mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-26 22:44:36 +00:00
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.
This commit is contained in:
parent
5e4a94e6b6
commit
cacfe4f3ca
@ -31,6 +31,7 @@
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Objbase.h>
|
||||
#include <Shlobj.h>
|
||||
#include <Shellapi.h>
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user