Added temp debug code to prevent exception related to reusing disposed

ComponentPlaceholders
This commit is contained in:
dragonmacher 2021-01-19 17:11:36 -05:00
parent ca89ec0f14
commit c11246634d
2 changed files with 44 additions and 14 deletions

View File

@ -27,9 +27,9 @@ import org.jdom.Element;
import docking.help.HelpService;
import docking.widgets.OptionDialog;
import docking.widgets.tabbedpane.DockingTabRenderer;
import ghidra.util.HelpLocation;
import ghidra.util.Swing;
import ghidra.util.*;
import ghidra.util.exception.AssertException;
import utilities.util.reflection.ReflectionUtilities;
/**
* Node object for managing one or more components. If more that one managed component
@ -187,14 +187,20 @@ class ComponentNode extends Node {
if (getTopLevelNode() == null) {
return; // this node has been disconnected.
}
if (placeholder.isShowing()) {
if (top == placeholder) {
top = null;
}
invalidate();
}
WindowNode topLevelNode = getTopLevelNode();
topLevelNode.componentRemoved(placeholder);
doRemove(placeholder);
}
private void doRemove(ComponentPlaceholder placeholder) {
windowPlaceholders.remove(placeholder);
placeholder.setNode(null);
if (windowPlaceholders.isEmpty()) {
@ -217,13 +223,10 @@ class ComponentNode extends Node {
invalidate();
winMgr.scheduleUpdate();
}
placeholder.setProvider(null);
if (!keepEmptyPlaceholder) {
windowPlaceholders.remove(placeholder);
placeholder.setNode(null);
if (windowPlaceholders.isEmpty()) {
parent.removeNode(this);
}
doRemove(placeholder);
}
}
@ -248,7 +251,7 @@ class ComponentNode extends Node {
if (isDisposed) {
throw new AssertException(
"Attempted to reuse a component window node");
"Attempted to reuse a disposed component window node");
}
if (!invalid) {
@ -265,6 +268,18 @@ class ComponentNode extends Node {
populateActiveComponents(activeComponents);
int count = activeComponents.size();
if (count == 1) {
//
// TODO Hack Alert! (When this is removed, also update ComponentPlaceholder)
//
ComponentPlaceholder nextTop = activeComponents.get(0);
if (nextTop.isDisposed()) {
// This should not happen! We have seen this bug recently
Msg.debug(this, "Found disposed component that was not removed from the active " +
"list: " + nextTop, ReflectionUtilities.createJavaFilteredThrowable());
return null;
}
top = activeComponents.get(0);
comp = top.getComponent();
comp.setBorder(BorderFactory.createRaisedBevelBorder());

View File

@ -22,10 +22,14 @@ import java.util.List;
import javax.swing.*;
import org.apache.commons.lang3.StringUtils;
import docking.action.DockingAction;
import docking.action.DockingActionIf;
import ghidra.util.Msg;
import ghidra.util.Swing;
import ghidra.util.exception.AssertException;
import utilities.util.reflection.ReflectionUtilities;
/**
* Class to hold information about a dockable component with respect to its position within the
@ -108,6 +112,16 @@ public class ComponentPlaceholder {
* @param node the component node containing this placeholder.
*/
void setNode(ComponentNode node) {
if (node != null && disposed) {
//
// TODO Hack Alert! (When this is removed, also update ComponentNode)
//
// This should not happen! We have seen this bug recently
Msg.debug(this, "Found disposed component that was not removed from the hierarchy " +
"list: " + this, ReflectionUtilities.createJavaFilteredThrowable());
}
compNode = node;
}
@ -200,6 +214,10 @@ public class ComponentPlaceholder {
}
}
public boolean isDisposed() {
return disposed;
}
void dispose() {
disposed = true;
@ -289,8 +307,9 @@ public class ComponentPlaceholder {
public DockableComponent getComponent() {
if (disposed) {
throw new AssertException(
"Attempted to get a component for a disposed component placeholder");
"Attempted to get a component for a disposed placeholder - " + this);
}
boolean isDocking = true;
if (compNode != null) {
isDocking = compNode.winMgr.isDocking();
@ -554,7 +573,7 @@ public class ComponentPlaceholder {
*/
public String getFullTitle() {
String text = title;
if (subTitle != null && !subTitle.isEmpty()) {
if (!StringUtils.isBlank(subTitle)) {
text += " - " + subTitle;
}
return text;
@ -564,8 +583,4 @@ public class ComponentPlaceholder {
public String toString() {
return "name=\"" + name + "\", fullTitle=\"" + getFullTitle() + "\"";
}
public boolean isDisposed() {
return disposed;
}
}