From ac63b721ce80f32a04a6d0eeff29192bad50972e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 15 Jun 2022 15:54:56 +0100 Subject: [PATCH] JAL-1988 JAL-3416 avoid unnecessary static flag --- src/jalview/jbgui/APQHandlers.java | 8 ++------ src/jalview/jbgui/GDesktop.java | 7 ++++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/jalview/jbgui/APQHandlers.java b/src/jalview/jbgui/APQHandlers.java index e18ec44..00ce170 100644 --- a/src/jalview/jbgui/APQHandlers.java +++ b/src/jalview/jbgui/APQHandlers.java @@ -29,8 +29,6 @@ import jalview.util.MessageManager; public class APQHandlers { - protected static boolean setAPQHandlers = false; - public static boolean setAPQHandlers(GDesktop desktop) { FlatDesktop.setAboutHandler(() -> { @@ -81,10 +79,8 @@ public class APQHandlers response.cancelQuit(); } }); - - setAPQHandlers = true; - - return setAPQHandlers; + // if we got to here, no exceptions occurred when we set the handlers. + return true; } } diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index e3f171d..98217b1 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -140,6 +140,7 @@ public class GDesktop extends JFrame */ private void jbInit() throws Exception { + boolean apqHandlersSet = false; /** * APQHandlers sets handlers for About, Preferences and Quit actions * peculiar to macOS's application menu. APQHandlers will check to see if a @@ -147,7 +148,7 @@ public class GDesktop extends JFrame */ try { - APQHandlers.setAPQHandlers(this); + apqHandlersSet = APQHandlers.setAPQHandlers(this); } catch (Exception e) { System.out.println("Cannot set APQHandlers"); @@ -401,12 +402,12 @@ public class GDesktop extends JFrame FileMenu.add(loadState); FileMenu.addSeparator(); FileMenu.add(quit); - if (!APQHandlers.setAPQHandlers) + if (!apqHandlersSet) { HelpMenu.add(aboutMenuItem); } HelpMenu.add(documentationMenuItem); - if (!APQHandlers.setAPQHandlers) + if (!apqHandlersSet) { toolsMenu.add(preferences); } -- 1.7.10.2