From: Jim Procter Date: Wed, 15 Jun 2022 14:54:56 +0000 (+0100) Subject: JAL-1988 JAL-3416 avoid unnecessary static flag X-Git-Tag: Release_2_11_2_6~47 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ac63b721ce80f32a04a6d0eeff29192bad50972e;p=jalview.git JAL-1988 JAL-3416 avoid unnecessary static flag --- 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); }