Commit 8926f716 authored by hjk's avatar hjk
Browse files

debugger: move MemoryViewAgent ownership to DebuggerEngine

parent 8e5eaf82
......@@ -113,7 +113,6 @@ public:
virtual void showModuleSymbols(const QString &moduleName,
const QVector<Symbol> &symbols) = 0;
virtual void openMemoryEditor() = 0;
virtual void updateMemoryEditors() = 0;
virtual void languagesChanged() = 0;
virtual Utils::SavedAction *action(int code) const = 0;
......
......@@ -189,8 +189,9 @@ public:
m_stackHandler(),
m_threadsHandler(),
m_watchHandler(engine),
m_isSlaveEngine(false),
m_disassemblerViewAgent(engine),
m_isSlaveEngine(false)
m_memoryViewAgent(engine)
{}
~DebuggerEnginePrivate() {}
......@@ -264,10 +265,11 @@ public:
StackHandler m_stackHandler;
ThreadsHandler m_threadsHandler;
WatchHandler m_watchHandler;
DisassemblerViewAgent m_disassemblerViewAgent;
QFutureInterface<void> m_progress;
bool m_isSlaveEngine;
DisassemblerViewAgent m_disassemblerViewAgent;
MemoryViewAgent m_memoryViewAgent;
};
......@@ -1421,7 +1423,12 @@ bool DebuggerEngine::isCppBreakpoint(const BreakpointParameters &p)
void DebuggerEngine::openMemoryView(quint64 address)
{
(void) new MemoryViewAgent(this, address);
d->m_memoryViewAgent.createBinEditor(address);
}
void DebuggerEngine::updateMemoryViews()
{
d->m_memoryViewAgent.updateContents();
}
void DebuggerEngine::openDisassemblerView(const StackFrame &frame)
......
......@@ -166,6 +166,7 @@ public:
virtual void openMemoryView(quint64 addr);
virtual void fetchMemory(Internal::MemoryViewAgent *, QObject *,
quint64 addr, quint64 length);
virtual void updateMemoryViews();
virtual void openDisassemblerView(const Internal::StackFrame &frame);
virtual void fetchDisassembler(Internal::DisassemblerViewAgent *);
virtual void activateFrame(int index);
......
......@@ -1027,7 +1027,6 @@ public slots:
void languagesChanged();
void showStatusMessage(const QString &msg, int timeout = -1);
void openMemoryEditor();
void updateMemoryEditors();
const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;
......@@ -2426,16 +2425,6 @@ void DebuggerPluginPrivate::openMemoryEditor()
currentEngine()->openMemoryView(dialog.address());
}
void DebuggerPluginPrivate::updateMemoryEditors()
{
EditorManager *editorManager = EditorManager::instance();
QTC_ASSERT(editorManager, return);
foreach (IEditor *editor, editorManager->openedEditors()) {
if (editor->property(Constants::OPENED_WITH_MEMORY).toBool())
QMetaObject::invokeMethod(editor->widget(), "updateContents");
}
}
void DebuggerPluginPrivate::coreShutdown()
{
m_shuttingDown = true;
......
......@@ -3530,7 +3530,7 @@ void GdbEngine::updateLocals(const QVariant &cookie)
updateLocalsPython(false, QByteArray());
else
updateLocalsClassic(cookie);
debuggerCore()->updateMemoryEditors();
updateMemoryViews();
}
......
......@@ -62,21 +62,19 @@ namespace Internal {
namespace { const int DataRange = 1024 * 1024; }
MemoryViewAgent::MemoryViewAgent(Debugger::DebuggerEngine *engine, quint64 addr)
MemoryViewAgent::MemoryViewAgent(Debugger::DebuggerEngine *engine)
: QObject(engine), m_engine(engine)
{
QTC_ASSERT(engine, /**/);
createBinEditor(addr);
}
MemoryViewAgent::~MemoryViewAgent()
{
EditorManager *editorManager = EditorManager::instance();
QList<IEditor *> editors;
foreach (QPointer<IEditor> editor, m_editors)
if (editor)
editors.append(editor.data());
editorManager->closeEditors(editors);
EditorManager::instance()->closeEditors(editors);
}
void MemoryViewAgent::createBinEditor(quint64 addr)
......@@ -156,5 +154,12 @@ void MemoryViewAgent::handleEndOfFileRequested(IEditor *editor)
"setCursorPosition", Q_ARG(int, DataRange - 1));
}
void MemoryViewAgent::updateContents()
{
foreach (QPointer<IEditor> editor, m_editors)
if (editor)
QMetaObject::invokeMethod(editor->widget(), "updateContents");
}
} // namespace Internal
} // namespace Debugger
......@@ -48,18 +48,20 @@ class MemoryViewAgent : public QObject
Q_OBJECT
public:
// Called from Gui
explicit MemoryViewAgent(DebuggerEngine *engine, quint64 startaddr);
explicit MemoryViewAgent(DebuggerEngine *engine);
~MemoryViewAgent();
enum { BinBlockSize = 1024 };
public slots:
// Called from Engine
// Called by engine to create a new view.
void createBinEditor(quint64 startAddr);
// Called by engine to trigger update of contents.
void updateContents();
// Called by enine to pass updated contents.
void addLazyData(QObject *editorToken, quint64 addr, const QByteArray &data);
private:
Q_SLOT void createBinEditor(quint64 startAddr);
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);
......
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