Skip to content

Commit

Permalink
Eliminate possible runaway loop on EDT
Browse files Browse the repository at this point in the history
updateGui would sleep if tabbedPane is null, but this isn't necessary as
updateGui should be called again when the tabbedPane is initialized
anyway. Now just return if tabbedPane isn't defined yet.

Change-Id: I94d17a8b4c6e780292f6346741def28a0a5e7408
  • Loading branch information
Walter Kolczynski authored and Walter Kolczynski committed Apr 4, 2018
1 parent 15e0500 commit f19d8e3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/net/bubbaland/gui/BubbaDragDropTabFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public void addTab(String tabName) {
BubbaMainPanel newTab = this.tabFactory(tabName.replaceFirst(" \\([0-9]*\\)", ""));
this.tabbedPane.addTab(tabName, newTab);
this.tabbedPane.setSelectedComponent(newTab);
newTab.updateGui();
} catch (IllegalArgumentException | SecurityException exception) {
exception.printStackTrace();
}
Expand Down Expand Up @@ -194,13 +193,12 @@ public String getTabDescription() {
public void updateGui() {
super.updateGui();

// Propagate update to current tab
while (this.tabbedPane == null) {
if (this.tabbedPane == null) {
System.out.println(this.getClass().getSimpleName() + "Can't update null tabbedPane!");
try {
Thread.sleep(50);
} catch (final InterruptedException exception) {}
return;
}

// Propagate update to current tab
Component tab = this.tabbedPane.getSelectedComponent();
if (tab instanceof BubbaMainPanel) {
( (BubbaMainPanel) tab ).updateGui();
Expand Down

0 comments on commit f19d8e3

Please sign in to comment.