mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 08:45:25 +08:00
qt 6.5.1 original
This commit is contained in:
11
tests/auto/corelib/io/qprocess-noapplication/CMakeLists.txt
Normal file
11
tests/auto/corelib/io/qprocess-noapplication/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## qprocess-noapplication Test:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_test(qprocess-noapplication
|
||||
SOURCES
|
||||
tst_qprocessnoapplication.cpp
|
||||
)
|
@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2016 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QThread>
|
||||
#include <QTest>
|
||||
|
||||
class tst_QProcessNoApplication : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void initializationDeadlock();
|
||||
};
|
||||
|
||||
void tst_QProcessNoApplication::initializationDeadlock()
|
||||
{
|
||||
// see QTBUG-27260
|
||||
// QProcess on Unix uses (or used to, at the time of the writing of this test)
|
||||
// a global class called QProcessManager.
|
||||
// This class is instantiated (or was) only in the main thread, which meant that
|
||||
// blocking the main thread while waiting for QProcess could mean a deadlock.
|
||||
|
||||
struct MyThread : public QThread
|
||||
{
|
||||
void run() override
|
||||
{
|
||||
// what we execute does not matter, as long as we try to
|
||||
// and that the process exits
|
||||
QProcess::execute("true");
|
||||
}
|
||||
};
|
||||
|
||||
char *argv[] = { const_cast<char*>(QTest::currentAppName()), 0 };
|
||||
int argc = 1;
|
||||
QCoreApplication app(argc, argv);
|
||||
MyThread thread;
|
||||
thread.start();
|
||||
QVERIFY(thread.wait(10000));
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QProcessNoApplication)
|
||||
|
||||
#include "tst_qprocessnoapplication.moc"
|
Reference in New Issue
Block a user