forked from qt-creator/qt-creator
Utils: Merge QtcProcess and SynchronousProcess
Keep SynchronousProcess as type alias for a transition period. Change-Id: I2540b6cecc17eb46f40ed57d27589011693728f1 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -206,7 +206,6 @@ public:
|
||||
bool m_startFailure = false;
|
||||
bool m_timeOutMessageBoxEnabled = false;
|
||||
bool m_waitingForUser = false;
|
||||
bool m_isSynchronousProcess = false;
|
||||
bool m_processUserEvents = false;
|
||||
};
|
||||
|
||||
@@ -252,8 +251,6 @@ QtcProcess::QtcProcess(QObject *parent)
|
||||
|
||||
QtcProcess::~QtcProcess()
|
||||
{
|
||||
disconnect(&d->m_timer, nullptr, this, nullptr);
|
||||
disconnect(this, nullptr, this, nullptr);
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -567,7 +564,7 @@ void QtcProcess::setResult(Result result)
|
||||
|
||||
int QtcProcess::exitCode() const
|
||||
{
|
||||
return d->m_isSynchronousProcess ? d->m_exitCode : d->m_process->exitCode(); // FIXME: Unify.
|
||||
return d->m_exitCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -946,24 +943,13 @@ void ChannelBuffer::handleRest()
|
||||
}
|
||||
}
|
||||
|
||||
// ----------- SynchronousProcess
|
||||
SynchronousProcess::SynchronousProcess()
|
||||
{
|
||||
d->m_isSynchronousProcess = true; // Only for QTC_ASSERTs above.
|
||||
}
|
||||
|
||||
SynchronousProcess::~SynchronousProcess()
|
||||
{
|
||||
}
|
||||
|
||||
void SynchronousProcess::setProcessUserEventWhileRunning()
|
||||
void QtcProcess::setProcessUserEventWhileRunning()
|
||||
{
|
||||
d->m_processUserEvents = true;
|
||||
}
|
||||
|
||||
void QtcProcess::setTimeoutS(int timeoutS)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
if (timeoutS > 0)
|
||||
d->m_maxHangTimerCount = qMax(2, timeoutS);
|
||||
else
|
||||
@@ -978,7 +964,6 @@ void QtcProcess::setCodec(QTextCodec *c)
|
||||
|
||||
void QtcProcess::setTimeOutMessageBoxEnabled(bool v)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_timeOutMessageBoxEnabled = v;
|
||||
}
|
||||
|
||||
@@ -989,7 +974,6 @@ void QtcProcess::setExitCodeInterpreter(const ExitCodeInterpreter &interpreter)
|
||||
|
||||
void QtcProcess::setWriteData(const QByteArray &writeData)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_writeData = writeData;
|
||||
}
|
||||
|
||||
@@ -1002,7 +986,6 @@ static bool isGuiThread()
|
||||
|
||||
void SynchronousProcess::runBlocking()
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
// FIXME: Implement properly
|
||||
if (d->m_commandLine.executable().needsDevice()) {
|
||||
|
||||
@@ -1073,7 +1056,6 @@ void SynchronousProcess::runBlocking()
|
||||
|
||||
void QtcProcess::setStdOutCallback(const std::function<void (const QString &)> &callback)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_stdOut.outputCallback = callback;
|
||||
d->m_stdOut.emitSingleLines = false;
|
||||
d->m_stdOut.emitSingleLines = false;
|
||||
@@ -1089,7 +1071,6 @@ void QtcProcess::setStdOutLineCallback(const std::function<void (const QString &
|
||||
|
||||
void QtcProcess::setStdErrCallback(const std::function<void (const QString &)> &callback)
|
||||
{
|
||||
QTC_CHECK(d->m_isSynchronousProcess);
|
||||
d->m_stdErr.outputCallback = callback;
|
||||
d->m_stdErr.emitSingleLines = false;
|
||||
d->m_stdErr.keepRawData = false;
|
||||
|
@@ -98,6 +98,12 @@ public:
|
||||
void terminate();
|
||||
void interrupt();
|
||||
|
||||
// Starts the command and waits for finish. User input processing depends
|
||||
// on whether setProcessUserEventWhileRunning was called.
|
||||
void runBlocking();
|
||||
// This starts a nested event loop when running the command.
|
||||
void setProcessUserEventWhileRunning(); // Avoid.
|
||||
|
||||
/* Timeout for hanging processes (triggers after no more output
|
||||
* occurs on stderr/stdout). */
|
||||
void setTimeoutS(int timeoutS);
|
||||
@@ -186,7 +192,6 @@ signals:
|
||||
void readyReadStandardError();
|
||||
|
||||
private:
|
||||
friend class SynchronousProcess;
|
||||
friend QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &r);
|
||||
|
||||
Internal::QtcProcessPrivate *d = nullptr;
|
||||
@@ -204,22 +209,6 @@ using ExitCodeInterpreter = std::function<QtcProcess::Result(int /*exitCode*/)>;
|
||||
|
||||
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const QtcProcess &);
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT SynchronousProcess : public QtcProcess
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SynchronousProcess();
|
||||
~SynchronousProcess() override;
|
||||
|
||||
// Force the use of 'runBlocking' for now.
|
||||
void start() = delete;
|
||||
|
||||
// This starts a nested event loop when running the command.
|
||||
void setProcessUserEventWhileRunning(); // Avoid.
|
||||
|
||||
// Starts the command and waits for finish. User input processing depends
|
||||
// on whether setProcessUserEventWhileRunning was called.
|
||||
void runBlocking();
|
||||
};
|
||||
using SynchronousProcess = QtcProcess; // FIXME: Remove.
|
||||
|
||||
} // namespace Utils
|
||||
|
@@ -184,7 +184,7 @@ bool CMakeTool::isValid() const
|
||||
return m_introspection->m_didRun && !m_introspection->m_fileApis.isEmpty();
|
||||
}
|
||||
|
||||
void CMakeTool::runCMake(SynchronousProcess &cmake, const QStringList &args, int timeoutS) const
|
||||
void CMakeTool::runCMake(QtcProcess &cmake, const QStringList &args, int timeoutS) const
|
||||
{
|
||||
cmake.setTimeoutS(timeoutS);
|
||||
cmake.setDisableUnixTerminal();
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <utils/id.h>
|
||||
#include <utils/optional.h>
|
||||
|
||||
namespace Utils { class SynchronousProcess; }
|
||||
namespace Utils { class QtcProcess; }
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
private:
|
||||
void readInformation() const;
|
||||
|
||||
void runCMake(Utils::SynchronousProcess &proc, const QStringList &args, int timeoutS = 1) const;
|
||||
void runCMake(Utils::QtcProcess &proc, const QStringList &args, int timeoutS = 1) const;
|
||||
void parseFunctionDetailsOutput(const QString &output);
|
||||
QStringList parseVariableOutput(const QString &output);
|
||||
|
||||
|
Reference in New Issue
Block a user