-
Notifications
You must be signed in to change notification settings - Fork 188
Fix WindowsRegistryKey for Qt 6.8.1 #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Here the commit in qtbase |
|
Thanks! But I think we should use new API in user code instead of restoring the old Qt API. |
|
Yes this was my first thought aswell, but I can not test Qt versions below 5.14.0 qwindowkit/src/core/qwindowkit_windows.h Line 114 in ba8e8a3
For the most recent commit I confirmed compilation with these Qt versions (Windows, MinGW):
|
wangwenx190
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Only minor tweaks needed.
src/core/qwindowkit_windows.cpp
Outdated
| return qMakePair(value, ok); | ||
| } | ||
|
|
||
| template<> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
template implementations should be placed in header files
src/core/qwindowkit_windows.cpp
Outdated
|
|
||
| template<> | ||
| std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { | ||
| auto dv = dwordValue(subKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be const
src/core/qwindowkit_windows.cpp
Outdated
| template<> | ||
| std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { | ||
| auto dv = dwordValue(subKey); | ||
| if(!dv.second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after if
src/core/qwindowkit_windows.cpp
Outdated
| return dv.first; | ||
| } | ||
| #elif QT_VERSION < QT_VERSION_CHECK(6, 8, 1) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line not needed
src/core/qwindowkit_windows.cpp
Outdated
| { | ||
| } | ||
|
|
||
| template<> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, place this in header file
src/core/qwindowkit_windows.cpp
Outdated
|
|
||
| template<> | ||
| std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { | ||
| auto dv = dwordValue(subKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, can be const
src/core/qwindowkit_windows.cpp
Outdated
| template<> | ||
| std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { | ||
| auto dv = dwordValue(subKey); | ||
| if(!dv.second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, space after if
src/core/qwindowkit_windows.cpp
Outdated
| #endif | ||
|
|
||
| } No newline at end of file | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something that should not be changed
src/core/qwindowkit_windows.h
Outdated
| QPair<DWORD, bool> dwordValue(QStringView subKey) const; | ||
|
|
||
| template<typename T> | ||
| std::optional<T> value(QStringView subKey) const { return {}; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you don't want this function to be called directly, so we can use static_cast(false, "xxx") to ensure this.
src/core/qwindowkit_windows.h
Outdated
| explicit WindowsRegistryKey(HKEY parentHandle, QStringView subKey, REGSAM permissions = KEY_READ, REGSAM access = 0); | ||
|
|
||
| template<typename T> | ||
| std::optional<T> value(QStringView subKey) const { return {}; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, use static_assert here
- Moved template specializations to header, had to add inline for this to work - Added const qualifiers - Added space after if - Removed unneeded new lines - Removed new lines inserted by the IDE - Removed general template implementation, static asserts did not compile (due to MOC i think). Using the function with any other type than DWORD will still cause a compilation error
wangwenx190
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you may misunderstand my words. Please apply some more minor tweaks. Really thanks!
src/core/qwindowkit_windows.h
Outdated
| QPair<DWORD, bool> dwordValue(QStringView subKey) const; | ||
|
|
||
| template<typename T> | ||
| const std::optional<T> value(QStringView subKey) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't mean the return value should be const, sorry for my misleading word. You can remove the const keyword from the return value
src/core/qwindowkit_windows.h
Outdated
| } | ||
|
|
||
| template<> | ||
| inline const std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this const keyword
src/core/qwindowkit_windows.h
Outdated
|
|
||
| template<> | ||
| inline const std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { | ||
| auto dv = dwordValue(subKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was meant to make this "dv" const, but never mind, const or not doesn't really matter.
src/core/qwindowkit_windows.h
Outdated
| explicit WindowsRegistryKey(HKEY parentHandle, QStringView subKey, REGSAM permissions = KEY_READ, REGSAM access = 0); | ||
|
|
||
| template<typename T> | ||
| inline const std::optional<T> value(QStringView subKey) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, please remove the const keyword
src/core/qwindowkit_windows.h
Outdated
| }; | ||
|
|
||
| template<> | ||
| inline const std::optional<DWORD> WindowsRegistryKey::value(QStringView subKey) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove const
src/core/qwindowkit_windows.h
Outdated
| #endif | ||
|
|
||
| #endif // QWINDOWKIT_WINDOWS_H | ||
| #endif // QWINDOWKIT_WINDOWS_H No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the line ending is changed? Could you please restore it?
|
Thanks! |
This commit updates QWindowKit in order to fix the following build issue on Qt 6.8: stdware/qwindowkit#154 GitLab: #1944 Change-Id: Iab82514b51577148ff5dc1ba382f8bb517c94f8a
Qt changed some of their private API with version 6.8.1, which causes compilation errors.
Specifically they removed QWinRegistryKey::dwordValue(...) in favor of QWinRegistryKey::value(...)