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
(cherry picked from commit 2b46f828b4)
This commit is contained in:
Thorbjørn Lindeijer
2010-01-11 12:47:01 +01:00
committed by con
parent 8243986b9a
commit 94dc99fa64
2 changed files with 10 additions and 6 deletions

View File

@@ -485,12 +485,11 @@ Bookmark *BookmarkManager::bookmarkForIndex(QModelIndex index)
bool BookmarkManager::gotoBookmark(Bookmark* bookmark)
{
if (!TextEditor::BaseTextEditor::openEditorAt(bookmark->filePath(), bookmark->lineNumber())) {
// Could not open editor
using namespace TextEditor;
if (ITextEditor *editor = BaseTextEditor::openEditorAt(bookmark->filePath(), bookmark->lineNumber()))
return (editor->currentLine() == bookmark->lineNumber());
return false;
}
return true;
}
void BookmarkManager::nextInDocument()
{

View File

@@ -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;
}
}
}
}