diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-04-29 14:17:08 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-04-29 14:17:09 +0200 |
commit | 85e3c53e5c5e2de993c90ece324a68d0ff62f417 (patch) | |
tree | 6f078576f01f18afcdae773e48664640ce795abe /src/plugins/platforms/xcb/qxcbintegration.cpp | |
parent | 2e749c089f6fd93909e7cd4cc8129f2969b35185 (diff) | |
parent | 7f943968ade6a65321d4a00822f5b3a034a19e0c (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I2a54058b64ac69c78b4120fdaf09b96e025a4c6c
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbintegration.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index f0cabea43d..dd1466d23c 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -91,8 +91,34 @@ #endif #endif +#include <QtCore/QFileInfo> + QT_BEGIN_NAMESPACE +#if defined(QT_DEBUG) && defined(Q_OS_LINUX) +// Find out if our parent process is gdb by looking at the 'exe' symlink under /proc,. +// or, for older Linuxes, read out 'cmdline'. +static bool runningUnderDebugger() +{ + const QString parentProc = QLatin1String("/proc/") + QString::number(getppid()); + const QFileInfo parentProcExe(parentProc + QLatin1String("/exe")); + if (parentProcExe.isSymLink()) + return parentProcExe.symLinkTarget().endsWith(QLatin1String("/gdb")); + QFile f(parentProc + QLatin1String("/cmdline")); + if (!f.open(QIODevice::ReadOnly)) + return false; + QByteArray s; + char c; + while (f.getChar(&c) && c) { + if (c == '/') + s.clear(); + else + s += c; + } + return s == "gdb"; +} +#endif + QXcbIntegration::QXcbIntegration(const QStringList ¶meters) : m_eventDispatcher(createUnixEventDispatcher()) , m_services(new QGenericUnixServices) @@ -104,7 +130,15 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters) #endif m_nativeInterface.reset(new QXcbNativeInterface); - m_connections << new QXcbConnection(m_nativeInterface.data()); + bool canGrab = true; + #if defined(QT_DEBUG) && defined(Q_OS_LINUX) + canGrab = !runningUnderDebugger(); + #endif + static bool canNotGrabEnv = qgetenv("QT_XCB_NO_GRAB_SERVER").length(); + if (canNotGrabEnv) + canGrab = false; + + m_connections << new QXcbConnection(m_nativeInterface.data(), canGrab); for (int i = 0; i < parameters.size() - 1; i += 2) { #ifdef Q_XCB_DEBUG |