summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-05-11 11:39:54 +0300
committerArttu Tarkiainen <arttu.tarkiainen@qt.io>2022-05-17 06:42:39 +0000
commitc37cc0616430f6dfd5ba72430a9ae9e539e2598d (patch)
tree5f71cbec70b642333e757f31b4d2f91e49b9e9f1 /tests
parentd0d848e8849a25b4599e9a7b01093721e1b1a366 (diff)
Workaround QSettings / QDateTime incompatibility with Qt 6 applications
This causes problems when installers created with IFW share config files with Qt 6 applications. If the config file contains keys with QDateTime values written by the other application, the installer and maintenance tool will segfault when attempting to sync the file, even if we do not overwrite the values. This is fixed to recent Qt 5 and 6 versions with the submitted patches to QTBUG-102334. But as this requires updating the baseline Qt version for both the Qt IFW and the Qt 6 application, apply the workaround suggested in the issue comments, to avoid the crash in meantime. Task-number: QTIFW-2610 Change-Id: I968e293324775dc650315e223f549a81657a27a3 Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/installer/clientserver/tst_clientserver.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/auto/installer/clientserver/tst_clientserver.cpp b/tests/auto/installer/clientserver/tst_clientserver.cpp
index bcd87815d..ffd96d14e 100644
--- a/tests/auto/installer/clientserver/tst_clientserver.cpp
+++ b/tests/auto/installer/clientserver/tst_clientserver.cpp
@@ -312,8 +312,17 @@ private slots:
delete object;
}
+ void testQSettingsWrapper_data()
+ {
+ QTest::addColumn<QSettings::Format>("format");
+ QTest::newRow("Native format") << QSettings::NativeFormat;
+ QTest::newRow("INI format") << QSettings::IniFormat;
+ }
+
void testQSettingsWrapper()
{
+ QFETCH(QSettings::Format, format);
+
RemoteServer server;
QString socketName = QUuid::createUuid().toString();
server.init(socketName, QLatin1String("SomeKey"), Protocol::Mode::Production);
@@ -322,14 +331,16 @@ private slots:
RemoteClient::instance().init(socketName, QLatin1String("SomeKey"), Protocol::Mode::Debug,
Protocol::StartAs::User);
- QSettingsWrapper wrapper("digia", "clientserver");
+ QSettingsWrapper wrapper(static_cast<QSettingsWrapper::Format>(format),
+ QSettingsWrapper::UserScope, "digia", "clientserver");
+
QCOMPARE(wrapper.isConnectedToServer(), false);
wrapper.clear();
QCOMPARE(wrapper.isConnectedToServer(), true);
wrapper.sync();
wrapper.setFallbacksEnabled(false);
- QSettings settings("digia", "clientserver");
+ QSettings settings(format, QSettings::UserScope, "digia", "clientserver");
settings.setFallbacksEnabled(false);
QCOMPARE(settings.fileName(), wrapper.fileName());
@@ -358,6 +369,30 @@ private slots:
QCOMPARE(wrapper.contains("key"), false);
QCOMPARE(settings.contains("key"), false);
+ const QDateTime dateTime = QDateTime::currentDateTimeUtc();
+ QCOMPARE(settings.iniCodec(), nullptr);
+ // The wrapper does not support this method, but assume:
+ // QCOMPARE(wrapper.iniCodec(), QTextCodec::codecForName("UTF-8"));
+ wrapper.setValue("dateTime", dateTime);
+ wrapper.sync();
+ QCOMPARE(wrapper.value("dateTime").toDateTime(), dateTime);
+ QCOMPARE(settings.value("dateTime").toDateTime(), dateTime);
+
+ wrapper.remove("dateTime");
+ wrapper.sync();
+ QCOMPARE(wrapper.contains("dateTime"), false);
+ QCOMPARE(settings.contains("dateTime"), false);
+
+ settings.setValue("dateTime", dateTime);
+ settings.sync();
+ QCOMPARE(wrapper.value("dateTime").toDateTime(), dateTime);
+ QCOMPARE(settings.value("dateTime").toDateTime(), dateTime);
+
+ settings.remove("dateTime");
+ settings.sync();
+ QCOMPARE(wrapper.contains("dateTime"), false);
+ QCOMPARE(settings.contains("dateTime"), false);
+
wrapper.beginGroup("group");
wrapper.setValue("key", "value");
wrapper.endGroup();