diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-28 14:11:21 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-10-28 14:14:28 +0000 |
commit | 8cd812455932f896b45aae84c4dc571f60f60b25 (patch) | |
tree | 6c2365856023fbd06c803dbd2607c9226d33bb5c /src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp | |
parent | e5451f086bb9551527a4f0da06525eef860a53a9 (diff) |
Windows QPA: Do not use QSettings to access the registry
When commenting out the warning in createOrOpenKey()
(src\corelib\io\qsettings_win.cpp:157), applications produce warnings:
QSettings: Failed to create subkey "Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes": Access is denied.
indicating that an attempt to open the registry in read/write mode fails.
Add a utility function to read out registry strings in read-only mode to
the font database and use that instead.
Change-Id: I4187344cac7ec2ba27f15b51e237575efc171853
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp')
-rw-r--r-- | src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 7cf24421f8..aed9c94003 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -47,13 +47,13 @@ #include <QtCore/qmap.h> #include <QtCore/qpair.h> #include <QtCore/qpointer.h> -#include <QtCore/qsettings.h> #include <QtGui/qaccessible.h> #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformintegration.h> #include <QtGui/qwindow.h> #include <QtGui/qguiapplication.h> +#include <QtFontDatabaseSupport/private/qwindowsfontdatabase_p.h> // registry helper #include "qwindowsaccessibility.h" #ifdef Q_CC_MINGW @@ -114,6 +114,14 @@ static inline QString messageBoxAlertSound(const QObject *messageBox) return QString(); } +static QString soundFileName(const QString &soundName) +{ + const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\") + + soundName + QStringLiteral("\\.Current"); + return QWindowsFontDatabase::readRegistryString(HKEY_CURRENT_USER, + reinterpret_cast<const wchar_t *>(key.utf16()), L""); +} + void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { QString soundName; @@ -134,17 +142,9 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) break; } - if (!soundName.isEmpty()) { -#ifndef QT_NO_SETTINGS - QSettings settings(QLatin1String("HKEY_CURRENT_USER\\AppEvents\\Schemes\\Apps\\.Default\\") + soundName, - QSettings::NativeFormat); - QString file = settings.value(QLatin1String(".Current/.")).toString(); -#else - QString file; -#endif - if (!file.isEmpty()) { - PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), 0, SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT); - } + if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) { + PlaySound(reinterpret_cast<const wchar_t *>(soundName.utf16()), 0, + SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT); } // An event has to be associated with a window, |