Commit 453d191d authored by Kai Koehne's avatar Kai Koehne
Browse files

Prevent 'qmake -query' from bringing up modal message dialog on startup

Temporarily set the ErrorMode so that no Windows error message box will
show up in case qmake fails to run (e.g. because of missing .dll's).
The error mode will automatically be inherited by child processes.

This fixes an issue that actually became virulent by another bug fix
( cbb05306


Task-number: QTCREATORBUG-11962
Change-Id: I5baccf52baee46f3d45b69ea0a13d77e4e113fbd
Reviewed-by: default avatarFriedemann Kleint <>
Reviewed-by: default avatarTobias Hunger <>
parent 254ecd19
......@@ -172,4 +172,22 @@ QTCREATOR_UTILS_EXPORT bool is64BitWindowsBinary(const QString &binaryIn)
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
unsigned int errorMode = SetErrorMode(originalErrorMode);
// someone else messed with the error mode in between? Better not touch ...
QTC_ASSERT(errorMode == silenceErrorMode, SetErrorMode(errorMode));
} // namespace Utils
......@@ -49,6 +49,23 @@ QTCREATOR_UTILS_EXPORT bool is64BitWindowsSystem();
// Check for a 64bit binary.
QTCREATOR_UTILS_EXPORT bool is64BitWindowsBinary(const QString &binary);
// RAII class to temporarily prevent windows crash messages from popping up using the
// application-global (!) error mode.
// Useful primarily for QProcess launching, since the setting will be inherited.
class QTCREATOR_UTILS_EXPORT WindowsCrashDialogBlocker {
#ifdef Q_OS_WIN
const unsigned int silenceErrorMode;
const unsigned int originalErrorMode;
#endif // Q_OS_WIN
} // namespace Utils
#endif // WINUTILS_H
......@@ -48,6 +48,7 @@
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
#include <utils/synchronousprocess.h>
#include <utils/winutils.h>
#include <QDir>
#include <QUrl>
......@@ -1206,6 +1207,9 @@ static QByteArray runQmakeQuery(const FileName &binary, const Environment &env,
const int timeOutMS = 30000; // Might be slow on some machines.
// Prevent e.g. qmake 4.x on MinGW to show annoying errors about missing dll's.
WindowsCrashDialogBlocker crashDialogBlocker;
QProcess process;
process.start(binary.toString(), QStringList(QLatin1String("-query")), QIODevice::ReadOnly);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment