Commit 4461ec2e authored by hjk's avatar hjk
Browse files

debugger: prevent crash when trying to view memory if bin editor is

unavailable
parent aa3b274a
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QMessageBox>
#include <QtGui/QPlainTextEdit> #include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCursor> #include <QtGui/QTextCursor>
#include <QtGui/QSyntaxHighlighter> #include <QtGui/QSyntaxHighlighter>
...@@ -68,13 +70,13 @@ namespace Internal { ...@@ -68,13 +70,13 @@ namespace Internal {
*/ */
MemoryViewAgent::MemoryViewAgent(DebuggerManager *manager, quint64 addr) MemoryViewAgent::MemoryViewAgent(DebuggerManager *manager, quint64 addr)
: QObject(manager), m_engine(manager->currentEngine()) : QObject(manager), m_engine(manager->currentEngine()), m_manager(manager)
{ {
init(addr); init(addr);
} }
MemoryViewAgent::MemoryViewAgent(DebuggerManager *manager, const QString &addr) MemoryViewAgent::MemoryViewAgent(DebuggerManager *manager, const QString &addr)
: QObject(manager), m_engine(manager->currentEngine()) : QObject(manager), m_engine(manager->currentEngine()), m_manager(manager)
{ {
bool ok = true; bool ok = true;
init(addr.toULongLong(&ok, 0)); init(addr.toULongLong(&ok, 0));
...@@ -94,11 +96,19 @@ void MemoryViewAgent::init(quint64 addr) ...@@ -94,11 +96,19 @@ void MemoryViewAgent::init(quint64 addr)
m_editor = editorManager->openEditorWithContents( m_editor = editorManager->openEditorWithContents(
Core::Constants::K_DEFAULT_BINARY_EDITOR, Core::Constants::K_DEFAULT_BINARY_EDITOR,
&titlePattern); &titlePattern);
connect(m_editor->widget(), SIGNAL(lazyDataRequested(quint64,bool)), if (m_editor) {
this, SLOT(fetchLazyData(quint64,bool))); connect(m_editor->widget(), SIGNAL(lazyDataRequested(quint64,bool)),
editorManager->activateEditor(m_editor); this, SLOT(fetchLazyData(quint64,bool)));
QMetaObject::invokeMethod(m_editor->widget(), "setLazyData", editorManager->activateEditor(m_editor);
Q_ARG(quint64, addr), Q_ARG(int, 1024 * 1024), Q_ARG(int, BinBlockSize)); QMetaObject::invokeMethod(m_editor->widget(), "setLazyData",
Q_ARG(quint64, addr), Q_ARG(int, 1024 * 1024), Q_ARG(int, BinBlockSize));
} else {
m_manager->showMessageBox(QMessageBox::Warning,
tr("No memory viewer available"),
tr("The memory contents cannot be shown as no viewer plugin not "
"the BinEditor plugin could be loaded."));
deleteLater();
}
} }
void MemoryViewAgent::fetchLazyData(quint64 block, bool sync) void MemoryViewAgent::fetchLazyData(quint64 block, bool sync)
......
...@@ -70,6 +70,7 @@ private: ...@@ -70,6 +70,7 @@ private:
QPointer<IDebuggerEngine> m_engine; QPointer<IDebuggerEngine> m_engine;
QPointer<Core::IEditor> m_editor; QPointer<Core::IEditor> m_editor;
QPointer<DebuggerManager> m_manager;
}; };
......
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