diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index b40dcbbf6..6bd4f1110 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -31,6 +31,7 @@ #ifdef Q_OS_WIN #include #include +#include #endif #include @@ -146,7 +147,24 @@ void Utils::Gui::openPath(const Path &path) const QUrl url = path.data().startsWith(u"//") ? QUrl(u"file:" + path.data()) : QUrl::fromLocalFile(path.data()); + +#ifdef Q_OS_WIN + auto *thread = QThread::create([path]() + { + if (SUCCEEDED(::CoInitializeEx(NULL, (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)))) + { + const std::wstring pathWStr = path.toString().toStdWString(); + + ::ShellExecuteW(nullptr, nullptr, pathWStr.c_str(), nullptr, nullptr, SW_SHOWNORMAL); + + ::CoUninitialize(); + } + }); + QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater); + thread->start(); +#else QDesktopServices::openUrl(url); +#endif } // Open the parent directory of the given path with a file manager and select