Qt - Mysterious segfaults on worker thread

痞子三分冷 提交于 2019-12-11 03:19:53

问题


I'm instantiating QSystemDeviceInfo on a worker thread, but it causes a segfault.

int BatteryInfo::getLevel() {
   QSystemDeviceInfo sysDevInfo; //segfault happens when I step on to this line
   return sysDevInfo.batteryLevel();
}

Is the class thread-safe, or does the problem lie elsewhere?

EDIT: With further debugging I also noticed that native Symbian calls segfault as well.

Best regards


回答1:


Me and my friend found this issue as well on Symbian Qt Mobilty 1.0. He reported an issue QtMobility access from multiple threads. As it says in the issue description Think this could be due to that some static members are created first time the QSystemDeviceInfo/QSystemNetworkInfo is created..

If you are using Qt Mobility 1.2 or only accessing QSystemDeviceInfo from one thread it's some other issue.

EDIT: One workaround for us was to make sure we created a QSystemDeviceInfo object in our main thread first but then we had some problems with not getting all signals.




回答2:


Do you have capabilities set ? QSystemDeviceInfo needs the 'ReadDeviceData' capability.You will need to sign your app to install on the device if you include this capability.



来源:https://stackoverflow.com/questions/6841611/qt-mysterious-segfaults-on-worker-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!