5
Tôi đã phát hiện ra rằng ngay cả việc chờ đợi đơn giản trên QMutex cũng sẽ gây ra xác nhận. Tôi có thể làm gì sai?Đang chờ QMutex khẳng định
QMutex mutex;
SyncMgr::SyncMgr(QObject *parent) : QObject(parent)
{
moveToThread(&thread );
thread.start();
process = new QProcess(this);
connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput()));
connect(process, SIGNAL(readyReadStandardError()), this, SLOT(onReadyReadStandardError()));
}
SyncMgr::~SyncMgr()
{
delete process;
}
void SyncMgr::onConnected()
{
cmdDispatcher.sendGetSerialNo();
// this asserts
waitForResponse.wait(&mutex); // waitForResponse is CWaitCondition object
// ...
}
tôi nhận được khẳng định và được thông báo lỗi là:
ASSERT: 'bản sao' trong thread \ qmutex.cpp, dòng 525
này có thể phải làm với 'chế độ đệ quy' cho QMutest. Bạn có đặt RecursionMode thành Recursive khi tạo mutex không? – AlexanderVX
mutex nên là một thành viên lớp học, và bạn cần phải khóa nó (sử dụng QMutexLocker) trước khi gọi wait(). Không chắc chắn nếu đó là liên quan đến việc khẳng định mặc dù. –
@AlexanderVX Tôi đã thử cả hai và không có gì thay đổi. – zar