Qt - Mysterious segfaults on worker thread

2019-07-15 08:26发布

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

2条回答
啃猪蹄的小仙女
2楼-- · 2019-07-15 09:11

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.

查看更多
迷人小祖宗
3楼-- · 2019-07-15 09:12

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.

查看更多
登录 后发表回答