Skip to content

Commit

Permalink
fix: resolve multi-threaded unloading
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jan 20, 2020
1 parent 08f9722 commit bb0fad2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jadx-core/src/main/java/jadx/api/JavaClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void decompile() {

public synchronized void refresh() {
listsLoaded = false;
cls.reloadCode();
cls.reRunDecompile();
}

public synchronized String getSmali() {
Expand Down
10 changes: 9 additions & 1 deletion jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,21 @@ public ICodeInfo getCode() {
return decompile(true);
}

public synchronized ICodeInfo reRunDecompile() {
return decompile(false);
}

public synchronized ICodeInfo reloadCode() {
unload();
deepUnload();
return decompile(false);
}

private void deepUnload() {
public void deepUnload() {
if (cls == null) {
// manually added class
return;
}
clearAttributes();
root().getConstValues().removeForClass(this);
initialLoad();
Expand Down
4 changes: 4 additions & 0 deletions jadx-gui/src/main/java/jadx/gui/ui/RenameDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ private int refreshState(RootNode rootNode) {
refreshTabs(mainWindow.getTabbedPane(), updatedClasses);

if (updatedClasses.size() > 0) {
for (JavaClass updatedClass : updatedClasses) {
updatedClass.unload();
updatedClass.getClassNode().deepUnload();
}
setRefreshTask(updatedClasses);
}

Expand Down

0 comments on commit bb0fad2

Please sign in to comment.