Debugger: Fix debugger switching to edit mode.

... on clicking stack frames or disassembler/
memory views.

Introduce flags to openEditorAt, pass
EditorManager::NoModeSwitch where applicable.

Task-number: QTCREATORBUG-2278
This commit is contained in:
Friedemann Kleint
2010-09-07 09:51:20 +02:00
parent 9374ba00d2
commit 763b59aa73
5 changed files with 21 additions and 14 deletions

View File

@@ -297,7 +297,9 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
void Manager::gotoLocation(const QString &fileName, int line, int column) void Manager::gotoLocation(const QString &fileName, int line, int column)
{ {
bool newEditor = false; bool newEditor = false;
TextEditor::BaseTextEditor::openEditorAt(fileName, line, column, QString(), &newEditor); TextEditor::BaseTextEditor::openEditorAt(fileName, line, column, QString(),
Core::EditorManager::IgnoreNavigationHistory,
&newEditor);
} }
void Manager::gotoLocations(const QList<QVariant> &list) void Manager::gotoLocations(const QList<QVariant> &list)

View File

@@ -123,7 +123,7 @@ void MemoryViewAgent::createBinEditor(quint64 addr)
connect(editor->widget(), SIGNAL(endOfFileRequested(Core::IEditor *)), connect(editor->widget(), SIGNAL(endOfFileRequested(Core::IEditor *)),
this, SLOT(handleEndOfFileRequested(Core::IEditor*))); this, SLOT(handleEndOfFileRequested(Core::IEditor*)));
m_editors << editor; m_editors << editor;
editorManager->activateEditor(editor); editorManager->activateEditor(editor, Core::EditorManager::NoModeSwitch);
QMetaObject::invokeMethod(editor->widget(), "setNewWindowRequestAllowed"); QMetaObject::invokeMethod(editor->widget(), "setNewWindowRequestAllowed");
QMetaObject::invokeMethod(editor->widget(), "setLazyData", QMetaObject::invokeMethod(editor->widget(), "setLazyData",
Q_ARG(quint64, addr), Q_ARG(int, DataRange), Q_ARG(int, BinBlockSize)); Q_ARG(quint64, addr), Q_ARG(int, DataRange), Q_ARG(int, BinBlockSize));
@@ -147,7 +147,7 @@ void MemoryViewAgent::addLazyData(QObject *editorToken, quint64 addr,
{ {
Core::IEditor *editor = qobject_cast<Core::IEditor *>(editorToken); Core::IEditor *editor = qobject_cast<Core::IEditor *>(editorToken);
if (editor && editor->widget()) { if (editor && editor->widget()) {
Core::EditorManager::instance()->activateEditor(editor); Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::NoModeSwitch);
QMetaObject::invokeMethod(editor->widget(), "addLazyData", QMetaObject::invokeMethod(editor->widget(), "addLazyData",
Q_ARG(quint64, addr / BinBlockSize), Q_ARG(QByteArray, ba)); Q_ARG(quint64, addr / BinBlockSize), Q_ARG(QByteArray, ba));
} }
@@ -343,7 +343,7 @@ void DisassemblerViewAgent::setContents(const QString &contents)
d->configureMimeType(); d->configureMimeType();
} }
editorManager->activateEditor(d->editor); editorManager->activateEditor(d->editor, Core::EditorManager::NoModeSwitch);
plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget()); plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget());
if (plainTextEdit) { if (plainTextEdit) {

View File

@@ -2345,7 +2345,9 @@ void DebuggerPluginPrivate::gotoLocation(const QString &file, int line, bool set
{ {
bool newEditor = false; bool newEditor = false;
ITextEditor *editor = ITextEditor *editor =
BaseTextEditor::openEditorAt(file, line, 0, QString(), &newEditor); BaseTextEditor::openEditorAt(file, line, 0, QString(),
Core::EditorManager::IgnoreNavigationHistory,
&newEditor);
if (!editor) if (!editor)
return; return;
if (newEditor) if (newEditor)
@@ -2575,7 +2577,9 @@ void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker)
{ {
bool newEditor = false; bool newEditor = false;
ITextEditor *editor = ITextEditor *editor =
BaseTextEditor::openEditorAt(file, line, 0, QString(), &newEditor); BaseTextEditor::openEditorAt(file, line, 0, QString(),
Core::EditorManager::IgnoreNavigationHistory|Core::EditorManager::NoModeSwitch,
&newEditor);
if (!editor) if (!editor)
return; return;
if (newEditor) if (newEditor)

View File

@@ -140,18 +140,16 @@ protected:
} // namespace Internal } // namespace Internal
} // namespace TextEditor } // namespace TextEditor
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName, int line, int column,
ITextEditor *BaseTextEditor::openEditorAt(const QString &fileName, const QString &editorKind,
int line, Core::EditorManager::OpenEditorFlags flags,
int column, bool *newEditor)
const QString &editorKind,
bool *newEditor)
{ {
Core::EditorManager *editorManager = Core::EditorManager::instance(); Core::EditorManager *editorManager = Core::EditorManager::instance();
editorManager->cutForwardNavigationHistory(); editorManager->cutForwardNavigationHistory();
editorManager->addCurrentPositionToNavigationHistory(); editorManager->addCurrentPositionToNavigationHistory();
Core::IEditor *editor = editorManager->openEditor(fileName, editorKind, Core::IEditor *editor = editorManager->openEditor(fileName, editorKind,
Core::EditorManager::IgnoreNavigationHistory, newEditor); flags, newEditor);
TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor); TextEditor::ITextEditor *texteditor = qobject_cast<TextEditor::ITextEditor *>(editor);
if (texteditor) { if (texteditor) {
texteditor->gotoLine(line, column); texteditor->gotoLine(line, column);

View File

@@ -34,6 +34,8 @@
#include <find/ifindsupport.h> #include <find/ifindsupport.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtGui/QPlainTextEdit> #include <QtGui/QPlainTextEdit>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -141,7 +143,8 @@ public:
~BaseTextEditor(); ~BaseTextEditor();
static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0, static ITextEditor *openEditorAt(const QString &fileName, int line, int column = 0,
const QString &editorId = QString(), const QString &editorId = QString(),
Core::EditorManager::OpenEditorFlags flags = Core::EditorManager::IgnoreNavigationHistory,
bool *newEditor = 0); bool *newEditor = 0);
const Utils::ChangeSet &changeSet() const; const Utils::ChangeSet &changeSet() const;