diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index 28860ffab..fac7e7599 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -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) { + CCOMHelper comHelper; + IShellLinkW* psl; // 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) { + CCOMHelper comHelper; + IShellLinkW* psl; WIN32_FIND_DATAW wfd; @@ -239,3 +243,21 @@ bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathOb } #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 +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h index 6de89bcba..c016ed8ba 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.h +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h @@ -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 resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj); +class CCOMHelper +{ + bool m_mustUninit; + +public: + CCOMHelper(); + ~CCOMHelper(); +}; + #endif