Windows QPA: Fix build with mingw64/Win32 threading
For this build, cxx11_future is not available and thus
QThread::create() as introduced by
ed114b728d
does not work.
Revert back to implementing a QThread.
Pick-to: 5.15
Fixes: QTBUG-86575
Task-number: QTBUG-85676
Change-Id: I86a91f6bcdfc88804b35bf617362d92f37e51dea
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
parent
e96a311334
commit
983132212c
@ -56,6 +56,26 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
enum { debug = 0 };
|
enum { debug = 0 };
|
||||||
|
|
||||||
|
class QWindowsShellExecuteThread : public QThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit QWindowsShellExecuteThread(const wchar_t *path) : m_path(path) { }
|
||||||
|
|
||||||
|
void run() override
|
||||||
|
{
|
||||||
|
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE))) {
|
||||||
|
m_result = ShellExecute(nullptr, nullptr, m_path, nullptr, nullptr, SW_SHOWNORMAL);
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HINSTANCE result() const { return m_result; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
HINSTANCE m_result = nullptr;
|
||||||
|
const wchar_t *m_path;
|
||||||
|
};
|
||||||
|
|
||||||
static quintptr runShellExecute(const wchar_t *path)
|
static quintptr runShellExecute(const wchar_t *path)
|
||||||
{
|
{
|
||||||
HINSTANCE result = nullptr;
|
HINSTANCE result = nullptr;
|
||||||
@ -75,13 +95,11 @@ static inline bool shellExecute(const QUrl &url)
|
|||||||
|
|
||||||
// Run ShellExecute() in a thread since it may spin the event loop.
|
// Run ShellExecute() in a thread since it may spin the event loop.
|
||||||
// Prevent it from interfering with processing of posted events (QTBUG-85676).
|
// Prevent it from interfering with processing of posted events (QTBUG-85676).
|
||||||
quintptr result = 0;
|
QWindowsShellExecuteThread thread(reinterpret_cast<const wchar_t *>(nativeFilePath.utf16()));
|
||||||
quintptr *resultPtr = &result;
|
thread.start();
|
||||||
const auto path = reinterpret_cast<const wchar_t *>(nativeFilePath.utf16());
|
thread.wait();
|
||||||
QScopedPointer<QThread> thread(QThread::create([path, resultPtr]
|
|
||||||
() { *resultPtr = runShellExecute(path); }));
|
const auto result = reinterpret_cast<quintptr>(thread.result());
|
||||||
thread->start();
|
|
||||||
thread->wait();
|
|
||||||
|
|
||||||
// ShellExecute returns a value greater than 32 if successful
|
// ShellExecute returns a value greater than 32 if successful
|
||||||
if (result <= 32) {
|
if (result <= 32) {
|
||||||
|
Loading…
Reference in New Issue
Block a user