summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/application.cpp14
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp8
2 files changed, 17 insertions, 5 deletions
diff --git a/src/application.cpp b/src/application.cpp
index efc1c2af..910e0bb5 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -102,7 +102,7 @@ struct BookmarksModelPrivate {
BookmarksModelPrivate()
{
model = new BookmarkModel;
- const auto path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/bookmarks.xbel";
+ const auto path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/bookmarks.xbel";
spdlog::debug("Loading bookmarks from {}", qUtf8Printable(path));
QFile f(path);
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -110,7 +110,17 @@ struct BookmarksModelPrivate {
f.close();
}
}
- ~BookmarksModelPrivate() noexcept { delete model; }
+ ~BookmarksModelPrivate() noexcept
+ {
+ const auto path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/bookmarks.xbel";
+ spdlog::debug("Storing bookmarks in {}", qUtf8Printable(path));
+ QFile f(path);
+ if (f.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ model->save(&f);
+ f.close();
+ }
+ delete model;
+ }
BookmarkModel *model;
};
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index 8086ff64..a4f322b8 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -193,7 +193,8 @@ QMimeData *BookmarkModel::mimeData(const QModelIndexList &indexes) const
for (const QModelIndex &index : indexes) {
if (index.isValid() && index.column() == 0) items.append(item(index));
}
- xbel::write(&buffer, items);
+ const auto write_result = xbel::write(&buffer, items);
+ Q_ASSERT(write_result == false);
auto *mimeData = new QMimeData;
mimeData->setData(mimeType, data);
@@ -212,7 +213,8 @@ bool BookmarkModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction actio
buffer.open(QIODevice::ReadOnly | QIODevice::Text);
auto *fake_root = new BookmarksTreeItem(BookmarksTreeItem::Root, {}, nullptr);
- xbel::read(&buffer, fake_root);
+ const auto read_result = xbel::read(&buffer, fake_root);
+ Q_ASSERT(read_result.isEmpty());
const auto childCount = static_cast<int>(fake_root->childCount());
auto *parentItem = item(parent);
@@ -232,5 +234,5 @@ QList<QString> BookmarkModel::load(QIODevice *buffer) { return readFns[Formats::
void BookmarkModel::save(QIODevice *buffer)
{
if (!buffer->isOpen() || !buffer->isWritable()) return;
- if (m_isModified) m_isModified = !writeFns[Formats::FormatXbel](buffer, {rootItem});
+ m_isModified = !writeFns[Formats::FormatXbel](buffer, {rootItem});
}