Skip to content

Commit

Permalink
ScopyActivity: fix crash after closing scopy on Android
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Suciu <[email protected]>
  • Loading branch information
adisuciu committed Jan 14, 2022
1 parent 9f462d1 commit 38c8b20
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
39 changes: 22 additions & 17 deletions android/src/org/adi/scopy/ScopyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,36 @@ public class ScopyActivity extends QtActivity
{
public static native void saveSessionJavaHelper();

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState); //saveSessionJavaHelper();
}
@Override
public void onCreate(Bundle savedInstanceState)
{
System.out.println("-- ScopyActivity: onCreate");
super.onCreate(savedInstanceState);
}

@Override
protected void onStart()
{
super.onStart();
}
@Override
protected void onStart()
{
System.out.println("-- ScopyActivity: onStart");
super.onStart();
}

@Override
protected void onStop()
{
super.onStop();
}
@Override
protected void onStop()
{
System.out.println("-- ScopyActivity: onStop");
super.onStop();
}

protected void onPause(){
saveSessionJavaHelper();
System.out.println("-- ScopyActivity: onPause - saving application state to ini file ");
saveSessionJavaHelper(); // actually save the data
super.onPause();
}

protected void onDestroy(){
super.onPause();
System.out.println("-- ScopyActivity: onDestroy ");
super.onDestroy();
}

public void restart() {
Expand Down
2 changes: 2 additions & 0 deletions android/src/org/adi/scopy/ScopyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ScopyApplication extends QtApplication
@Override
public void onCreate()
{
System.out.println("QtApplication started");
String apk = getApplicationInfo().sourceDir;
String cache = getApplicationContext().getCacheDir().toString();
System.out.println("sourcedir: "+ getApplicationInfo().sourceDir);
Expand All @@ -58,4 +59,5 @@ public void onCreate()

super.onCreate();
}

}
8 changes: 6 additions & 2 deletions src/tool_launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2017,8 +2017,12 @@ bool ToolLauncher::eventFilter(QObject *watched, QEvent *event)

void ToolLauncher::saveSessionJavaHelper(JNIEnv *env, jobject /*thiz*/) {
qDebug()<<"-- Saving session";
getToolLauncherInstance()->tl_api->sync();
getToolLauncherInstance()->saveSettings();
ToolLauncher* tl = getToolLauncherInstance();
if(tl)
{
getToolLauncherInstance()->tl_api->sync();
getToolLauncherInstance()->saveSettings();
}
}

void ToolLauncher::registerNativeMethods()
Expand Down

0 comments on commit 38c8b20

Please sign in to comment.