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

When creating explorer favorite use more specific windows functions #5690

Merged
merged 8 commits into from
Apr 27, 2017
Merged

When creating explorer favorite use more specific windows functions #5690

merged 8 commits into from
Apr 27, 2017

Conversation

remixtj
Copy link
Contributor

@remixtj remixtj commented Apr 10, 2017

Fixes #2719

@CLAassistant
Copy link

CLAassistant commented Apr 10, 2017

CLA assistant check
All committers have signed the CLA.

@guruz guruz requested a review from jturcotte April 10, 2017 13:04
@guruz guruz added this to the 2.4.0 milestone Apr 10, 2017
QLibrary kernel32Lib("shell32.dll");
if(kernel32Lib.load())
{
SHGetKnownFolderPathPtr = (SHGetKnownFolderPathFun) kernel32Lib.resolve("SHGetKnownFolderPath");
Copy link
Member

Choose a reason for hiding this comment

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

This function seems to be supported since Windows Vista, but we require Windows 7 at least. Would it be possible to use normal dynamic linking to access it rather than doing a manual symbol lookup?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Last time i tried this i had errors with direct lookup, but maybe because was testing also XP clients. If you say that Windows 7 is the minimum supported, i can try rewriting it

Copy link
Contributor

Choose a reason for hiding this comment

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

@remixtj I'd be great if you could try rewriting to use normal dynamic linking. Feel free to ping me if you need someone to test on Win7.

Copy link
Member

@jturcotte jturcotte left a comment

Choose a reason for hiding this comment

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

Thank you for the cleanup, looks already much simpler. Just one more thing.


/* Use new WINAPI functions */
wchar_t *path = NULL;
if(SHGetKnownFolderPath(FOLDERID_Links, 0, NULL, &path) == S_OK) {
Copy link
Member

Choose a reason for hiding this comment

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

From the documentation about the path argument:

The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree.

Could you verify or fix it?

linkName = QDir(links).filePath(folderDir.dirName() + QLatin1String(".lnk"));
}
qDebug() << Q_FUNC_INFO << " creating link from " << linkName << " to " << folder;
CoTaskMemFree(path);
Copy link
Member

Choose a reason for hiding this comment

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

This will crash if path is not null and yet not pointing to a valid allocation, which can happen if SHGetKnownFolderPath doesn't touch it. You could either move CoTaskMemFree into the if(){}, or initialize path to NULL.

Copy link
Member

@jturcotte jturcotte left a comment

Choose a reason for hiding this comment

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

Great, thank you :)

@jturcotte
Copy link
Member

jturcotte commented Apr 26, 2017

Argh...

/var/lib/jenkins/workspace/cloud-client_client_PR-5690-ICN3YAYSR6SITVLPHS5TYBHNKKE7PAVK3ABYGFA5SQ67JL2DZEJA/src/libsync/utility_win.cpp:36:59: error: 'SHGetKnownFolderPath' was not declared in this scope

The CI (and our build servers) might not be able to cross-build this... Are you testing your patch on Windows with MinGW, or are you using MSVC?

@guruz guruz added the ReadyToTest QA, please validate the fix/enhancement label Apr 26, 2017
@remixtj
Copy link
Contributor Author

remixtj commented Apr 27, 2017

Hi,

i'm compiling on mingw32-w64 on opensuse.

Maybe my environment is not much up to date, but works.

@jturcotte
Copy link
Member

That's perfect then, that's our official toolchain. Thanks for the patch and for fixing the build, I'll merge it 👍

@jturcotte jturcotte merged commit 3db8d3d into owncloud:master Apr 27, 2017
@remixtj remixtj deleted the utility_SHGetKnownFolderPath branch April 27, 2017 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ReadyToTest QA, please validate the fix/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants