Browse Source

Fix "Open destination folder" delay on Windows

Replaced QDesktopServices by native Windows function
to open destination folder due to QDesktopServices issues on Windows.
The issues are described in #17482 and even more detailed in #17025.

Closes #17482.
PR #17723.
adaptive-webui-19844
Andrew 2 years ago committed by GitHub
parent
commit
cacfe4f3ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      src/gui/utils.cpp

18
src/gui/utils.cpp

@ -31,6 +31,7 @@
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <Objbase.h> #include <Objbase.h>
#include <Shlobj.h> #include <Shlobj.h>
#include <Shellapi.h>
#endif #endif
#include <QApplication> #include <QApplication>
@ -146,7 +147,24 @@ void Utils::Gui::openPath(const Path &path)
const QUrl url = path.data().startsWith(u"//") const QUrl url = path.data().startsWith(u"//")
? QUrl(u"file:" + path.data()) ? QUrl(u"file:" + path.data())
: QUrl::fromLocalFile(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); QDesktopServices::openUrl(url);
#endif
} }
// Open the parent directory of the given path with a file manager and select // Open the parent directory of the given path with a file manager and select

Loading…
Cancel
Save