From 2b46f828b4ae2f41c4efc9fde7e8b7c5e271b4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Mon, 11 Jan 2010 12:47:01 +0100 Subject: [PATCH] Fixed crash when leaving session with invalid bookmarks or breakpoints When the bookmark could not be added to the editor due to being on a non-existing line, it would not be cleaned up properly when the editor was closed, resulting in a crash when it later tried to remove itself from the no longer existing editor. In addition to fixing the crash, bookmarks that are not on valid lines are now automatically removed when you try to navigate to them. Task-number: QTCREATORBUG-545 Reviewed-by: mae --- src/plugins/bookmarks/bookmarkmanager.cpp | 9 ++++----- src/plugins/texteditor/basetextmark.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 4fc8c040105..116e732271d 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -485,11 +485,10 @@ Bookmark *BookmarkManager::bookmarkForIndex(QModelIndex index) bool BookmarkManager::gotoBookmark(Bookmark* bookmark) { - if (!TextEditor::BaseTextEditor::openEditorAt(bookmark->filePath(), bookmark->lineNumber())) { - // Could not open editor - return false; - } - return true; + using namespace TextEditor; + if (ITextEditor *editor = BaseTextEditor::openEditorAt(bookmark->filePath(), bookmark->lineNumber())) + return (editor->currentLine() == bookmark->lineNumber()); + return false; } void BookmarkManager::nextInDocument() diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index 0d50a7111e5..cc64f152bf1 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -72,7 +72,12 @@ void BaseTextMark::editorOpened(Core::IEditor *editor) if (m_markableInterface == 0) { // We aren't added to something m_markableInterface = textEditor->markableInterface(); m_internalMark = new InternalMark(this); - m_markableInterface->addMark(m_internalMark, m_line); + + if (!m_markableInterface->addMark(m_internalMark, m_line)) { + delete m_internalMark; + m_internalMark = 0; + m_markableInterface = 0; + } } } } -- GitLab