From 851e19ce01d7f7125006c403d45434f53a32cccd Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 13 Feb 2014 16:35:52 +0100 Subject: [PATCH] [Bookmarks] Fixed assert when migrating bookmarks Assert when user had bookmark with folder that doesn't exists Also save bookmarks as soon as they are migrated Closes #1213 --- src/lib/bookmarks/bookmarks.cpp | 7 ++++++- src/lib/bookmarks/bookmarkstools.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/bookmarks/bookmarks.cpp b/src/lib/bookmarks/bookmarks.cpp index e0b9681d2..97c18b437 100644 --- a/src/lib/bookmarks/bookmarks.cpp +++ b/src/lib/bookmarks/bookmarks.cpp @@ -262,7 +262,12 @@ void Bookmarks::init() m_folderUnsorted->setTitle(tr("Unsorted Bookmarks")); m_folderUnsorted->setDescription(tr("All other bookmarks")); - if (!BookmarksTools::migrateBookmarksIfNecessary(this)) { + if (BookmarksTools::migrateBookmarksIfNecessary(this)) { + // Bookmarks migrated just now, let's save them ASAP + saveBookmarks(); + } + else { + // Bookmarks don't need to be migrated, just load them as usual loadBookmarks(); } diff --git a/src/lib/bookmarks/bookmarkstools.cpp b/src/lib/bookmarks/bookmarkstools.cpp index 1906652ef..b6721a9cd 100644 --- a/src/lib/bookmarks/bookmarkstools.cpp +++ b/src/lib/bookmarks/bookmarkstools.cpp @@ -376,7 +376,7 @@ bool BookmarksTools::migrateBookmarksIfNecessary(Bookmarks* bookmarks) const QUrl url = query.value(2).toUrl(); BookmarkItem* parent = folders.value(folder); - if (folder.isEmpty()) { + if (!parent) { parent = bookmarks->unsortedFolder(); } Q_ASSERT(parent);