This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new a36e4aba92 Issue #9227 : Stop the quit-time tab folder error in the
Hop GUI (#9228)
a36e4aba92 is described below
commit a36e4aba92859b0c2bf65a08020c6ffc34939fd9
Author: Matt Casters <[email protected]>
AuthorDate: Tue Nov 3 09:11:25 2026 +0100
Issue #9227 : Stop the quit-time tab folder error in the Hop GUI (#9228)
Display.dispose() still runs queued asyncExec updates after editor tabs
are gone. Navigation and toolbar updates now return when the shell or
folder is already disposed.
---
.../main/java/org/apache/hop/ui/hopgui/HopGui.java | 10 +++-
.../hopgui/file/pipeline/HopGuiPipelineGraph.java | 8 ++++
.../ui/hopgui/file/shared/HopGuiAbstractGraph.java | 12 +++++
.../hopgui/file/workflow/HopGuiWorkflowGraph.java | 8 ++++
.../execution/ExecutionPerspective.java | 45 ++++++++++++------
.../perspective/explorer/ExplorerPerspective.java | 54 ++++++++++++++--------
.../perspective/metadata/MetadataPerspective.java | 47 ++++++++++++-------
.../perspective/DisabledPerspectivesTest.java | 17 ++++++-
.../ExecutionPerspectiveDisabledTest.java | 12 +++++
9 files changed, 162 insertions(+), 51 deletions(-)
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
index dd8786e708..a62f255f0a 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
@@ -2485,6 +2485,11 @@ public class HopGui
boolean running,
boolean paused) {
+ // Display.dispose() still runs queued asyncExec updates after the shell
is gone.
+ if (shell == null || shell.isDisposed()) {
+ return;
+ }
+
this.capabilityFileTypeHandler = handler;
mainMenuWidgets.enableMenuItem(
@@ -2528,18 +2533,19 @@ public class HopGui
mainMenuWidgets.enableMenuItem(
fileType, handler, ID_MAIN_MENU_RUN_PREVIEW,
IHopFileType.CAPABILITY_PREVIEW);
+ IHopPerspective perspective = getActivePerspective();
mainMenuWidgets.enableMenuItem(
fileType,
handler,
ID_MAIN_MENU_EDIT_NAV_PREV,
IHopFileType.CAPABILITY_FILE_HISTORY,
- getActivePerspective().hasNavigationPreviousFile());
+ perspective != null && perspective.hasNavigationPreviousFile());
mainMenuWidgets.enableMenuItem(
fileType,
handler,
ID_MAIN_MENU_EDIT_NAV_NEXT,
IHopFileType.CAPABILITY_FILE_HISTORY,
- getActivePerspective().hasNavigationNextFile());
+ perspective != null && perspective.hasNavigationNextFile());
mainToolbarWidgets.enableToolbarItem(
fileType, handler, ID_MAIN_TOOLBAR_SAVE, IHopFileType.CAPABILITY_SAVE,
changed);
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
index 8a01bf0ed9..ea542b1787 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
@@ -7419,6 +7419,14 @@ public class HopGuiPipelineGraph extends
HopGuiAbstractGraph
hopDisplay()
.asyncExec(
() -> {
+ // The checks above can go stale: this runnable also runs during
Display.dispose().
+ if (!isUiAlive()
+ || toolBarWidgets == null
+ || toolBar == null
+ || toolBar.isDisposed()) {
+ return;
+ }
+
setZoomLabel();
// Enable/disable the undo/redo toolbar buttons...
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/HopGuiAbstractGraph.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/HopGuiAbstractGraph.java
index b7d6f06b07..a18dafb85c 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/HopGuiAbstractGraph.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/shared/HopGuiAbstractGraph.java
@@ -108,6 +108,18 @@ public abstract class HopGuiAbstractGraph extends
DragViewZoomBase
return hopGui.getDisplay();
}
+ /**
+ * False once this graph or the Hop shell has been disposed. {@code
Display.dispose()} still runs
+ * queued {@code asyncExec} runnables, and those must not touch widgets.
+ */
+ protected boolean isUiAlive() {
+ if (isDisposed() || hopGui == null) {
+ return false;
+ }
+ Shell shell = hopGui.getShell();
+ return shell != null && !shell.isDisposed();
+ }
+
public abstract boolean hasChanged();
public abstract void setChanged();
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
index 24278896f6..d71c15d73e 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
@@ -4763,6 +4763,14 @@ public class HopGuiWorkflowGraph extends
HopGuiAbstractGraph
hopDisplay()
.asyncExec(
() -> {
+ // The checks above can go stale: this runnable also runs during
Display.dispose().
+ if (!isUiAlive()
+ || toolBarWidgets == null
+ || toolBar == null
+ || toolBar.isDisposed()) {
+ return;
+ }
+
setZoomLabel();
// Enable/disable the undo/redo toolbar buttons...
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
index 204d38540e..327745b986 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
@@ -1766,32 +1766,49 @@ public class ExecutionPerspective implements
IHopPerspective, TabClosable {
@Override
public void navigateToPreviousFile() {
- if (hasNavigationPreviousFile()) {
- int index = tabFolder.getSelectionIndex() - 1;
- if (index < 0) {
- index = tabFolder.getItemCount() - 1;
- }
- tabFolder.setSelection(index);
+ CTabFolder folder = navigationFolder();
+ if (folder == null) {
+ return;
}
+ int index = folder.getSelectionIndex() - 1;
+ if (index < 0) {
+ index = folder.getItemCount() - 1;
+ }
+ folder.setSelection(index);
}
@Override
public void navigateToNextFile() {
- if (hasNavigationNextFile()) {
- int index = tabFolder.getSelectionIndex() + 1;
- if (index >= tabFolder.getItemCount()) {
- index = 0;
- }
- tabFolder.setSelection(index);
+ CTabFolder folder = navigationFolder();
+ if (folder == null) {
+ return;
+ }
+ int index = folder.getSelectionIndex() + 1;
+ if (index >= folder.getItemCount()) {
+ index = 0;
}
+ folder.setSelection(index);
}
+ @Override
public boolean hasNavigationPreviousFile() {
- return tabFolder.getItemCount() > 1;
+ return navigationFolder() != null;
}
+ @Override
public boolean hasNavigationNextFile() {
- return tabFolder.getItemCount() > 1;
+ return navigationFolder() != null;
+ }
+
+ /**
+ * Live folder with another file to switch to. Null before the UI exists or
after the folder is
+ * disposed on exit.
+ */
+ private CTabFolder navigationFolder() {
+ if (tabFolder == null || tabFolder.isDisposed() ||
tabFolder.getItemCount() <= 1) {
+ return null;
+ }
+ return tabFolder;
}
@Override
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
index 20f438b9c3..56ca512e5f 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
@@ -5085,6 +5085,9 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
/** Update tree item */
public void updateTreeItem(IHopFileTypeHandler fileTypeHandler) {
+ if (fileTypeHandler == null || tree == null || tree.isDisposed()) {
+ return;
+ }
// If no filename, no need to update the tree item
String filename = fileTypeHandler.getFilename();
if (filename != null) {
@@ -5256,38 +5259,53 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
@Override
public void navigateToPreviousFile() {
- if (hasNavigationPreviousFile()) {
- CTabFolder active = getTargetTabFolder();
- int index = active.getSelectionIndex() - 1;
- if (index < 0) {
- index = active.getItemCount() - 1;
- }
- active.setSelection(index);
- updateGui();
+ CTabFolder active = navigationFolder();
+ if (active == null) {
+ return;
}
+ int index = active.getSelectionIndex() - 1;
+ if (index < 0) {
+ index = active.getItemCount() - 1;
+ }
+ active.setSelection(index);
+ updateGui();
}
@Override
public void navigateToNextFile() {
- if (hasNavigationNextFile()) {
- CTabFolder active = getTargetTabFolder();
- int index = active.getSelectionIndex() + 1;
- if (index >= active.getItemCount()) {
- index = 0;
- }
- active.setSelection(index);
- updateGui();
+ CTabFolder active = navigationFolder();
+ if (active == null) {
+ return;
}
+ int index = active.getSelectionIndex() + 1;
+ if (index >= active.getItemCount()) {
+ index = 0;
+ }
+ active.setSelection(index);
+ updateGui();
}
@Override
public boolean hasNavigationPreviousFile() {
- return getTargetTabFolder().getItemCount() > 1;
+ return navigationFolder() != null;
}
@Override
public boolean hasNavigationNextFile() {
- return getTargetTabFolder().getItemCount() > 1;
+ return navigationFolder() != null;
+ }
+
+ /**
+ * Active folder when it has another file to switch to. Null when the folder
is missing or already
+ * disposed, which happens when {@code Display.dispose()} runs queued GUI
updates after the editor
+ * tabs are gone.
+ */
+ private CTabFolder navigationFolder() {
+ CTabFolder folder = getTargetTabFolder();
+ if (folder == null || folder.isDisposed() || folder.getItemCount() <= 1) {
+ return null;
+ }
+ return folder;
}
@Override
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
index bf86303bdb..9c62c79ffa 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
@@ -3442,36 +3442,51 @@ public class MetadataPerspective implements
IHopPerspective, TabClosable, IMetad
@Override
public void navigateToPreviousFile() {
- if (hasNavigationPreviousFile()) {
- int index = tabFolder.getSelectionIndex() - 1;
- if (index < 0) {
- index = tabFolder.getItemCount() - 1;
- }
- tabFolder.setSelection(index);
- updateGui();
+ CTabFolder folder = navigationFolder();
+ if (folder == null) {
+ return;
+ }
+ int index = folder.getSelectionIndex() - 1;
+ if (index < 0) {
+ index = folder.getItemCount() - 1;
}
+ folder.setSelection(index);
+ updateGui();
}
@Override
public void navigateToNextFile() {
- if (hasNavigationNextFile()) {
- int index = tabFolder.getSelectionIndex() + 1;
- if (index >= tabFolder.getItemCount()) {
- index = 0;
- }
- tabFolder.setSelection(index);
- updateGui();
+ CTabFolder folder = navigationFolder();
+ if (folder == null) {
+ return;
+ }
+ int index = folder.getSelectionIndex() + 1;
+ if (index >= folder.getItemCount()) {
+ index = 0;
}
+ folder.setSelection(index);
+ updateGui();
}
@Override
public boolean hasNavigationPreviousFile() {
- return tabFolder.getItemCount() > 1;
+ return navigationFolder() != null;
}
@Override
public boolean hasNavigationNextFile() {
- return tabFolder.getItemCount() > 1;
+ return navigationFolder() != null;
+ }
+
+ /**
+ * Live folder with another file to switch to. Null before the UI exists or
after the folder is
+ * disposed on exit.
+ */
+ private CTabFolder navigationFolder() {
+ if (tabFolder == null || tabFolder.isDisposed() ||
tabFolder.getItemCount() <= 1) {
+ return null;
+ }
+ return tabFolder;
}
@Override
diff --git
a/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/DisabledPerspectivesTest.java
b/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/DisabledPerspectivesTest.java
index 33ba539efb..07e6acb407 100644
---
a/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/DisabledPerspectivesTest.java
+++
b/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/DisabledPerspectivesTest.java
@@ -64,6 +64,13 @@ class DisabledPerspectivesTest {
assertNull(perspective.getActiveEditor());
assertTrue(perspective.getItems().isEmpty());
assertFalse(perspective.remove(null));
+ assertFalse(perspective.hasNavigationPreviousFile());
+ assertFalse(perspective.hasNavigationNextFile());
+ assertDoesNotThrow(
+ () -> {
+ perspective.navigateToPreviousFile();
+ perspective.navigateToNextFile();
+ });
}
/**
@@ -75,7 +82,15 @@ class DisabledPerspectivesTest {
ExplorerPerspective perspective = new ExplorerPerspective();
assertFalse(perspective.isActive());
- assertDoesNotThrow(perspective::activate);
+ assertFalse(perspective.hasNavigationPreviousFile());
+ assertFalse(perspective.hasNavigationNextFile());
+ assertDoesNotThrow(
+ () -> {
+ perspective.activate();
+ perspective.navigateToPreviousFile();
+ perspective.navigateToNextFile();
+ perspective.updateTreeItem(null);
+ });
}
@Test
diff --git
a/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspectiveDisabledTest.java
b/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspectiveDisabledTest.java
index 218ecfc79f..e43b601a1e 100644
---
a/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspectiveDisabledTest.java
+++
b/ui/src/test/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspectiveDisabledTest.java
@@ -92,6 +92,18 @@ class ExecutionPerspectiveDisabledTest {
assertFalse(disabledPerspective.isActive());
}
+ @Test
+ void navigationDoesNotFailWithoutATabFolder() {
+ // File-capability updates ask this during shutdown, after the tab folder
is gone.
+ assertFalse(disabledPerspective.hasNavigationPreviousFile());
+ assertFalse(disabledPerspective.hasNavigationNextFile());
+ assertDoesNotThrow(
+ () -> {
+ disabledPerspective.navigateToPreviousFile();
+ disabledPerspective.navigateToNextFile();
+ });
+ }
+
@Test
void getInstanceDoesNotReturnNullWhenNeverConstructed() throws Exception {
Field instanceField =
ExecutionPerspective.class.getDeclaredField("instance");