Qt 跨线程初始化变量,程序奔溃(Error - RtlWerpReportException failed with status code :-1073741823.)

版权声明:本文为博主原创文章,未经博主允许不得转载。如需转载,请私信博主。 https://blog.csdn.net/TurboIan/article/details/71600678

出现使用了未使用的内存问题,一般是弹出以下窗口:
这里写图片描述
以及输出窗口会显示以下内容:

Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly
Error - Failed to create the process C:\Windows\system32\WerFault.exe
Error - StartCrashVertial failed

首先可以明确出现该问题的原因是使用了未初始化的指针,应该要查找在哪里使用了野指针,然后解决即可。

而比较麻烦的情况是跨线程初始化变量问题,利用信号槽对另一个线程的变量进行初始化,而紧接着又对其进行connect,由于线程执行顺序问题,如果一个对象未被初始化而被connect,一般调试下会跳进qobject中报错,并且在报错中可以看到是关于connect的。

解决办法:

通过信号槽在A线程中对B线程的变量初始化时,在connect函数的第5个参数使用Qt::BlockingQuequeConnection

猜你喜欢

转载自blog.csdn.net/TurboIan/article/details/71600678