summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/QTEMPORARYFILE_LICENSE.txt26
-rw-r--r--src/corelib/io/qsavefile.cpp2
-rw-r--r--src/corelib/io/qt_attribution.json15
-rw-r--r--src/corelib/io/qtemporaryfile.cpp11
-rw-r--r--src/corelib/io/qtemporaryfile_p.h7
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp5
-rw-r--r--src/corelib/kernel/qeventloop.cpp14
-rw-r--r--src/corelib/kernel/qobject.cpp8
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp4
-rw-r--r--src/corelib/thread/qthread_p.h4
-rw-r--r--src/corelib/thread/qthread_unix.cpp26
-rw-r--r--src/corelib/thread/qthread_win.cpp20
-rw-r--r--src/gui/opengl/qopengltexture.cpp2
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsnativeimage.cpp6
-rw-r--r--src/plugins/platformthemes/flatpak/qflatpaktheme.h2
-rw-r--r--src/widgets/kernel/qaction.cpp5
-rw-r--r--src/widgets/widgets/qlineedit.cpp5
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp5
18 files changed, 70 insertions, 97 deletions
diff --git a/src/corelib/io/QTEMPORARYFILE_LICENSE.txt b/src/corelib/io/QTEMPORARYFILE_LICENSE.txt
deleted file mode 100644
index f5f1a2e05e..0000000000
--- a/src/corelib/io/QTEMPORARYFILE_LICENSE.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright (c) 1987, 1993
- The Regents of the University of California. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. Neither the name of the University nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index 56934a9a0f..0cbc8c2234 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -264,7 +264,7 @@ bool QSaveFile::open(OpenMode mode)
}
#endif
- d->fileEngine = new QTemporaryFileEngine(&d->finalFileName);
+ d->fileEngine = new QTemporaryFileEngine(&d->finalFileName, QTemporaryFileEngine::Win32NonShared);
// if the target file exists, we'll copy its permissions below,
// but until then, let's ensure the temporary file is not accessible
// to a third party
diff --git a/src/corelib/io/qt_attribution.json b/src/corelib/io/qt_attribution.json
index 0fa4502db4..e9eb9c85e4 100644
--- a/src/corelib/io/qt_attribution.json
+++ b/src/corelib/io/qt_attribution.json
@@ -1,17 +1,3 @@
-[
-{
- "Id": "qtemporaryfile",
- "Name": "Parts of QTemporaryFile",
- "QDocModule": "qtcore",
- "QtUsage": "Used in Qt Core. Disable the qtemporaryfile feature to avoid.",
- "Path": "qtemporaryfile.cpp",
-
- "Description": "Generates a unique file path and returns a native handle to the open file.",
- "License": "BSD 3-clause \"New\" or \"Revised\" License",
- "LicenseId": "BSD-3-Clause",
- "LicenseFile": "QTEMPORARYFILE_LICENSE.txt",
- "Copyright": "Copyright (c) 1987, 1993 The Regents of the University of California."
-},
{
"Id": "psl",
"Name": "The Public Suffix List",
@@ -39,4 +25,3 @@ supported by Qt (by the QNetworkCookieJar class).",
"Copyright": "The list was originally provided by Jo Hermans <jo.hermans@gmail.com>.
It is now maintained on github (https://github.com/publicsuffix/list)."
}
-]
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 73249d7df8..1983a22c65 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -207,7 +207,7 @@ QFileSystemEntry::NativePath QTemporaryFileName::generateNext()
changed and contain the generated path name.
*/
static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &templ,
- quint32 mode, QSystemError &error)
+ quint32 mode, int flags, QSystemError &error)
{
const int maxAttempts = 16;
for (int attempt = 0; attempt < maxAttempts; ++attempt) {
@@ -216,16 +216,18 @@ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &t
#if defined(Q_OS_WIN)
Q_UNUSED(mode);
+ const DWORD shareMode = (flags & QTemporaryFileEngine::Win32NonShared)
+ ? 0u : (FILE_SHARE_READ | FILE_SHARE_WRITE);
# ifndef Q_OS_WINRT
file = CreateFile((const wchar_t *)path.constData(),
GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW,
+ shareMode, NULL, CREATE_NEW,
FILE_ATTRIBUTE_NORMAL, NULL);
# else // !Q_OS_WINRT
file = CreateFile2((const wchar_t *)path.constData(),
GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, CREATE_NEW,
+ shareMode, CREATE_NEW,
NULL);
# endif // Q_OS_WINRT
@@ -247,6 +249,7 @@ static bool createFileFromTemplate(NativeFileHandle &file, QTemporaryFileName &t
return false;
}
#else // POSIX
+ Q_UNUSED(flags)
file = QT_OPEN(path.constData(),
QT_OPEN_CREAT | QT_OPEN_EXCL | QT_OPEN_RDWR | QT_OPEN_LARGEFILE,
static_cast<mode_t>(mode));
@@ -366,7 +369,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
unnamedFile = true;
d->fileEntry.clear();
} else if (st == CreateUnnamedFileStatus::NotSupported &&
- createFileFromTemplate(file, tfn, fileMode, error)) {
+ createFileFromTemplate(file, tfn, fileMode, flags, error)) {
filePathIsTemplate = false;
unnamedFile = false;
d->fileEntry = QFileSystemEntry(tfn.path, QFileSystemEntry::FromNativePath());
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index fb8887af53..0fec88d3cd 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -108,8 +108,10 @@ class QTemporaryFileEngine : public QFSFileEngine
{
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
- QTemporaryFileEngine(const QString *templateName)
- : templateName(*templateName)
+ enum Flags { Win32NonShared = 0x1 };
+
+ explicit QTemporaryFileEngine(const QString *_templateName, int _flags = 0)
+ : templateName(*_templateName), flags(_flags)
{}
void initialize(const QString &file, quint32 mode, bool nameIsTemplate = true)
@@ -144,6 +146,7 @@ public:
const QString &templateName;
quint32 fileMode;
+ int flags = 0;
bool filePathIsTemplate;
bool filePathWasTemplate;
bool unnamedFile = false;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index a8cabd52e1..ef431baca6 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -856,8 +856,9 @@ void QCoreApplicationPrivate::init()
#ifndef QT_NO_QOBJECT
// use the event dispatcher created by the app programmer (if any)
- if (!eventDispatcher)
- eventDispatcher = threadData->eventDispatcher.load();
+ Q_ASSERT(!eventDispatcher);
+ eventDispatcher = threadData->eventDispatcher.load();
+
// otherwise we create one
if (!eventDispatcher)
createEventDispatcher();
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index 8974ff7709..6034698349 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -101,8 +101,10 @@ QEventLoop::QEventLoop(QObject *parent)
Q_D(QEventLoop);
if (!QCoreApplication::instance() && QCoreApplicationPrivate::threadRequiresCoreApplication()) {
qWarning("QEventLoop: Cannot be used without QApplication");
- } else if (!d->threadData->eventDispatcher.load()) {
- QThreadPrivate::createEventDispatcher(d->threadData);
+ } else if (!d->threadData->hasEventDispatcher()) {
+ QAbstractEventDispatcher *eventDispatcher = QThreadPrivate::createEventDispatcher(d->threadData);
+ d->threadData->eventDispatcher.storeRelease(eventDispatcher);
+ eventDispatcher->startingUp();
}
}
@@ -129,7 +131,7 @@ QEventLoop::~QEventLoop()
bool QEventLoop::processEvents(ProcessEventsFlags flags)
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return false;
return d->threadData->eventDispatcher.load()->processEvents(flags);
}
@@ -234,7 +236,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return;
QElapsedTimer start;
@@ -263,7 +265,7 @@ void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
void QEventLoop::exit(int returnCode)
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return;
d->returnCode.store(returnCode);
@@ -292,7 +294,7 @@ bool QEventLoop::isRunning() const
void QEventLoop::wakeUp()
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return;
d->threadData->eventDispatcher.load()->wakeUp();
}
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 263c4019f7..9e1c3a50cb 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -238,7 +238,7 @@ QObjectPrivate::~QObjectPrivate()
if (extraData && !extraData->runningTimers.isEmpty()) {
if (Q_LIKELY(threadData->thread == QThread::currentThread())) {
// unregister pending timers
- if (threadData->eventDispatcher.load())
+ if (threadData->hasEventDispatcher())
threadData->eventDispatcher.load()->unregisterTimers(q_ptr);
// release the timer ids back to the pool
@@ -1538,7 +1538,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
++eventsMoved;
}
}
- if (eventsMoved > 0 && targetData->eventDispatcher.load()) {
+ if (eventsMoved > 0 && targetData->hasEventDispatcher()) {
targetData->canWait = false;
targetData->eventDispatcher.load()->wakeUp();
}
@@ -1621,7 +1621,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType)
qWarning("QObject::startTimer: Timers cannot have negative intervals");
return 0;
}
- if (Q_UNLIKELY(!d->threadData->eventDispatcher.load())) {
+ if (Q_UNLIKELY(!d->threadData->hasEventDispatcher())) {
qWarning("QObject::startTimer: Timers can only be used with threads started with QThread");
return 0;
}
@@ -1703,7 +1703,7 @@ void QObject::killTimer(int id)
return;
}
- if (d->threadData->eventDispatcher.load())
+ if (d->threadData->hasEventDispatcher())
d->threadData->eventDispatcher.load()->unregisterTimer(id);
d->extraData->runningTimers.remove(at);
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index 2268cb83bb..6ff8268978 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -149,7 +149,7 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
if (socket < 0)
qWarning("QSocketNotifier: Invalid socket specified");
- else if (!d->threadData->eventDispatcher.load())
+ else if (!d->threadData->hasEventDispatcher())
qWarning("QSocketNotifier: Can only be used with threads started with QThread");
else
d->threadData->eventDispatcher.load()->registerSocketNotifier(this);
@@ -234,7 +234,7 @@ void QSocketNotifier::setEnabled(bool enable)
return;
d->snenabled = enable;
- if (!d->threadData->eventDispatcher.load()) // perhaps application/thread is shutting down
+ if (!d->threadData->hasEventDispatcher()) // perhaps application/thread is shutting down
return;
if (Q_UNLIKELY(thread() != QThread::currentThread())) {
qWarning("QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread");
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index baeefd87ff..46294a5fc8 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -195,7 +195,7 @@ public:
#endif // Q_OS_WIN
QThreadData *data;
- static void createEventDispatcher(QThreadData *data);
+ static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
void ref()
{
@@ -222,7 +222,7 @@ public:
static void setCurrentThread(QThread*) {}
static QThread *threadForId(int) { return QThread::currentThread(); }
- static void createEventDispatcher(QThreadData *data);
+ static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
void ref() {}
void deref() {}
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 1bb8e613e0..2c815b870a 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -285,27 +285,26 @@ typedef void*(*QtThreadCallback)(void*);
#endif // QT_NO_THREAD
-void QThreadPrivate::createEventDispatcher(QThreadData *data)
+QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+ Q_UNUSED(data);
#if defined(Q_OS_DARWIN)
bool ok = false;
int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok);
if (ok && value > 0)
- data->eventDispatcher.storeRelease(new QEventDispatcherCoreFoundation);
+ return new QEventDispatcherCoreFoundation;
else
- data->eventDispatcher.storeRelease(new QEventDispatcherUNIX);
+ return new QEventDispatcherUNIX;
#elif !defined(QT_NO_GLIB)
if (qEnvironmentVariableIsEmpty("QT_NO_GLIB")
&& qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")
&& QEventDispatcherGlib::versionSupported())
- data->eventDispatcher.storeRelease(new QEventDispatcherGlib);
+ return new QEventDispatcherGlib;
else
- data->eventDispatcher.storeRelease(new QEventDispatcherUNIX);
+ return new QEventDispatcherUNIX;
#else
- data->eventDispatcher.storeRelease(new QEventDispatcherUNIX);
+ return new QEventDispatcherUNIX;
#endif
-
- data->eventDispatcher.load()->startingUp();
}
#ifndef QT_NO_THREAD
@@ -352,10 +351,13 @@ void *QThreadPrivate::start(void *arg)
data->quitNow = thr->d_func()->exited;
}
- if (data->eventDispatcher.load()) // custom event dispatcher set?
- data->eventDispatcher.load()->startingUp();
- else
- createEventDispatcher(data);
+ QAbstractEventDispatcher *eventDispatcher = data->eventDispatcher.load();
+ if (!eventDispatcher) {
+ eventDispatcher = createEventDispatcher(data);
+ data->eventDispatcher.storeRelease(eventDispatcher);
+ }
+
+ eventDispatcher->startingUp();
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
{
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 24d3ca2d7d..4459ae87af 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -331,15 +331,14 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
#endif // QT_NO_THREAD
-void QThreadPrivate::createEventDispatcher(QThreadData *data)
+QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data)
{
+ Q_UNUSED(data);
#ifndef Q_OS_WINRT
- QEventDispatcherWin32 *theEventDispatcher = new QEventDispatcherWin32;
+ return new QEventDispatcherWin32;
#else
- QEventDispatcherWinRT *theEventDispatcher = new QEventDispatcherWinRT;
+ return new QEventDispatcherWinRT;
#endif
- data->eventDispatcher.storeRelease(theEventDispatcher);
- theEventDispatcher->startingUp();
}
#ifndef QT_NO_THREAD
@@ -360,10 +359,13 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
data->quitNow = thr->d_func()->exited;
}
- if (data->eventDispatcher.load()) // custom event dispatcher set?
- data->eventDispatcher.load()->startingUp();
- else
- createEventDispatcher(data);
+ QAbstractEventDispatcher *eventDispatcher = data->eventDispatcher.load();
+ if (!eventDispatcher) {
+ eventDispatcher = createEventDispatcher(data);
+ data->eventDispatcher.storeRelease(eventDispatcher);
+ }
+
+ eventDispatcher->startingUp();
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
// sets the name of the current thread.
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp
index 3563f1b5d3..b825b56d45 100644
--- a/src/gui/opengl/qopengltexture.cpp
+++ b/src/gui/opengl/qopengltexture.cpp
@@ -778,6 +778,8 @@ static QOpenGLTexture::PixelFormat pixelFormatCompatibleWithInternalFormat(QOpen
return QOpenGLTexture::Alpha;
case QOpenGLTexture::RGBFormat:
+ return QOpenGLTexture::RGB;
+
case QOpenGLTexture::RGBAFormat:
return QOpenGLTexture::RGBA;
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsnativeimage.cpp b/src/platformsupport/fontdatabases/windows/qwindowsnativeimage.cpp
index 67a6619b91..b1133dca22 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsnativeimage.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsnativeimage.cpp
@@ -101,8 +101,10 @@ static inline HBITMAP createDIB(HDC hdc, int width, int height,
uchar *bits = nullptr;
HBITMAP bitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bmi),
DIB_RGB_COLORS, reinterpret_cast<void **>(&bits), 0, 0);
- if (Q_UNLIKELY(!bitmap || !bits))
- qFatal("%s: CreateDIBSection failed.", __FUNCTION__);
+ if (Q_UNLIKELY(!bitmap || !bits)) {
+ qFatal("%s: CreateDIBSection failed (%dx%d, format: %d)", __FUNCTION__,
+ width, height, int(format));
+ }
*bitsIn = bits;
return bitmap;
diff --git a/src/plugins/platformthemes/flatpak/qflatpaktheme.h b/src/plugins/platformthemes/flatpak/qflatpaktheme.h
index fcaac5b673..87f79a2395 100644
--- a/src/plugins/platformthemes/flatpak/qflatpaktheme.h
+++ b/src/plugins/platformthemes/flatpak/qflatpaktheme.h
@@ -72,7 +72,7 @@ public:
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override;
QIcon fileIcon(const QFileInfo &fileInfo,
- QPlatformTheme::IconOptions iconOptions = 0) const;
+ QPlatformTheme::IconOptions iconOptions = 0) const override;
QIconEngine *createIconEngine(const QString &iconName) const override;
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 967b0b8dde..8c8217bb75 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -1332,9 +1332,8 @@ bool QAction::isShortcutVisibleInContextMenu() const
{
Q_D(const QAction);
if (d->shortcutVisibleInContextMenu == -1) {
- if (QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))
- return false;
- return qApp->styleHints()->showShortcutsInContextMenus();
+ return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus)
+ && QGuiApplication::styleHints()->showShortcutsInContextMenus();
}
return d->shortcutVisibleInContextMenu;
}
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index e3b348f0ef..bdeef7cdf7 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -80,9 +80,8 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
-#define ACCEL_KEY(k) ((qApp->testAttribute(Qt::AA_DontShowIconsInMenus) \
- ? false \
- : qApp->styleHints()->showShortcutsInContextMenus()) \
+#define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus) \
+ && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \
&& !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
#else
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index 93158dcdba..d3203e180b 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -93,9 +93,8 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include <qkeysequence.h>
-#define ACCEL_KEY(k) ((qApp->testAttribute(Qt::AA_DontShowIconsInMenus) \
- ? false \
- : qApp->styleHints()->showShortcutsInContextMenus()) \
+#define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
+ && QGuiApplication::styleHints()->showShortcutsInContextMenus()) \
&& !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())