Commit be81d25b authored by hjk's avatar hjk
Browse files

bineditor: simplify code

Remove 'synchronous' parameter in data requests as everything is
asynchroneous right now. Also remove unneeded m_requests.contains call.
parent 8ed8554c
......@@ -176,7 +176,7 @@ void BinEditor::addData(quint64 block, const QByteArray &data)
}
}
bool BinEditor::requestDataAt(int pos, bool synchronous) const
bool BinEditor::requestDataAt(int pos) const
{
int block = pos / m_blockSize;
BlockMap::const_iterator it = m_modifiedData.find(block);
......@@ -188,10 +188,8 @@ bool BinEditor::requestDataAt(int pos, bool synchronous) const
if (!m_requests.contains(block)) {
m_requests.insert(block);
emit const_cast<BinEditor*>(this)->
dataRequested(editor(), m_baseAddr / m_blockSize + block,
synchronous);
if (!m_requests.contains(block))
return true; // synchronous data source
dataRequested(editor(), m_baseAddr / m_blockSize + block);
return true;
}
return false;
}
......@@ -530,7 +528,7 @@ int BinEditor::dataIndexOf(const QByteArray &pattern, int from, bool caseSensiti
const int end =
qMin<qint64>(static_cast<qint64>(from) + SearchStride, m_size);
while (from < end) {
if (!requestDataAt(block * m_blockSize, true))
if (!requestDataAt(block * m_blockSize))
return -1;
QByteArray data = blockData(block);
::memcpy(b, b + m_blockSize, trailing);
......@@ -561,7 +559,7 @@ int BinEditor::dataLastIndexOf(const QByteArray &pattern, int from, bool caseSen
int block = from / m_blockSize;
const int lowerBound = qMax(0, from - SearchStride);
while (from > lowerBound) {
if (!requestDataAt(block * m_blockSize, true))
if (!requestDataAt(block * m_blockSize))
return -1;
QByteArray data = blockData(block);
::memcpy(b + m_blockSize, b, trailing);
......
......@@ -133,7 +133,7 @@ Q_SIGNALS:
void copyAvailable(bool);
void cursorPositionChanged(int position);
void dataRequested(Core::IEditor *editor, quint64 block, bool synchronous);
void dataRequested(Core::IEditor *editor, quint64 block);
void newWindowRequested(quint64 address);
void newRangeRequested(Core::IEditor *, quint64 address);
void startOfFileRequested(Core::IEditor *);
......@@ -169,7 +169,7 @@ private:
int dataIndexOf(const QByteArray &pattern, int from, bool caseSensitive = true) const;
int dataLastIndexOf(const QByteArray &pattern, int from, bool caseSensitive = true) const;
bool requestDataAt(int pos, bool synchronous = false) const;
bool requestDataAt(int pos) const;
bool requestOldDataAt(int pos) const;
char dataAt(int pos, bool old = false) const;
char oldDataAt(int pos) const;
......
......@@ -185,7 +185,7 @@ public:
Core::IFile(parent)
{
m_editor = parent;
connect(m_editor, SIGNAL(dataRequested(Core::IEditor *, quint64, bool)),
connect(m_editor, SIGNAL(dataRequested(Core::IEditor*,quint64)),
this, SLOT(provideData(Core::IEditor *, quint64)));
connect(m_editor, SIGNAL(newRangeRequested(Core::IEditor*,quint64)),
this, SLOT(provideNewRange(Core::IEditor*,quint64)));
......
......@@ -92,8 +92,8 @@ void MemoryAgent::createBinEditor(quint64 addr)
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
editor->setProperty(Constants::OPENED_WITH_MEMORY, true);
connect(editor->widget(),
SIGNAL(dataRequested(Core::IEditor*,quint64,bool)),
SLOT(fetchLazyData(Core::IEditor*,quint64,bool)));
SIGNAL(dataRequested(Core::IEditor*,quint64)),
SLOT(fetchLazyData(Core::IEditor*,quint64)));
connect(editor->widget(),
SIGNAL(newWindowRequested(quint64)),
SLOT(createBinEditor(quint64)));
......@@ -125,9 +125,8 @@ void MemoryAgent::createBinEditor(quint64 addr)
}
}
void MemoryAgent::fetchLazyData(IEditor *editor, quint64 block, bool sync)
void MemoryAgent::fetchLazyData(IEditor *editor, quint64 block)
{
Q_UNUSED(sync); // FIXME: needed support for incremental searching
m_engine->fetchMemory(this, editor, BinBlockSize * block, BinBlockSize);
}
......
......@@ -63,16 +63,18 @@ public slots:
void createBinEditor(quint64 startAddr);
// Called by engine to trigger update of contents.
void updateContents();
// Called by enine to pass updated contents.
// Called by engine to pass updated contents.
void addLazyData(QObject *editorToken, quint64 addr, const QByteArray &data);
private:
Q_SLOT void fetchLazyData(Core::IEditor *, quint64 block, bool sync);
Q_SLOT void provideNewRange(Core::IEditor *editor, quint64 address);
Q_SLOT void handleStartOfFileRequested(Core::IEditor *editor);
Q_SLOT void handleEndOfFileRequested(Core::IEditor *editor);
Q_SLOT void handleDataChanged(Core::IEditor *editor, quint64 address, const QByteArray &data);
private slots:
void fetchLazyData(Core::IEditor *, quint64 block);
void provideNewRange(Core::IEditor *editor, quint64 address);
void handleStartOfFileRequested(Core::IEditor *editor);
void handleEndOfFileRequested(Core::IEditor *editor);
void handleDataChanged(Core::IEditor *editor, quint64 address,
const QByteArray &data);
private:
QList<QPointer<Core::IEditor> > m_editors;
QPointer<DebuggerEngine> m_engine;
};
......
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