diff --git a/lib/database_model.cpp b/lib/database_model.cpp index 5933ad33..6c94eddb 100644 --- a/lib/database_model.cpp +++ b/lib/database_model.cpp @@ -422,13 +422,9 @@ void database_model::as_default_database(const QString &db) } if (file.open(QIODevice::ReadWrite)) { - QByteArray ba; - if (isRemoteDB(db)) - ba = filename2bytearray(db); - else - ba = filename2bytearray(relativePath(db)); - ba += '\n'; - file.write(ba); + QByteArray ba = isRemoteDB(db) ? + db.toUtf8() : relativePath(db).toUtf8(); + file.write(ba + '\n'); /* write() failed? Harmless. Only inconvenient */ } file.close(); diff --git a/lib/dbhistory.cpp b/lib/dbhistory.cpp index 70b49f8e..d2bec188 100644 --- a/lib/dbhistory.cpp +++ b/lib/dbhistory.cpp @@ -33,7 +33,7 @@ dbhistory::dbhistory() ssize_t size = file.readLine(buf, sizeof buf); if (size <= 0) break; - name = filename2QString(buf).trimmed(); + name = QString::fromUtf8(buf).trimmed(); if (name.size() == 0) continue; if (history.indexOf(name) == -1) @@ -72,12 +72,10 @@ void dbhistory::addEntry(const QString &name) if (!file.open_write()) return; - for (pos = 0; pos < history.size(); pos++) { - QByteArray ba = filename2bytearray(history[pos]); - ba.append('\n'); - if (file.write(ba) <= 0) - break; - } + QString all = history.join("\n"); + if (file.write(all.toUtf8()) <= 0) + qDebug() << "Error writing history" << file.fileName() + << file.errorString(); file.close(); }