Skip to content

Commit

Permalink
QWindowsTheme: Suppress error dialogs when calling SHGetFileInfo().
Browse files Browse the repository at this point in the history
Set the error mode flag SEM_NOOPENFILEERRORBOX when calling Win32 API
SHGetFileInfo() to prevent it from prompting to insert media
as does QStorageInfoPrivate::mountedVolumes().

Task-number: QTBUG-32457
Task-number: QTBUG-48823
Change-Id: I01a2f99b5a75b39dd729509ca319f634e3dcd695
Reviewed-by: Maurice Kalinowski <[email protected]>
  • Loading branch information
FriedemannKleint committed May 24, 2016
1 parent 17a4384 commit c96ddd9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/plugins/platforms/windows/qwindowstheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ class ShGetFileInfoFunction
explicit ShGetFileInfoFunction(const wchar_t *fn, DWORD a, SHFILEINFO *i, UINT f, bool *r) :
m_fileName(fn), m_attributes(a), m_flags(f), m_info(i), m_result(r) {}

void operator()() const { *m_result = SHGetFileInfo(m_fileName, m_attributes, m_info, sizeof(SHFILEINFO), m_flags); }
void operator()() const
{
#ifndef Q_OS_WINCE
const UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif
*m_result = SHGetFileInfo(m_fileName, m_attributes, m_info, sizeof(SHFILEINFO), m_flags);
#ifndef Q_OS_WINCE
SetErrorMode(oldErrorMode);
#endif
}

private:
const wchar_t *m_fileName;
Expand Down

0 comments on commit c96ddd9

Please sign in to comment.