Commit f3d38de9 authored by hjk's avatar hjk
Browse files

debugger: fix breakpoint toggling of "moved" breakpoints

parent 4271d2a2
......@@ -372,10 +372,12 @@ BreakHandler::BreakHandler(DebuggerEngine *engine)
m_disabledBreakpointIcon(_(":/debugger/images/breakpoint_disabled_16.png")),
m_pendingBreakPointIcon(_(":/debugger/images/breakpoint_pending_16.png")),
m_watchpointIcon(_(":/debugger/images/watchpoint.png")),
m_engine(engine), // Possibly 0 for the dummy engine "handling" session data.
m_engine(engine),
m_lastFound(0),
m_lastFoundQueried(false)
{}
{
QTC_ASSERT(m_engine, /**/);
}
BreakHandler::~BreakHandler()
{
......@@ -737,27 +739,11 @@ bool BreakHandler::setData(const QModelIndex &index, const QVariant &value, int
return true;
}
case RequestRemoveBreakpointRole: {
BreakpointData *data = value.value<BreakpointData *>();
QTC_ASSERT(data, return false);
removeBreakpoint(data);
return true;
}
case RequestAppendBreakpointRole: {
BreakpointData *data = value.value<BreakpointData *>();
QTC_ASSERT(data, return false);
appendBreakpoint(data);
if (m_engine)
m_engine->attemptBreakpointSynchronization();
return true;
}
case RequestUpdateBreakpointRole: {
BreakpointData *data = value.value<BreakpointData *>();
QTC_ASSERT(data, return false);
if (m_engine)
m_engine->attemptBreakpointSynchronization();
QTC_ASSERT(m_engine, return false);
m_engine->attemptBreakpointSynchronization();
return true;
}
......@@ -940,14 +926,25 @@ void BreakHandler::removeAllBreakpoints()
updateMarkers();
}
/*
void BreakHandler::setAllPending()
void BreakHandler::toggleBreakpoint(const QString &fileName, int lineNumber)
{
for (int index = size(); --index >= 0;)
at(index)->pending = true;
updateMarkers();
for (int index = size(); --index >= 0;) {
BreakpointData *data = m_bp.at(index);
if (data->isLocatedAt(fileName, lineNumber)) {
removeBreakpointHelper(index);
emit layoutChanged();
return;
}
}
BreakpointData *data = new BreakpointData;
data->fileName = fileName;
data->lineNumber = QByteArray::number(lineNumber);
data->pending = true;
data->setMarkerFileName(fileName);
data->setMarkerLineNumber(lineNumber);
appendBreakpoint(data);
m_engine->attemptBreakpointSynchronization();
}
*/
void BreakHandler::saveSessionData()
{
......
......@@ -56,7 +56,6 @@ public:
~BreakHandler();
void removeAllBreakpoints();
//void setAllPending();
void loadSessionData();
void saveSessionData();
......@@ -88,6 +87,7 @@ public:
void initializeFromTemplate(BreakHandler *other);
void storeToTemplate(BreakHandler *other);
void toggleBreakpoint(const QString &fileName, int lineNumber);
public slots:
void appendBreakpoint(BreakpointData *data);
......
......@@ -421,18 +421,6 @@ BreakpointData *BreakWindow::findSimilarBreakpoint(const BreakpointData *needle0
return v.value<BreakpointData *>();
}
void BreakWindow::appendBreakpoint(BreakpointData *data)
{
QVariant v = QVariant::fromValue<BreakpointData *>(data);
setModelData(RequestAppendBreakpointRole, v);
}
void BreakWindow::removeBreakpoint(BreakpointData *data)
{
QVariant v = QVariant::fromValue<BreakpointData *>(data);
setModelData(RequestRemoveBreakpointRole, v);
}
void BreakWindow::updateBreakpoint(BreakpointData *data)
{
QVariant v = QVariant::fromValue<BreakpointData *>(data);
......
......@@ -47,8 +47,8 @@ public:
BreakpointData *findSimilarBreakpoint(const BreakpointData *needle);
void updateBreakpoint(BreakpointData *data);
void appendBreakpoint(BreakpointData *data);
void removeBreakpoint(BreakpointData *data);
//void appendBreakpoint(BreakpointData *data);
//void removeBreakpoint(BreakpointData *data);
QVariant modelData(int role, int index);
public slots:
......
......@@ -190,14 +190,13 @@ enum ModelRoles
BreakpointIgnoreCountRole,
BreakpointThreadSpecRole,
RequestActivateBreakpointRole,
RequestRemoveBreakpointRole,
RequestRemoveBreakpointByIndexRole,
RequestSynchronizeBreakpointsRole,
RequestBreakByFunctionRole,
RequestBreakByFunctionMainRole,
RequestFindSimilarBreakpointRole,
RequestAppendBreakpointRole,
RequestUpdateBreakpointRole,
RequestToggleBreakpointRole,
// Locals and Watchers
LocalsINameRole,
......
......@@ -349,14 +349,17 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
break;
}
case RequestWatchPointRole:
//if (QAction *action = qobject_cast<QAction *>(sender()))
// watchPoint(action->data().toPoint());
QTC_ASSERT(false, /* FIXME ABC */);
case RequestToggleBreakpointRole: {
QList<QVariant> list = value.toList();
QTC_ASSERT(list.size() == 2, break);
const QString fileName = list.at(0).toString();
const int lineNumber = list.at(1).toInt();
breakHandler()->toggleBreakpoint(fileName, lineNumber);
break;
}
}
}
}
void DebuggerEngine::showModuleSymbols
(const QString &moduleName, const Symbols &symbols)
......
......@@ -1843,21 +1843,10 @@ void DebuggerPluginPrivate::toggleBreakpoint()
void DebuggerPluginPrivate::toggleBreakpoint(const QString &fileName, int lineNumber)
{
BreakpointData needle;
needle.bpFileName = fileName;
needle.bpLineNumber.setNum(lineNumber);
BreakpointData *data = m_breakWindow->findSimilarBreakpoint(&needle);
if (data) {
m_breakWindow->removeBreakpoint(data);
} else {
data = new BreakpointData;
data->fileName = fileName;
data->lineNumber = QByteArray::number(lineNumber);
data->pending = true;
data->setMarkerFileName(fileName);
data->setMarkerLineNumber(lineNumber);
m_breakWindow->appendBreakpoint(data);
}
QList<QVariant> list;
list.append(fileName);
list.append(lineNumber);
notifyCurrentEngine(RequestToggleBreakpointRole, list);
}
void DebuggerPluginPrivate::breakpointSetRemoveMarginActionTriggered()
......
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