fix(gui): add missing sync in clean task at search dialog close (#2363)

This commit is contained in:
Skylot
2024-12-21 19:44:15 +00:00
parent fe0ab5ebf8
commit 73966fda89
3 changed files with 20 additions and 7 deletions
@@ -456,13 +456,15 @@ public class ClassNode extends NotificationAttrNode
if (state == NOT_LOADED) {
return;
}
methods.forEach(MethodNode::unload);
innerClasses.forEach(ClassNode::unload);
fields.forEach(FieldNode::unload);
unloadAttributes();
setState(NOT_LOADED);
this.loadStage = LoadStage.NONE;
this.smali = null;
synchronized (clsInfo) { // decompilation sync
methods.forEach(MethodNode::unload);
innerClasses.forEach(ClassNode::unload);
fields.forEach(FieldNode::unload);
unloadAttributes();
setState(NOT_LOADED);
this.loadStage = LoadStage.NONE;
this.smali = null;
}
}
private void buildCache() {
@@ -22,6 +22,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.api.utils.tasks.ITaskExecutor;
import jadx.core.utils.exceptions.JadxRuntimeException;
import jadx.gui.settings.JadxSettings;
import jadx.gui.ui.MainWindow;
import jadx.gui.ui.panel.ProgressPanel;
@@ -81,6 +82,15 @@ public class BackgroundExecutor {
}
}
public synchronized void waitForComplete() {
try {
// add empty task and wait its completion
taskQueueExecutor.submit(UiUtils.EMPTY_RUNNABLE).get();
} catch (Exception e) {
throw new JadxRuntimeException("Failed to wait tasks completion", e);
}
}
public void execute(String title, List<Runnable> backgroundJobs, Consumer<TaskStatus> onFinishUiRunnable) {
execute(new SimpleTask(title, backgroundJobs, onFinishUiRunnable));
}
@@ -182,6 +182,7 @@ public class SearchDialog extends CommonSearchDialog {
removeActiveTabListener();
searchBackgroundExecutor.execute(() -> {
stopSearchTask();
mainWindow.getBackgroundExecutor().waitForComplete();
unloadTempData();
});
super.dispose();