Skip to content
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

Misc fixes for Windows 7 #2589

Merged
merged 1 commit into from
Oct 28, 2020
Merged

Misc fixes for Windows 7 #2589

merged 1 commit into from
Oct 28, 2020

Conversation

sryze
Copy link
Contributor

@sryze sryze commented Oct 24, 2020

This fixes the following issues with the desktop app on Windows 7:

  1. Registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace does not exist

  2. Task bar position is not calculated properly because HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3 does not exist, but StuckRects2 can be used instead

@@ -374,26 +380,23 @@ QPoint Systray::computeWindowPosition(int width, int height) const
const auto windowRect = [=]() {
const auto rect = QRect(topLeft, bottomRight);
auto offset = QPoint();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: please don't remove those empty lines, this has nothing to do with the rest of your patch and reduced readability IMHO.

@@ -241,6 +241,12 @@ Systray::TaskBarPosition Systray::taskbarOrientation() const
auto taskbarPosition = Utility::registryGetKeyValue(HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3",
"Settings");
if (taskbarPosition.isNull()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to do a check on the key before hand using the registryKeyExists function you introduced to determine if we're going with StuckRects3 or StuckRects2. And then making a single registryGetKeyValue call with that key.

A bit like this:

QString taskbarPositionSubkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3";
if (!Utility::registryKeyExists(HKEY_CURRENT_USER, taskbarPositionSubkey)) {
    taskbarPositionSubkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3";
}
auto taskbarPosition = Utility::registryGetKeyValue(HKEY_CURRENT_USER, taskbarPositionSubkey, "Settings");

I think it'd show the intent better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated it

@er-vin
Copy link
Member

er-vin commented Oct 26, 2020

Ah also: please make sure all your changes are in a single commit and also please ensure you please the DCO bot.

Thanks in advance.

@DominiqueFuchs
Copy link
Contributor

  1. Registry key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace does not exist

I'm wondering what the issue was? Because the check of the return value of RegOpenKeyEx is already done in the Utility::registryGetKeyValue (just like you do in the new registryKeyExists now), thus it's duplicated that way. If no key is found, it returns an empty QVariant:

https://github.com/nextcloud/desktop/blob/ca1575b59f62d9e10ac2aff82e445365241517d9/src/common/utility_win.cpp#L137-L138

Don't mind the change though, extracting this into a separate check function that return a bool (which is easier to understand/harder to misuse) may be a good idea.

@DominiqueFuchs DominiqueFuchs removed their request for review October 26, 2020 14:24
@sryze
Copy link
Contributor Author

sryze commented Oct 26, 2020

@DominiqueFuchs the issue was that registryWalkSubKeys has an assert that fails if the key is not found:

    REGSAM sam = KEY_READ | KEY_WOW64_64KEY;
    LONG result = RegOpenKeyEx(hRootKey, reinterpret_cast<LPCWSTR>(subKey.utf16()), 0, sam, &hKey);
    ASSERT(result == ERROR_SUCCESS);

Instead of adding registryKeyExists, maybe it would be better to make registryWalkSubKeys just return false in such case, I'm not entirely sure about this

@er-vin
Copy link
Member

er-vin commented Oct 27, 2020

@DominiqueFuchs the issue was that registryWalkSubKeys has an assert that fails if the key is not found:

    REGSAM sam = KEY_READ | KEY_WOW64_64KEY;
    LONG result = RegOpenKeyEx(hRootKey, reinterpret_cast<LPCWSTR>(subKey.utf16()), 0, sam, &hKey);
    ASSERT(result == ERROR_SUCCESS);

Instead of adding registryKeyExists,

registryKeyExists is needed anyway for the other part of the patch. So definitely a keeper.

maybe it would be better to make registryWalkSubKeys just return false in such case, I'm not entirely sure about this

I like your patch as is, but I like this idea quite a bit as well. Your call. Just let me know what you want to do.

@sryze
Copy link
Contributor Author

sryze commented Oct 27, 2020

I like your patch as is, but I like this idea quite a bit as well. Your call. Just let me know what you want to do.

OK, let's keep it as is

@er-vin
Copy link
Member

er-vin commented Oct 28, 2020

/rebase

Signed-off-by: Sergey Zolotarev <[email protected]>
@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-2589-18c1bc0bd66be5f70965a45ba106a855b1013e5a-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@er-vin er-vin merged commit 56d067d into nextcloud:master Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants