Fixed: Unable to create shortcuts, see #279

--HG--
branch : develop
This commit is contained in:
kervala 2016-09-21 15:20:56 +02:00
parent 91221fd4ce
commit 1e474e9ebd
2 changed files with 31 additions and 0 deletions

View file

@ -99,6 +99,8 @@ wchar_t* qToWide(const QString &str)
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir) bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir)
{ {
CCOMHelper comHelper;
IShellLinkW* psl; IShellLinkW* psl;
// Get a pointer to the IShellLink interface. It is assumed that CoInitialize // Get a pointer to the IShellLink interface. It is assumed that CoInitialize
@ -135,6 +137,8 @@ bool createLink(const QString &link, const QString &name, const QString &executa
bool resolveLink(const QWidget &window, const QString &linkFile, QString &path) bool resolveLink(const QWidget &window, const QString &linkFile, QString &path)
{ {
CCOMHelper comHelper;
IShellLinkW* psl; IShellLinkW* psl;
WIN32_FIND_DATAW wfd; WIN32_FIND_DATAW wfd;
@ -239,3 +243,21 @@ bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathOb
} }
#endif #endif
CCOMHelper::CCOMHelper()
{
#ifdef Q_OS_WIN
// to fix the bug with QFileDialog::getExistingDirectory hanging under Windows
m_mustUninit = SUCCEEDED(CoInitialize(NULL));
#else
m_mustUninit = false;
#endif
}
CCOMHelper::~CCOMHelper()
{
#ifdef Q_OS_WIN
// only call CoUninitialize if CoInitialize succeeded
if (m_mustUninit) CoUninitialize();
#endif
}

View file

@ -51,4 +51,13 @@ wchar_t* qToWide(const QString &str);
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir); bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj); bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj);
class CCOMHelper
{
bool m_mustUninit;
public:
CCOMHelper();
~CCOMHelper();
};
#endif #endif