简体   繁体   中英

QFileDialog freezes on close/destructor (with selected file or cancel)

I'm developing applications in qt with Ubuntu 15.04 and the respective qt pakage 5.4. For some reason, out of nowhere the application would freeze after selecting a file within a QFileDialog (or even cancelling).

I found some similar topics on the web but most were concerned with a now resolved bug in qt 5.1 and (non-)native QFileDialog s.

Then I found out this is related to more than just my own application - even qtcreator would freeze on leaving the QFileDialog , now.

There seems to be a deadlock in the destructor of QFileDialog .

The following snippet is from qsettings.cpp (line 1382), within void QConfFileSettingsPrivate::syncConfFile(int confFileNo)

QLockFile lockFile(confFile->name + QLatin1String(".lock"));
if (!readOnly) {
    if (!confFile->isWritable() || !lockFile.lock() ) {
        setStatus(QSettings::AccessError);
        return;
    }
}

It turns out some other qt application has left a lock file which causes all other applications' QFileDialog destructor to be deadlocked within the above lock call.

I searched for .lock files in my home folder and after deleting ./.config/QtProject.conf.lock and a second file similar to .config/USERNAME/APPTARGETNAME.conf.lock the QFileDialog works well, agian.

I just now can't reproduce which of the two files did cause the deadlock.

Hope this helps anyone in a similar situation!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM