Linux: autodetect gdb (to add -nograb) even in release mode

Application developers using Qt from their distribution, or from the
official installer, get a release-mode Qt build, where QT_DEBUG wasn't
defined. That's no reason to hit the issue that a breakpoint in
code that gets hit when opening a popup menu should lead to a complete
desktop freeze due to the mouse/keyboard grab.

Change-Id: Idf0df03ce5afb792261b62cabb06fab17b5e2952
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit a176f87a6451412a632866fda1fd79290b9d7520)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
David Faure 2025-02-05 10:13:38 +01:00 committed by Qt Cherry-pick Bot
parent 711b86fa24
commit 7328f90e64

View File

@ -71,7 +71,7 @@ using namespace Qt::StringLiterals;
// or, for older Linuxes, read out 'cmdline'.
static bool runningUnderDebugger()
{
#if defined(QT_DEBUG) && defined(Q_OS_LINUX)
#if defined(Q_OS_LINUX)
const QString parentProc = "/proc/"_L1 + QString::number(getppid());
const QFileInfo parentProcExe(parentProc + "/exe"_L1);
if (parentProcExe.isSymLink())
@ -157,12 +157,10 @@ QXcbIntegration::QXcbIntegration(const QStringList &parameters, int &argc, char
doGrabArg = false;
}
#if defined(QT_DEBUG)
if (!noGrabArg && !doGrabArg && underDebugger) {
qCDebug(lcQpaXcb, "Qt: gdb: -nograb added to command-line options.\n"
"\t Use the -dograb option to enforce grabbing.");
}
#endif
m_canGrab = (!underDebugger && !noGrabArg) || (underDebugger && doGrabArg);
static bool canNotGrabEnv = qEnvironmentVariableIsSet("QT_XCB_NO_GRAB_SERVER");