其他分享
首页 > 其他分享> > Qt自作聪明对QMutex初始化导致出现问题this application has requested the runtime to terminate it in an unusual way

Qt自作聪明对QMutex初始化导致出现问题this application has requested the runtime to terminate it in an unusual way

作者:互联网

我在Linux下编写好的程序编译运行都没有问题,但是关掉程序后会在Application Output里提示The program has unexpectedly finished.以为是一些内存没有释放的小问题,没有管它。当把程序放到windows下后编译没有问题,但是运行起来就提示this application has requested the runtime to terminate it in an unusual way,我以为是Qt安装时的一些配置问题,试了三个版本的qt,浪费了很多时间!最后发现仅仅是因为我在主窗口构造函数里自作聪明的加了一句mutexlock.unlock(),想对锁初始化一下,没想到会导致程序无法启动的问题,关键是在Linux地下能启动!当我去掉mutexlock.unlock()后,Linux地下关掉程序后的提示The program has unexpectedly finished.没有了!windows底下也正常了!

教训,没有问题就不要去找问题,想法要尽可能地简单!因为你的担忧和多虑很可能会导致其它问题!只有当出现了问题才去解决问题!比如我发现我那个锁根本没必要用!我把它去掉也正常!我那个锁是保护一个list,这个list在一个试件里读头部,在另一个试件里写尾部!经实验,不加锁也行!

标签:requested,Qt,terminate,程序,问题,list,program,Linux
来源: https://blog.csdn.net/lovemytime/article/details/122621269