From 7db269acb588f4311f927115f2b5f6973fbd871b Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 19:15:45 +0800 Subject: [PATCH] Fixes for Windows 1. On Windows, the lmdb file is immediately allocated at full size. So we have to limit the size. 2. Windows need an organization name for QSettings to work. So an organization name is added for Windows target. --- core/archive.cpp | 10 +++++++++- core/main.cpp | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/archive.cpp b/core/archive.cpp index 2582ff9..c67f228 100644 --- a/core/archive.cpp +++ b/core/archive.cpp @@ -58,7 +58,15 @@ void Core::Archive::open(const QString& account) } mdb_env_set_maxdbs(environment, 5); - mdb_env_set_mapsize(environment, 512UL * 1024UL * 1024UL); + mdb_env_set_mapsize(environment, +#ifdef Q_OS_WIN + // On Windows, the file is immediately allocated. + // So we have to limit the size. + 80UL * 1024UL * 1024UL +#else + 512UL * 1024UL * 1024UL +#endif + ); mdb_env_open(environment, path.toStdString().c_str(), 0, 0664); MDB_txn *txn; diff --git a/core/main.cpp b/core/main.cpp index 0be020e..f63d4f8 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -42,7 +42,16 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); SignalCatcher sc(&app); - +#ifdef Q_OS_WIN + // Windows need an organization name for QSettings to work + // https://doc.qt.io/qt-5/qsettings.html#basic-usage + { + const QString& orgName = QApplication::organizationName(); + if (orgName.isNull() || orgName.isEmpty()) { + QApplication::setOrganizationName("squawk"); + } + } +#endif QApplication::setApplicationName("squawk"); QApplication::setApplicationDisplayName("Squawk"); QApplication::setApplicationVersion("0.1.5"); -- 2.44.0