Details
Description
My application uses QSettings to store periodically (every ~100 msec) some values to *.ini files. Also, my application starts automatically on embedded board by some init scripts after the system reboot (always starts with root rights). But, sometimes, when the system reboots on a power, then the application hangs within ~20-30 seconds.
I use following code:
#include <QCoreApplication> #include <QSettings> #include <QTimer> #include <QDebug> #include <QDateTime> const char kParameterKey[] = "Parameter"; const int kTimerInterval = 100; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qDebug() << "Current date" << QDateTime::currentDateTime(); // has been added const QString inifile = qApp->applicationDirPath() + QLatin1String("/settings-bug.ini"); QSettings settings(inifile, QSettings::IniFormat); auto parameter = settings.value(QLatin1String(kParameterKey)).toInt(); QTimer timer; QCoreApplication::connect(&timer, &QTimer::timeout, [&settings, ¶meter]() { ++parameter; settings.setValue(QLatin1String(kParameterKey), parameter); qDebug() << "Update" << parameter; }); timer.start(kTimerInterval); return a.exec(); }
I see, that after almost of every rebooting, the QSettings creates a set of new 'lock' files, like:
settings-bug.ini.lock settings-bug.ini.UVd200 settings-bug.ini.FVs201 ... settings-bug.ini.yJH201When no any hangs occurred, I see following output:
Update 136 QLockFile: Lock file '/home/root/settings-bug.ini.lock' has a modification time in the future Update 137 Update 138 ... Update 142 Update 143
But, when hangs occurred, I see following output:
Update 143 <here hangs on 20-30 second> Update 144 Update 145 ...
As I understand, this 'hang' comes from QLockFile which is uses inside of QSettings, and this 20-30 seconds is "default locking timeout" (yes?). But QSettings does not provide an API to control this 'locking timeout'.
PS: I have attached the source project example.
Attachments
Issue Links
- replaces
-
QTBUG-48627 QSerialPort hangs after restart
-
- Closed
-