< prev index next >

src/solaris/classes/sun/awt/X11/XFramePeer.java

Print this page
rev 1571 : 8010297: Missing isLoggable() checks in logging code
Summary: Add isLoggable() checks
Reviewed-by: anthony, mchung, serb
Contributed-by: Laurent Bourges <bourges.laurent@gmail.com>

@@ -210,11 +210,13 @@
             }
         );
     }
 
     public void setMaximizedBounds(Rectangle b) {
-        if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting maximized bounds to " + b);
+        if (insLog.isLoggable(Level.FINE)) {
+            insLog.fine("Setting maximized bounds to " + b);
+        }
         if (b == null) return;
         maxBounds = new Rectangle(b);
         XToolkit.awtLock();
         try {
             XSizeHints hints = getHints();

@@ -227,50 +229,62 @@
             if (b.height != Integer.MAX_VALUE) {
                 hints.set_max_height(b.height);
             } else {
                 hints.set_max_height((int)XlibWrapper.DisplayHeight(XToolkit.getDisplay(), XlibWrapper.DefaultScreen(XToolkit.getDisplay())));
             }
-            if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(hints.get_flags()));
+            if (insLog.isLoggable(Level.FINER)) {
+                insLog.finer("Setting hints, flags " + XlibWrapper.hintsToString(hints.get_flags()));
+            }
             XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), window, hints.pData);
         } finally {
             XToolkit.awtUnlock();
         }
     }
 
     public int getState() { return state; }
 
     public void setState(int newState) {
         if (!isShowing()) {
+            if (stateLog.isLoggable(Level.FINER)) {
             stateLog.finer("Frame is not showing");
+            }
             state = newState;
             return;
         }
         changeState(newState);
     }
 
     void changeState(int newState) {
         int changed = state ^ newState;
         int changeIconic = changed & Frame.ICONIFIED;
         boolean iconic = (newState & Frame.ICONIFIED) != 0;
+        if (stateLog.isLoggable(Level.FINER)) {
         stateLog.log(Level.FINER, "Changing state, old state {0}, new state {1}(iconic {2})",
                      new Object[] {Integer.valueOf(state), Integer.valueOf(newState), Boolean.valueOf(iconic)});
+        }
         if (changeIconic != 0 && iconic) {
-            if (stateLog.isLoggable(Level.FINER)) stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
+            if (stateLog.isLoggable(Level.FINER)) {
+                stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
+            }
             XToolkit.awtLock();
             try {
                 int res = XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), getShell(), getScreenNumber());
-                if (stateLog.isLoggable(Level.FINER)) stateLog.finer("XIconifyWindow returned " + res);
+                if (stateLog.isLoggable(Level.FINER)) {
+                    stateLog.finer("XIconifyWindow returned " + res);
+                }
             }
             finally {
                 XToolkit.awtUnlock();
             }
         }
         if ((changed & ~Frame.ICONIFIED) != 0) {
             setExtendedState(newState);
         }
         if (changeIconic != 0 && !iconic) {
-            if (stateLog.isLoggable(Level.FINER)) stateLog.finer("DeIconifying " + this);
+            if (stateLog.isLoggable(Level.FINER)) {
+                stateLog.finer("DeIconifying " + this);
+            }
             xSetVisible(true);
         }
     }
 
     void setExtendedState(int newState) {

@@ -294,23 +308,29 @@
             return;
         }
 
         int changed = state ^ newState.intValue();
         if (changed == 0) {
+            if (stateLog.isLoggable(Level.FINER)) {
             stateLog.finer("State is the same: " + state);
+            }
             return;
         }
 
         int old_state = state;
         state = newState.intValue();
 
         if ((changed & Frame.ICONIFIED) != 0) {
             if ((state & Frame.ICONIFIED) != 0) {
+                if (stateLog.isLoggable(Level.FINER)) {
                 stateLog.finer("Iconified");
+                }
                 handleIconify();
             } else {
+                if (stateLog.isLoggable(Level.FINER)) {
                 stateLog.finer("DeIconified");
+                }
                 content.purgeIconifiedExposeEvents();
                 handleDeiconify();
             }
         }
         handleStateChange(old_state, state);

@@ -343,11 +363,13 @@
         XToolkit.awtLock();
         try {
             XWMHints hints = getWMHints();
             hints.set_flags((int)XlibWrapper.StateHint | hints.get_flags());
             hints.set_initial_state(wm_state);
-            if (stateLog.isLoggable(Level.FINE)) stateLog.fine("Setting initial WM state on " + this + " to " + wm_state);
+            if (stateLog.isLoggable(Level.FINE)) {
+                stateLog.fine("Setting initial WM state on " + this + " to " + wm_state);
+            }
             XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
         }
         finally {
             XToolkit.awtUnlock();
         }
< prev index next >