Some Windows API functions like GetDiskFreeSpaceEx may produce error
dialogs. This is not desired. Fix this by temporarily blocking errors by
calling SetThreadErrorMode with certain error suppressing flags.
BUG: 371012
FIXED-IN: 5.28.0
brauch | |
vonreth |
Frameworks |
Some Windows API functions like GetDiskFreeSpaceEx may produce error
dialogs. This is not desired. Fix this by temporarily blocking errors by
calling SetThreadErrorMode with certain error suppressing flags.
BUG: 371012
FIXED-IN: 5.28.0
No Linters Available |
No Unit Test Coverage |
Can't really comment on this, though.
While I'm a huge fan of RAII you don't seem to be returning early from that function, can't you just set the value and set it back at the end without this new class?
Meanwhile I'm skeptical of the need to "set it back". Is there any case where such error dialog boxes would be desirable? It seems like their existence is an ancient-app-compatibility thing. The documentation for SetErrorMode recommends setting SEM_FAILCRITICALERRORS at app startup and leaving it that way.
The other interesting question is why we even query for free disk space on all drives, but I guess this patch still makes sense in any case.
While I'm a huge fan of RAII you don't seem to be returning early from that function
RAII is not only useful for cases where you return early.
..., can't you just set the value and set it back at the end without this new class?
I'm fairly sure, we'll need to guard other WinAPI calls as well. QStorageInfo from qtbase uses SetErrorMode/GetErrorMode a lot
I'm using a similar approach as Qt does. If some application decides to use a different "global" error mode, we should not interfere with it just because Solid wants to. This is a general purpose library after all.
Pushed:
commit f544380db86301f4833b2149dd46dca47acc8042
Author: Kevin Funk <kfunk@kde.org>
Date: Mon Oct 17 22:02:26 2016 +0200
Windows: Don't display error dialogs