GNOME Bugzilla – Bug 777308
GModule win32: disable error dialog popup
Last modified: 2017-11-02 15:50:43 UTC
When loading a module on win32, a blocking error dialog pops up whenever the module could not be loaded. This is particularly annoying when module loading failure is a harmless and expected event... The attached patch temporarily disables these error dialogs from popping up.
Created attachment 343533 [details] [review] GModule win32: disable error dialogs
Review of attachment 343533 [details] [review]: ::: gmodule/gmodule-win32.c @@ +80,3 @@ + /* suppress error dialog */ + SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); GLib now requires Windows 7 (https://wiki.gnome.org/Projects/GLib/SupportedPlatforms), so we can (and should) use SetThreadErrorMode() to prevent threading problems with this code fighting with the error mode in other threads. https://msdn.microsoft.com/en-us/library/windows/desktop/dd553630(v=vs.85).aspx Also, code-style-wise, please put a space before the first `(` in a function call. @@ +83,2 @@ handle = LoadLibraryW (wfilename); + SetErrorMode(0); This should restore the previous set of flags, as returned by the first SetThreadErrorMode() call.
Ok thanks, will make the necessary changes soon.
Created attachment 362825 [details] [review] GModule win32 suppress error dialogs patch New patch, with fixes per your previous comments.
Review of attachment 362825 [details] [review]: ::: gmodule/gmodule-win32.c @@ +81,3 @@ + /* suppress error dialog */ + SetThreadErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS, &old_mode); old_mode is only going to be valid if SetThreadErrorMode() succeeds, so you need to check the return value and skip the SetThreadErrorMode(old_mode) call if the first call fails.
Created attachment 362837 [details] [review] GModule win32 suppress error dialogs patch Updated with check for SetThreadErrorMode return value
Review of attachment 362837 [details] [review]: Looks good to me, thanks. There’s only slight value in calling set_error(""), given that the caller of g_module_open() can’t detect the error from the SetThreadErrorMode() call. The g_module_close() implementation in gmodule-win32.c does this too, though, so there’s precedent.
Ok thanks for merging it in
commit 719edde63b1f4756c61c325e8457c7d033be8194 (HEAD -> master, origin/master, origin/HEAD) Author: Tom Schoonjans <Tom.Schoonjans@diamond.ac.uk> Date: Mon Jan 16 11:39:49 2017 +0530 GModule win32: disable error dialog popup When loading a module on win32, a blocking error dialog pops up whenever the module could not be loaded. This is particularly annoying when module loading failure is a harmless and expected event... This patch temporarily disables these error dialogs from popping up. https://bugzilla.gnome.org/show_bug.cgi?id=777308