Debug assertion fails on debug build of Geant4 when /run/beamOn 10
returns (using example B1) with TBB multithreading with Qt 5.15.2 vs2022.
Console output:
ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 0x0x1a811d51ec0. Receiver '' (of type 'QGLWidget') was created in thread 0x0x1a879c26ff0", file kernel\qcoreapplication.cpp, line 558
Debug stack trace:
The assertion happens in G4OpenGLStoredQtViewer::updateQWidget()
's repaint()
call, which eventually calls the check function:
void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver)
{
QThread *currentThread = QThread::currentThread();
QThread *thr = receiver->thread();
Q_ASSERT_X(currentThread == thr || !thr,
"QCoreApplication::sendEvent",
QString::asprintf("Cannot send events to objects owned by a different thread. "
"Current thread 0x%p. Receiver '%ls' (of type '%s') was created in thread 0x%p",
currentThread, qUtf16Printable(receiver->objectName()),
receiver->metaObject()->className(), thr)
.toLocal8Bit().data());
Q_UNUSED(currentThread);
Q_UNUSED(thr);
}
The assertion is only present in debug mode, since QtGlobal
header gives:
#if !defined(Q_ASSERT_X)
# if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS)
# define Q_ASSERT_X(cond, where, what) static_cast<void>(false && (cond))
# else
# define Q_ASSERT_X(cond, where, what) ((cond) ? static_cast<void>(0) : qt_assert_x(where, what, __FILE__, __LINE__))
# endif
#endif
Release mode Qt binary skips the check and works.