简体   繁体   English

QFileDialog在关闭/析构函数上冻结(带有选定文件或取消)

[英]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. 我正在使用Ubuntu 15.04和相应的qt pakage 5.4在qt中开发应用程序。 For some reason, out of nowhere the application would freeze after selecting a file within a QFileDialog (or even cancelling). 由于某种原因,在QFileDialog选择一个文件后(甚至取消),应用程序将无处死机。

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. 我在网络上找到了一些类似的主题,但是大多数都与qt 5.1和(非)本地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. 然后,我发现这不仅与我自己的应用程序有关-甚至qtcreator现在离开QFileDialog也会冻结。

There seems to be a deadlock in the destructor of QFileDialog . QFileDialog的析构函数中似乎存在死锁。

The following snippet is from qsettings.cpp (line 1382), within void QConfFileSettingsPrivate::syncConfFile(int confFileNo) 以下代码段来自qsettings.cpp (第1382行),位于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. 事实证明,其他一些qt应用程序留下了一个锁定文件,这导致所有其他应用程序的QFileDialog析构函数在上述lock调用中被死锁。

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. 我搜索了我的主文件夹中的.lock文件,并删除了./.config/QtProject.conf.lock和第二个类似于.config/USERNAME/APPTARGETNAME.conf.lock的文件后,QFileDialog很好用了。

I just now can't reproduce which of the two files did cause the deadlock. 我现在无法重现两个文件中的哪个确实导致了死锁。

Hope this helps anyone in a similar situation! 希望这对遇到类似情况的人有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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