• 5417阅读
  • 0回复

请问QSound线程安全吗? [复制链接]

上一主题 下一主题
离线cspp
 

只看楼主 倒序阅读 楼主  发表于: 2009-11-06
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
Win32+Qt332

我一个子线程中调用了QSound用来播放声音,
发现在个别情况下会发现有问题
具体在如下代码时线程死掉了
void MProcess::resetSound
{
    if( sound != NULL)
    {
        sound->stop();
        delete sound;
        sound = NULL;
    }
}

其中sound是一个QSound对象,
在其他地方初始化

void MProcess::PlaySound()
{
    resetSound();
    sound = new QSound(fileName);
    sound->setLoops(3000);
    sound->play();
}

其中PlaySound会被我期中的一个子线程调用,但通过打印语句跟踪,
发现该子线程在调用resetSound()中的sound->stop()后函数没有退出。
导致我的线程堵塞。

不知道有谁知道?
快速回复
限100 字节
 
上一个 下一个