diff options
author | Liang Qi <liang.qi@qt.io> | 2017-08-15 12:21:21 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-08-15 12:44:40 +0200 |
commit | 580f3366a74e95369a151ed6108c9f94a5cef303 (patch) | |
tree | e8ea7cbb553d9686b0f974f813634e937396ada3 /src/activeqt/control/qaxserver.cpp | |
parent | 706c07ffb3f9ba473c71f4c8b66be94b810500c8 (diff) | |
parent | 9a6d57385c49fa702319139ae1f2e471520963ee (diff) |
Merge remote-tracking branch 'origin/5.9' into devv5.10.0-alpha1
Conflicts:
.qmake.conf
Change-Id: I4d94e662fb8608a90cb548b5c79f82482d5d819b
Diffstat (limited to 'src/activeqt/control/qaxserver.cpp')
-rw-r--r-- | src/activeqt/control/qaxserver.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index b3c11db..45f6940 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -231,19 +231,35 @@ HRESULT UpdateRegistry(BOOL bRegister) qAxTypeLibrary->GetLibAttr(&libAttr); if (!libAttr) return SELFREG_E_TYPELIB; - - if (bRegister) - RegisterTypeLib(qAxTypeLibrary, reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), 0); - else - UnRegisterTypeLib(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, libAttr->syskind); - + bool userFallback = false; + if (bRegister) { + if (RegisterTypeLib(qAxTypeLibrary, + reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), 0) == TYPE_E_REGISTRYACCESS) { +#ifndef Q_CC_MINGW + // MinGW does not have RegisterTypeLibForUser() implemented so we cannot fallback in this case + RegisterTypeLibForUser(qAxTypeLibrary, reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), 0); + userFallback = true; +#endif + } + } else { + if (UnRegisterTypeLib(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, + libAttr->syskind) == TYPE_E_REGISTRYACCESS) { +#ifndef Q_CC_MINGW + // MinGW does not have RegisterTypeLibForUser() implemented so we cannot fallback in this case + UnRegisterTypeLibForUser(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, libAttr->syskind); + userFallback = true; +#endif + } + } + if (userFallback) + qWarning("QAxServer: Falling back to registering as user for %s due to insufficient permission.", qPrintable(module)); qAxTypeLibrary->ReleaseTLibAttr(libAttr); // check whether the user has permission to write to HKLM\Software\Classes // if not, use HKCU\Software\Classes QString keyPath(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes")); QScopedPointer<QSettings> settings(new QSettings(keyPath, QSettings::NativeFormat)); - if (!settings->isWritable()) { + if (userFallback || !settings->isWritable()) { keyPath = QLatin1String("HKEY_CURRENT_USER\\Software\\Classes"); settings.reset(new QSettings(keyPath, QSettings::NativeFormat)); } @@ -420,7 +436,7 @@ HRESULT UpdateRegistry(BOOL bRegister) QString extension; while (mime.contains(QLatin1Char(':'))) { extension = mime.mid(mime.lastIndexOf(QLatin1Char(':')) + 1); - mime.chop(extension.length() - 1); + mime.chop(extension.length() + 1); // Prepend '.' before extension, if required. extension = extension.trimmed(); if (extension[0] != dot) |