forked from qt-creator/qt-creator
Work with documents instead of editors where possible in debugger
And where using editors is necessary, take *all* editors into account, not a random set of what previously was called "original" editors (when using splits). Change-Id: Id6bbad08f3083b6744fc2edcf0b87ba504d3257b Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -582,20 +582,13 @@ void DebuggerEngine::gotoLocation(const Location &loc)
|
|||||||
|
|
||||||
const QString file = loc.fileName();
|
const QString file = loc.fileName();
|
||||||
const int line = loc.lineNumber();
|
const int line = loc.lineNumber();
|
||||||
QList<IEditor *> editors = EditorManager::instance()->editorsForFileName(file);
|
bool newEditor = false;
|
||||||
IEditor *editor = 0;
|
IEditor *editor = EditorManager::openEditor(file, Core::Id(),
|
||||||
if (editors.isEmpty()) {
|
EditorManager::IgnoreNavigationHistory, &newEditor);
|
||||||
editor = EditorManager::openEditor(file, Core::Id(),
|
QTC_ASSERT(editor, return); // Unreadable file?
|
||||||
EditorManager::IgnoreNavigationHistory);
|
editor->gotoLine(line, 0);
|
||||||
QTC_ASSERT(editor, return); // Unreadable file?
|
if (newEditor)
|
||||||
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
||||||
} else {
|
|
||||||
editor = editors.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
ITextEditor *texteditor = qobject_cast<ITextEditor *>(editor);
|
|
||||||
if (texteditor)
|
|
||||||
texteditor->gotoLine(line, 0);
|
|
||||||
|
|
||||||
if (loc.needsMarker()) {
|
if (loc.needsMarker()) {
|
||||||
d->m_locationMark.reset(new TextEditor::BaseTextMark(file, line));
|
d->m_locationMark.reset(new TextEditor::BaseTextMark(file, line));
|
||||||
@@ -604,9 +597,6 @@ void DebuggerEngine::gotoLocation(const Location &loc)
|
|||||||
d->m_locationMark->init();
|
d->m_locationMark->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Breaks with split views.
|
|
||||||
if (!d->m_memoryAgent.hasVisibleEditor() || loc.needsRaise())
|
|
||||||
EditorManager::activateEditor(editor);
|
|
||||||
//qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor();
|
//qDebug() << "MEMORY: " << d->m_memoryAgent.hasVisibleEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2119,29 +2119,26 @@ void DebuggerPluginPrivate::cleanupViews()
|
|||||||
if (!boolSetting(CloseBuffersOnExit))
|
if (!boolSetting(CloseBuffersOnExit))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EditorManager *editorManager = EditorManager::instance();
|
QList<IDocument *> toClose;
|
||||||
QTC_ASSERT(editorManager, return);
|
foreach (IDocument *document, EditorManager::documentModel()->openedDocuments()) {
|
||||||
QList<IEditor *> toClose;
|
if (document->property(Constants::OPENED_BY_DEBUGGER).toBool()) {
|
||||||
foreach (IEditor *editor, editorManager->openedEditors()) {
|
|
||||||
if (editor->property(Constants::OPENED_BY_DEBUGGER).toBool()) {
|
|
||||||
IDocument *doc = editor->document();
|
|
||||||
bool keepIt = true;
|
bool keepIt = true;
|
||||||
if (editor->property(Constants::OPENED_WITH_DISASSEMBLY).toBool())
|
if (document->property(Constants::OPENED_WITH_DISASSEMBLY).toBool())
|
||||||
keepIt = false;
|
keepIt = false;
|
||||||
else if (doc->isModified())
|
else if (document->isModified())
|
||||||
keepIt = true;
|
keepIt = true;
|
||||||
else if (doc->filePath().contains(_("qeventdispatcher")))
|
else if (document->filePath().contains(_("qeventdispatcher")))
|
||||||
keepIt = false;
|
keepIt = false;
|
||||||
else
|
else
|
||||||
keepIt = (editor == EditorManager::currentEditor());
|
keepIt = (document == EditorManager::currentDocument());
|
||||||
|
|
||||||
if (keepIt)
|
if (keepIt)
|
||||||
editor->setProperty(Constants::OPENED_BY_DEBUGGER, false);
|
document->setProperty(Constants::OPENED_BY_DEBUGGER, false);
|
||||||
else
|
else
|
||||||
toClose.append(editor);
|
toClose.append(document);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
editorManager->closeEditors(toClose);
|
EditorManager::closeDocuments(toClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerPluginPrivate::setBusyCursor(bool busy)
|
void DebuggerPluginPrivate::setBusyCursor(bool busy)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/editormanager/documentmodel.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <utils/tooltip/tooltip.h>
|
||||||
@@ -1372,7 +1373,8 @@ void DebuggerToolTipManager::debugModeEntered()
|
|||||||
this, SLOT(slotUpdateVisibleToolTips()));
|
this, SLOT(slotUpdateVisibleToolTips()));
|
||||||
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
|
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
|
||||||
this, SLOT(slotEditorOpened(Core::IEditor*)));
|
this, SLOT(slotEditorOpened(Core::IEditor*)));
|
||||||
foreach (IEditor *e, em->openedEditors())
|
DocumentModel *documentModel = EditorManager::documentModel();
|
||||||
|
foreach (IEditor *e, documentModel->editorsForDocuments(documentModel->openedDocuments()))
|
||||||
slotEditorOpened(e);
|
slotEditorOpened(e);
|
||||||
// Position tooltips delayed once all the editor placeholder layouting is done.
|
// Position tooltips delayed once all the editor placeholder layouting is done.
|
||||||
if (!m_tooltips.isEmpty())
|
if (!m_tooltips.isEmpty())
|
||||||
@@ -1391,15 +1393,14 @@ void DebuggerToolTipManager::leavingDebugMode()
|
|||||||
hide();
|
hide();
|
||||||
if (QWidget *topLevel = ICore::mainWindow()->topLevelWidget())
|
if (QWidget *topLevel = ICore::mainWindow()->topLevelWidget())
|
||||||
topLevel->removeEventFilter(this);
|
topLevel->removeEventFilter(this);
|
||||||
if (EditorManager *em = EditorManager::instance()) {
|
DocumentModel *documentModel = EditorManager::documentModel();
|
||||||
foreach (IEditor *e, em->openedEditors()) {
|
foreach (IEditor *e, documentModel->editorsForDocuments(documentModel->openedDocuments())) {
|
||||||
if (DebuggerToolTipEditor toolTipEditor = DebuggerToolTipEditor(e)) {
|
if (DebuggerToolTipEditor toolTipEditor = DebuggerToolTipEditor(e)) {
|
||||||
toolTipEditor.baseTextEditor->verticalScrollBar()->disconnect(this);
|
toolTipEditor.baseTextEditor->verticalScrollBar()->disconnect(this);
|
||||||
toolTipEditor.textEditor->disconnect(this);
|
toolTipEditor.textEditor->disconnect(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
em->disconnect(this);
|
|
||||||
}
|
}
|
||||||
|
EditorManager::instance()->disconnect(this);
|
||||||
m_lastToolTipEditor = 0;
|
m_lastToolTipEditor = 0;
|
||||||
m_lastToolTipPoint = QPoint(-1, -1);
|
m_lastToolTipPoint = QPoint(-1, -1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,8 +310,9 @@ void DisassemblerAgent::setContentsToEditor(const DisassemblerLines &contents)
|
|||||||
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
||||||
&titlePattern));
|
&titlePattern));
|
||||||
QTC_ASSERT(d->editor, return);
|
QTC_ASSERT(d->editor, return);
|
||||||
d->editor->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
IDocument *document = d->editor->document();
|
||||||
d->editor->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
document->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
||||||
|
document->setProperty(Debugger::Constants::OPENED_WITH_DISASSEMBLY, true);
|
||||||
d->configureMimeType();
|
d->configureMimeType();
|
||||||
|
|
||||||
BaseTextEditorWidget *baseTextEdit =
|
BaseTextEditorWidget *baseTextEdit =
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ static void openImageViewer(const QImage &image)
|
|||||||
temporaryFile.close();
|
temporaryFile.close();
|
||||||
}
|
}
|
||||||
if (Core::IEditor *e = Core::EditorManager::instance()->openEditor(fileName))
|
if (Core::IEditor *e = Core::EditorManager::instance()->openEditor(fileName))
|
||||||
e->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, QVariant(true));
|
e->document()->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, QVariant(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::contextMenuEvent(QContextMenuEvent *ev)
|
void ImageViewer::contextMenuEvent(QContextMenuEvent *ev)
|
||||||
|
|||||||
@@ -181,8 +181,8 @@ bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags,
|
|||||||
Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title);
|
Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title);
|
||||||
if (!editor)
|
if (!editor)
|
||||||
return false;
|
return false;
|
||||||
editor->setProperty(Constants::OPENED_BY_DEBUGGER, QVariant(true));
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, QVariant(true));
|
||||||
editor->setProperty(Constants::OPENED_WITH_MEMORY, QVariant(true));
|
editor->document()->setProperty(Constants::OPENED_WITH_MEMORY, QVariant(true));
|
||||||
QWidget *editorBinEditor = editor->widget();
|
QWidget *editorBinEditor = editor->widget();
|
||||||
connectBinEditorWidget(editorBinEditor);
|
connectBinEditorWidget(editorBinEditor);
|
||||||
MemoryView::setBinEditorReadOnly(editorBinEditor, readOnly);
|
MemoryView::setBinEditorReadOnly(editorBinEditor, readOnly);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/helpmanager.h>
|
#include <coreplugin/helpmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -528,28 +528,25 @@ void QmlEngine::gotoLocation(const Location &location)
|
|||||||
if (QUrl(fileName).isLocalFile()) {
|
if (QUrl(fileName).isLocalFile()) {
|
||||||
// internal file from source files -> show generated .js
|
// internal file from source files -> show generated .js
|
||||||
QTC_ASSERT(m_sourceDocuments.contains(fileName), return);
|
QTC_ASSERT(m_sourceDocuments.contains(fileName), return);
|
||||||
Core::IEditor *editor = 0;
|
|
||||||
|
|
||||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
|
||||||
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
||||||
//Check if there are open editors with the same title
|
//Check if there are open documents with the same title
|
||||||
QList<Core::IEditor *> editors = editorManager->openedEditors();
|
foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) {
|
||||||
foreach (Core::IEditor *ed, editors) {
|
if (document->displayName() == titlePattern) {
|
||||||
if (ed->document()->displayName() == titlePattern) {
|
Core::EditorManager::instance()->activateEditorForDocument(document);
|
||||||
editor = ed;
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!editor) {
|
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
|
||||||
editor = Core::EditorManager::openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
|
QmlJSEditor::Constants::C_QMLJSEDITOR_ID, &titlePattern);
|
||||||
&titlePattern);
|
if (editor) {
|
||||||
if (editor)
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
||||||
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
QPlainTextEdit *plainTextEdit =
|
||||||
|
qobject_cast<QPlainTextEdit *>(editor->widget());
|
||||||
updateEditor(editor, m_sourceDocuments.value(fileName));
|
if (plainTextEdit)
|
||||||
|
plainTextEdit->setReadOnly(true);
|
||||||
|
updateDocument(editor->document(), m_sourceDocuments.value(fileName));
|
||||||
}
|
}
|
||||||
Core::EditorManager::activateEditor(editor);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DebuggerEngine::gotoLocation(location);
|
DebuggerEngine::gotoLocation(location);
|
||||||
}
|
}
|
||||||
@@ -1299,27 +1296,22 @@ void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int
|
|||||||
//update open editors
|
//update open editors
|
||||||
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
||||||
//Check if there are open editors with the same title
|
//Check if there are open editors with the same title
|
||||||
QList<Core::IEditor *> editors = Core::EditorManager::instance()->openedEditors();
|
foreach (Core::IDocument *doc, Core::EditorManager::documentModel()->openedDocuments()) {
|
||||||
foreach (Core::IEditor *editor, editors) {
|
if (doc->displayName() == titlePattern) {
|
||||||
if (editor->document()->displayName() == titlePattern) {
|
updateDocument(doc, document);
|
||||||
updateEditor(editor, document);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::updateEditor(Core::IEditor *editor, const QTextDocument *document)
|
void QmlEngine::updateDocument(Core::IDocument *document, const QTextDocument *textDocument)
|
||||||
{
|
{
|
||||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
TextEditor::BaseTextDocument *baseTextDocument
|
||||||
if (!textEditor)
|
= qobject_cast<TextEditor::BaseTextDocument *>(document);
|
||||||
|
if (!baseTextDocument)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPlainTextEdit *plainTextEdit =
|
baseTextDocument->document()->setPlainText(textDocument->toPlainText());
|
||||||
qobject_cast<QPlainTextEdit *>(editor->widget());
|
|
||||||
if (!plainTextEdit)
|
|
||||||
return;
|
|
||||||
plainTextEdit->setPlainText(document->toPlainText());
|
|
||||||
plainTextEdit->setReadOnly(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlEngine::canEvaluateScript(const QString &script)
|
bool QmlEngine::canEvaluateScript(const QString &script)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IEditor;
|
class IDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
@@ -181,7 +181,7 @@ private:
|
|||||||
const QString &oldBasePath, const QString &newBasePath) const;
|
const QString &oldBasePath, const QString &newBasePath) const;
|
||||||
QString qmlImportPath() const;
|
QString qmlImportPath() const;
|
||||||
|
|
||||||
void updateEditor(Core::IEditor *editor, const QTextDocument *document);
|
void updateDocument(Core::IDocument *document, const QTextDocument *textDocument);
|
||||||
bool canEvaluateScript(const QString &script);
|
bool canEvaluateScript(const QString &script);
|
||||||
bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line,
|
bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line,
|
||||||
quint32 *column, bool *valid);
|
quint32 *column, bool *valid);
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void SourceAgent::setContent(const QString &filePath, const QString &content)
|
|||||||
CppEditor::Constants::CPPEDITOR_ID,
|
CppEditor::Constants::CPPEDITOR_ID,
|
||||||
&titlePattern, content));
|
&titlePattern, content));
|
||||||
QTC_ASSERT(d->editor, return);
|
QTC_ASSERT(d->editor, return);
|
||||||
d->editor->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
d->editor->document()->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, true);
|
||||||
|
|
||||||
BaseTextEditorWidget *baseTextEdit =
|
BaseTextEditorWidget *baseTextEdit =
|
||||||
qobject_cast<BaseTextEditorWidget *>(d->editor->widget());
|
qobject_cast<BaseTextEditorWidget *>(d->editor->widget());
|
||||||
|
|||||||
Reference in New Issue
Block a user