forked from qt-creator/qt-creator
QtcProcess: Don't merge ready read signals
We store pointers to signal objects inside m_signals list, so we can't easily merge the old ready read signal with the new one, since when flushing the m_signals from the main thread we are taking copy of m_signals, but this copy still holds the pointers to the original objects, and using them outside of locked mutex isn't safe. The possible solution would be to store simple data structures instead of signal objects allocated on heap. However, there is not really much gain of merging the ready read signals, so we get rid of it. Task-number: QTCREATORBUG-27578 Change-Id: Idd19a6fc1ebb4ccab1e4e367cfeb3f2f02a35512 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -83,10 +83,6 @@ public:
|
||||
, m_stdErr(stdErr) {}
|
||||
QByteArray stdOut() const { return m_stdOut; }
|
||||
QByteArray stdErr() const { return m_stdErr; }
|
||||
void mergeWith(ReadyReadSignal *newSignal) {
|
||||
m_stdOut += newSignal->stdOut();
|
||||
m_stdErr += newSignal->stdErr();
|
||||
}
|
||||
private:
|
||||
QByteArray m_stdOut;
|
||||
QByteArray m_stdErr;
|
||||
@@ -268,16 +264,6 @@ void CallerHandle::appendSignal(LauncherSignal *launcherSignal)
|
||||
|
||||
QMutexLocker locker(&m_mutex);
|
||||
QTC_ASSERT(isCalledFromLaunchersThread(), return);
|
||||
// Merge ReadyRead signals into one.
|
||||
if (launcherSignal->signalType() == CallerHandle::SignalType::ReadyRead
|
||||
&& !m_signals.isEmpty()
|
||||
&& m_signals.last()->signalType() == CallerHandle::SignalType::ReadyRead) {
|
||||
ReadyReadSignal *lastSignal = static_cast<ReadyReadSignal *>(m_signals.last());
|
||||
ReadyReadSignal *newSignal = static_cast<ReadyReadSignal *>(launcherSignal);
|
||||
lastSignal->mergeWith(newSignal);
|
||||
delete newSignal;
|
||||
return;
|
||||
}
|
||||
m_signals.append(launcherSignal);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user