From dfa7995b17d0ad227300de9bf169fe02a175fcf9 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 20 Jun 2011 17:47:09 +0200 Subject: [PATCH] QmlDesigner.designModeWidget: fix Using a QWeakPointer for m_textEditor, since the texteditor might be deleted if the document was closed. Moving the NavigationHistory handling upwards. Change-Id: Ib5c14d6cd139490379cc2bf76d5440720c5664bc Reviewed-on: http://codereview.qt.nokia.com/526 Reviewed-by: Qt Sanity Bot Reviewed-by: Thomas Hartmann --- src/plugins/qmldesigner/designmodewidget.cpp | 12 ++++++------ src/plugins/qmldesigner/designmodewidget.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index e5011c7a651..a22e6e4676e 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -185,7 +185,6 @@ void DocumentWarningWidget::goToError() DesignModeWidget::DesignModeWidget(QWidget *parent) : QWidget(parent), m_syncWithTextEdit(false), - m_textEditor(0), m_mainSplitter(0), m_leftSideBar(0), m_rightSideBar(0), @@ -271,8 +270,12 @@ void DesignModeWidget::toggleSidebars() void DesignModeWidget::showEditor(Core::IEditor *editor) { if (m_textEditor && editor) - if (m_textEditor->file()->fileName() == editor->file()->fileName()) - return; + if (m_textEditor->file()->fileName() != editor->file()->fileName()) { + if (!m_keepNavigatorHistory) + addNavigatorHistoryEntry(editor->file()->fileName()); + setupNavigatorHistory(); + } + // // Prevent recursive calls to function by explicitly managing initialization status // (QApplication::processEvents is called explicitly at a number of places) @@ -295,9 +298,6 @@ void DesignModeWidget::showEditor(Core::IEditor *editor) textEditor = qobject_cast(editor); if (textEditor) m_fakeToolBar->addEditor(textEditor); - if (!m_keepNavigatorHistory) - addNavigatorHistoryEntry(fileName); - setupNavigatorHistory(); } if (debug) diff --git a/src/plugins/qmldesigner/designmodewidget.h b/src/plugins/qmldesigner/designmodewidget.h index 1be2fa2fef3..ec99f589abc 100644 --- a/src/plugins/qmldesigner/designmodewidget.h +++ b/src/plugins/qmldesigner/designmodewidget.h @@ -130,7 +130,7 @@ public: void saveSettings(); void setAutoSynchronization(bool sync); - TextEditor::ITextEditor *textEditor() const {return m_textEditor; } + TextEditor::ITextEditor *textEditor() const {return m_textEditor.data(); } private slots: void undo(); @@ -200,7 +200,7 @@ private: void setupNavigatorHistory(); void addNavigatorHistoryEntry(const QString &fileName); - TextEditor::ITextEditor *m_textEditor; + QWeakPointer m_textEditor; QSplitter *m_mainSplitter; Core::SideBar *m_leftSideBar;