Bug 1274444 - Check for null console before attempting to flash it; r?glandium draft
authorGregory Szorc <gps@mozilla.com>
Fri, 20 May 2016 14:22:38 -0700
changeset 369230 271026cc6b00607bc115c2361348d69dda889977
parent 369022 c67dc1f9fab86d4f2cf3224307809c44fe3ce820
child 521519 99e5f1a1826649836ce9eb5ba575f3502466d414
push id18802
push userbmo:gps@mozilla.com
push dateFri, 20 May 2016 21:26:16 +0000
reviewersglandium
bugs1274444
milestone49.0a1
Bug 1274444 - Check for null console before attempting to flash it; r?glandium GetConsoleWindow() can return NULL. Previously, we may have passed a NULL console reference into FlashWindowEx(). On my machine (when running in a console), passing NULL doesn't seem to cause an error. But since we have a report of this function hanging, it is quite possible it can cause hangs in other scenarios. Since a NULL console won't result in any notification, let's not call FlashWindowEx() when no console is available. MozReview-Commit-ID: LrKX8weUkzX
python/mozbuild/mozbuild/base.py
--- a/python/mozbuild/mozbuild/base.py
+++ b/python/mozbuild/mozbuild/base.py
@@ -444,18 +444,25 @@ class MozbuildObject(ProcessExecutionMix
                                 ("dwFlags", DWORD),
                                 ("uCount", UINT),
                                 ("dwTimeout", DWORD)]
                 FlashWindowExProto = WINFUNCTYPE(BOOL, POINTER(FLASHWINDOW))
                 FlashWindowEx = FlashWindowExProto(("FlashWindowEx", windll.user32))
                 FLASHW_CAPTION = 0x01
                 FLASHW_TRAY = 0x02
                 FLASHW_TIMERNOFG = 0x0C
+
+                # GetConsoleWindows returns NULL if no console is attached. We
+                # can't flash nothing.
+                console = windll.kernel32.GetConsoleWindow()
+                if not console:
+                    return
+
                 params = FLASHWINDOW(sizeof(FLASHWINDOW),
-                                    windll.kernel32.GetConsoleWindow(),
+                                    console,
                                     FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0)
                 FlashWindowEx(params)
         except Exception as e:
             self.log(logging.WARNING, 'notifier-failed', {'error':
                 e.message}, 'Notification center failed: {error}')
 
     @property
     def _config_guess(self):