Commit 9b4e6512 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen

protect against recursing into handleResponse

those pesky nested event loops ...

i pondered various other scenarios (in particular, the adapter or
gdb crashing while the nested loop is running), but did not discover
serious side effects of it, so i'm not trying to handle it specially.
parent 3e72ecde
...@@ -191,6 +191,9 @@ GdbEngine::GdbEngine(DebuggerManager *manager) : ...@@ -191,6 +191,9 @@ GdbEngine::GdbEngine(DebuggerManager *manager) :
m_trkOptions->fromSettings(Core::ICore::instance()->settings()); m_trkOptions->fromSettings(Core::ICore::instance()->settings());
m_gdbAdapter = 0; m_gdbAdapter = 0;
// Needs no resetting in initializeVariables()
m_busy = false;
connect(theDebuggerAction(AutoDerefPointers), SIGNAL(valueChanged(QVariant)), connect(theDebuggerAction(AutoDerefPointers), SIGNAL(valueChanged(QVariant)),
this, SLOT(setAutoDerefPointers(QVariant))); this, SLOT(setAutoDerefPointers(QVariant)));
} }
...@@ -594,6 +597,10 @@ void GdbEngine::readGdbStandardOutput() ...@@ -594,6 +597,10 @@ void GdbEngine::readGdbStandardOutput()
m_inbuffer.append(m_gdbProc.readAllStandardOutput()); m_inbuffer.append(m_gdbProc.readAllStandardOutput());
// This can trigger when a dialog starts a nested event loop
if (m_busy)
return;
while (newstart < m_inbuffer.size()) { while (newstart < m_inbuffer.size()) {
int start = newstart; int start = newstart;
int end = m_inbuffer.indexOf('\n', scan); int end = m_inbuffer.indexOf('\n', scan);
...@@ -612,7 +619,9 @@ void GdbEngine::readGdbStandardOutput() ...@@ -612,7 +619,9 @@ void GdbEngine::readGdbStandardOutput()
continue; continue;
} }
#endif #endif
m_busy = true;
handleResponse(QByteArray::fromRawData(m_inbuffer.constData() + start, end - start)); handleResponse(QByteArray::fromRawData(m_inbuffer.constData() + start, end - start));
m_busy = false;
} }
m_inbuffer.clear(); m_inbuffer.clear();
} }
......
...@@ -160,6 +160,7 @@ private: ...@@ -160,6 +160,7 @@ private:
QTextCodec::ConverterState m_outputCodecState; QTextCodec::ConverterState m_outputCodecState;
QByteArray m_inbuffer; QByteArray m_inbuffer;
bool m_busy;
QProcess m_gdbProc; QProcess m_gdbProc;
AbstractGdbAdapter *m_gdbAdapter; AbstractGdbAdapter *m_gdbAdapter;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment