mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-12 22:08:07 +00:00
free mainpanel on reload (it is not disposed by java GC for some reason)
This commit is contained in:
@@ -786,20 +786,24 @@ public class Helper {
|
||||
f.setAccessible(true);
|
||||
Object v = f.get(obj);
|
||||
if (v != null) {
|
||||
if (v instanceof Collection) {
|
||||
((Collection) v).clear();
|
||||
}
|
||||
if (v instanceof Component) {
|
||||
if (((Component) v).getParent() != null) {
|
||||
((Component) v).getParent().remove((Component) v);
|
||||
try {
|
||||
if (v instanceof Collection) {
|
||||
((Collection) v).clear();
|
||||
}
|
||||
}
|
||||
if (v instanceof Freed) {
|
||||
Freed freed = ((Freed) v);
|
||||
if (!freed.isFreeing()) {
|
||||
((Freed) v).free();
|
||||
if (v instanceof Component) {
|
||||
if (((Component) v).getParent() != null) {
|
||||
((Component) v).getParent().remove((Component) v);
|
||||
}
|
||||
}
|
||||
if (v instanceof Freed) {
|
||||
Freed freed = ((Freed) v);
|
||||
if (!freed.isFreeing()) {
|
||||
((Freed) v).free();
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
|
||||
f.set(obj, null);
|
||||
}
|
||||
} catch (UnsupportedOperationException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
|
||||
@@ -126,6 +126,7 @@ public final class MainFrameClassic extends AppFrame implements MainFrame {
|
||||
public void dispose() {
|
||||
removeAll();
|
||||
mainMenu.dispose();
|
||||
panel.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ public final class MainFrameRibbon extends AppRibbonFrame {
|
||||
public void dispose() {
|
||||
removeAll();
|
||||
mainMenu.dispose();
|
||||
panel.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
@@ -3208,4 +3209,21 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void disposeInner(Container container) {
|
||||
for (Component c : container.getComponents()) {
|
||||
if (c instanceof Container) {
|
||||
Container c2 = (Container) c;
|
||||
disposeInner(c2);
|
||||
}
|
||||
}
|
||||
|
||||
container.removeAll();
|
||||
container.setLayout(null);
|
||||
Helper.emptyObject(container);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
disposeInner(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user