diff --git a/bcmainwindow.cpp b/bcmainwindow.cpp index 356effa..fefc18c 100644 --- a/bcmainwindow.cpp +++ b/bcmainwindow.cpp @@ -318,11 +318,14 @@ void BCMainWindow::onSyncDeviceView() for( const BCValuePtr& value : currentList ) { - qDebug() << " --- begin sync of value: " << value->label; + qDebug() << " --- begin sync of value: " << QThread::currentThreadId() << " : " << value->label; // wir setzen auf 'lesen' value->state.setFlag( BCValue::State::ReadMe ); - // statt '_transmitter.onEnqueueValueCommand( value )' entkoppeln - // wir das eleganter über emit requestValueUpdate() + + // statt '_transmitter.onEnqueueValue( value )' müssen wir hier + // über emit requestValueUpdate() zur Thread sysnchronisation + // entkoppeln, + emit requestValueUpdate( value); } diff --git a/bctransmitter.cpp b/bctransmitter.cpp index b3533db..f1db6f8 100644 --- a/bctransmitter.cpp +++ b/bctransmitter.cpp @@ -122,6 +122,12 @@ void BCTransmitter::disconnectCanDriver() void BCTransmitter::onEnqueueValue( BCValuePtrConst value) { + + // wir stellen hier auf die arte Tour sicher, das onEnqueueValue + // nicht aus dem Parent-Thread direkt sondern über die EventQueue aufgerufen wurde. + + Q_ASSERT(QThread::currentThread() == this->thread()); + // Hier sind wir noch in GUI Thread //QMutexLocker locker(&_mutex); _valueQueue.enqueue( value ); @@ -134,21 +140,15 @@ void BCTransmitter::onEnqueueValue( BCValuePtrConst value) // invokeMethod mit QueuedConnection entkoppelt den Aufruf, // damit onEnqueueValue sofort zurückkehrt (non-blocking für den Aufrufer). - QMetaObject::invokeMethod(this, "onProcessValue", Qt::QueuedConnection); - - /* - QMetaObject::invokeMethod(this, [this]() - { - onProcessValue(); - }, Qt::QueuedConnection ); - */ + //QMetaObject::invokeMethod(this, "onProcessValue", Qt::QueuedConnection); + onProcessValue(); } void BCTransmitter::onProcessValue() { - if (_isBusy) - return; + //if (_isBusy) + // return; _isBusy = true; @@ -168,6 +168,8 @@ void BCTransmitter::onProcessValue() // Kosmetik const BCValue& value = *(valuePtr.get()); + qDebug() << "------- DE.-.QUEUE: " << QThread::currentThreadId() << ": " << value.label; + // Value ist 'under construction' //emit valueUpdated( value.deviceID, value.indexRow, BCValue::State::Locked ); @@ -204,10 +206,9 @@ void BCTransmitter::onProcessValue() emit valueUpdated( value.deviceID, value.indexRow, newState, newVisibleValue ); // __fix - bc::processEventsFor(50); + //bc::processEventsFor(150); + bc::delay_millis(150); - //emit valueStateChanged(cmd.id, true); - //emit valueStateChanged(0, true); } }