Skip to content

Commit

Permalink
FX-749: Attempt to mitigiate occasional deadlocks by not initializing…
Browse files Browse the repository at this point in the history
… Qt3d scene in a showEvent call (#40)
  • Loading branch information
marcus-sonestedt authored Nov 13, 2023
1 parent 8444323 commit 56aa8f2
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/cellink/widgets/qt3dwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <Qt3DRender/qcamera.h>
#include <Qt3DRender/qrenderaspect.h>
#include <Qt3DRender/qrendersettings.h>
#include <QtCore/QTimer>
#include <QtGui/private/qwindow_p.h>
#include <QtGui/qevent.h>
#include <QtGui/qopenglcontext.h>
Expand Down Expand Up @@ -260,12 +261,16 @@ Qt3DRender::QRenderSettings* Qt3DWindow::renderSettings() const
void Qt3DWindow::showEvent(QShowEvent* e)
{
Q_D(Qt3DWindow);
if (!d->m_initialized) {
d->m_root->addComponent(d->m_renderSettings);
d->m_root->addComponent(d->m_inputSettings);
d->m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(d->m_root));

if (!d->m_initialized) {
d->m_initialized = true;

// becomes stuck sometimes, maybe because it's inside showEvent?
QTimer::singleShot(0, this, [d]() {
d->m_root->addComponent(d->m_renderSettings);
d->m_root->addComponent(d->m_inputSettings);
d->m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(d->m_root));
});
}

QWindow::showEvent(e);
Expand Down

0 comments on commit 56aa8f2

Please sign in to comment.