debugger: move updateMarker from BreakHandler to BreakpointItem

Change-Id: Ie3bafc8fc23cc95e0795d57dac956b3345e671dd
Reviewed-on: http://codereview.qt.nokia.com/748
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-06-24 19:44:49 +02:00
committed by hjk
parent e41f11298b
commit 377668a0cf
2 changed files with 32 additions and 38 deletions

View File

@@ -394,24 +394,9 @@ void BreakHandler::loadBreakpoints()
void BreakHandler::updateMarkers() void BreakHandler::updateMarkers()
{ {
ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd(); Iterator it = m_storage.begin(), et = m_storage.end();
for ( ; it != et; ++it) for ( ; it != et; ++it)
updateMarker(it.key()); it->updateMarker(it.key());
}
void BreakHandler::updateMarker(BreakpointModelId id)
{
Iterator it = m_storage.find(id);
BREAK_ASSERT(it != m_storage.end(), return);
QString markerFileName = it->markerFileName();
int markerLineNumber = it->markerLineNumber();
if (it->marker && (markerFileName != it->marker->fileName()
|| markerLineNumber != it->marker->lineNumber()))
it->destroyMarker();
if (!it->marker && !markerFileName.isEmpty() && markerLineNumber > 0)
it->marker = new BreakpointMarker(id, markerFileName, markerLineNumber);
} }
QVariant BreakHandler::headerData(int section, QVariant BreakHandler::headerData(int section,
@@ -752,7 +737,7 @@ void BreakHandler::setEnabled(BreakpointModelId id, bool on)
return; return;
it->data.enabled = on; it->data.enabled = on;
it->destroyMarker(); it->destroyMarker();
updateMarker(id); it->updateMarker(id);
if (it->engine) { if (it->engine) {
it->state = BreakpointChangeRequested; it->state = BreakpointChangeRequested;
scheduleSynchronization(); scheduleSynchronization();
@@ -788,8 +773,8 @@ void BreakHandler::setTracepoint(BreakpointModelId id, bool on)
return; return;
it->data.tracepoint = on; it->data.tracepoint = on;
it->destroyMarker(); it->destroyMarker();
it->updateMarker(id);
updateMarker(id);
if (it->engine) { if (it->engine) {
it->state = BreakpointChangeRequested; it->state = BreakpointChangeRequested;
scheduleSynchronization(); scheduleSynchronization();
@@ -807,7 +792,7 @@ void BreakHandler::setMarkerFileAndLine(BreakpointModelId id,
it->response.fileName = fileName; it->response.fileName = fileName;
it->response.lineNumber = lineNumber; it->response.lineNumber = lineNumber;
it->destroyMarker(); it->destroyMarker();
updateMarker(id); it->updateMarker(id);
emit layoutChanged(); emit layoutChanged();
} }
@@ -836,7 +821,7 @@ void BreakHandler::setEngine(BreakpointModelId id, DebuggerEngine *value)
it->state = BreakpointInsertRequested; it->state = BreakpointInsertRequested;
it->response = BreakpointResponse(); it->response = BreakpointResponse();
it->response.fileName = it->data.fileName; it->response.fileName = it->data.fileName;
updateMarker(id); it->updateMarker(id);
scheduleSynchronization(); scheduleSynchronization();
} }
@@ -899,7 +884,7 @@ void BreakHandler::setState(BreakpointModelId id, BreakpointState state)
// FIXME: updateMarker() should recognize the need for icon changes. // FIXME: updateMarker() should recognize the need for icon changes.
if (state == BreakpointInserted) { if (state == BreakpointInserted) {
it->destroyMarker(); it->destroyMarker();
updateMarker(id); it->updateMarker(id);
} }
layoutChanged(); layoutChanged();
} }
@@ -977,13 +962,12 @@ void BreakHandler::notifyBreakpointReleased(BreakpointModelId id)
it->engine = 0; it->engine = 0;
it->response = BreakpointResponse(); it->response = BreakpointResponse();
it->subItems.clear(); it->subItems.clear();
delete it->marker; it->destroyMarker();
it->marker = 0; it->updateMarker(id);
if (it->data.type == WatchpointAtAddress if (it->data.type == WatchpointAtAddress
|| it->data.type == WatchpointAtExpression || it->data.type == WatchpointAtExpression
|| it->data.type == BreakpointByAddress) || it->data.type == BreakpointByAddress)
it->data.enabled = false; it->data.enabled = false;
updateMarker(id);
layoutChanged(); layoutChanged();
} }
@@ -1053,9 +1037,10 @@ void BreakHandler::appendBreakpoint(const BreakpointParameters &data)
m_storage.insert(id, item); m_storage.insert(id, item);
endInsertRows(); endInsertRows();
item.updateMarker(id);
layoutChanged(); layoutChanged();
updateMarker(id);
scheduleSynchronization(); scheduleSynchronization();
} }
@@ -1075,6 +1060,7 @@ void BreakHandler::handleAlienBreakpoint(BreakpointModelId id,
item.response = response; item.response = response;
item.state = BreakpointInserted; item.state = BreakpointInserted;
item.engine = engine; item.engine = engine;
item.updateMarker(id);
const int row = m_storage.size(); const int row = m_storage.size();
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
@@ -1082,8 +1068,6 @@ void BreakHandler::handleAlienBreakpoint(BreakpointModelId id,
endInsertRows(); endInsertRows();
layoutChanged(); layoutChanged();
updateMarker(id);
scheduleSynchronization(); scheduleSynchronization();
} }
} }
@@ -1245,7 +1229,7 @@ void BreakHandler::updateLineNumberFromMarker(BreakpointModelId id, int lineNumb
// FIXME: Should we tell gdb about the change? // FIXME: Should we tell gdb about the change?
it->response.lineNumber = lineNumber; it->response.lineNumber = lineNumber;
} }
updateMarker(id); it->updateMarker(id);
emit layoutChanged(); emit layoutChanged();
} }
@@ -1304,15 +1288,14 @@ void BreakHandler::setResponse(BreakpointModelId id,
{ {
Iterator it = m_storage.find(id); Iterator it = m_storage.find(id);
BREAK_ASSERT(it != m_storage.end(), return); BREAK_ASSERT(it != m_storage.end(), return);
BreakpointItem &item = it.value(); it->response = response;
item.response = response; it->destroyMarker();
item.destroyMarker(); it->updateMarker(id);
// Take over corrected values from response. // Take over corrected values from response.
if ((item.data.type == BreakpointByFileAndLine if ((it->data.type == BreakpointByFileAndLine
|| item.data.type == BreakpointByFunction) || it->data.type == BreakpointByFunction)
&& !response.module.isEmpty()) && !response.module.isEmpty())
item.data.module = response.module; it->data.module = response.module;
updateMarker(id);
} }
void BreakHandler::changeBreakpointData(BreakpointModelId id, void BreakHandler::changeBreakpointData(BreakpointModelId id,
@@ -1325,7 +1308,7 @@ void BreakHandler::changeBreakpointData(BreakpointModelId id,
it->data = data; it->data = data;
if (parts == NoParts) { if (parts == NoParts) {
it->destroyMarker(); it->destroyMarker();
updateMarker(id); it->updateMarker(id);
layoutChanged(); layoutChanged();
} else if (it->needsChange() && it->engine && it->state != BreakpointNew) { } else if (it->needsChange() && it->engine && it->state != BreakpointNew) {
setState(id, BreakpointChangeRequested); setState(id, BreakpointChangeRequested);
@@ -1411,6 +1394,17 @@ bool BreakHandler::BreakpointItem::isLocatedAt
|| fileNameMatch(fileName, markerFileName())); || fileNameMatch(fileName, markerFileName()));
} }
void BreakHandler::BreakpointItem::updateMarker(BreakpointModelId id)
{
QString file = markerFileName();
int line = markerLineNumber();
if (marker && (file != marker->fileName() || line != marker->lineNumber()))
destroyMarker();
if (!marker && !file.isEmpty() && line > 0)
marker = new BreakpointMarker(id, file, line);
}
QIcon BreakHandler::BreakpointItem::icon() const QIcon BreakHandler::BreakpointItem::icon() const
{ {
// FIXME: This seems to be called on each cursor blink as soon as the // FIXME: This seems to be called on each cursor blink as soon as the

View File

@@ -183,7 +183,6 @@ private:
void setState(BreakpointModelId id, BreakpointState state); void setState(BreakpointModelId id, BreakpointState state);
void loadBreakpoints(); void loadBreakpoints();
void saveBreakpoints(); void saveBreakpoints();
void updateMarker(BreakpointModelId id);
void cleanupBreakpoint(BreakpointModelId id); void cleanupBreakpoint(BreakpointModelId id);
struct BreakpointItem struct BreakpointItem
@@ -194,6 +193,7 @@ private:
bool needsChange() const; bool needsChange() const;
bool isLocatedAt(const QString &fileName, int lineNumber, bool isLocatedAt(const QString &fileName, int lineNumber,
bool useMarkerPosition) const; bool useMarkerPosition) const;
void updateMarker(BreakpointModelId id);
QString toToolTip() const; QString toToolTip() const;
QString markerFileName() const; QString markerFileName() const;
int markerLineNumber() const; int markerLineNumber() const;