Skip to content

Commit

Permalink
Fix sefgault cause by a concurrent creation of platform windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Sep 29, 2022
1 parent 785fd06 commit c9af1e0
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/skin/legacy/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,22 +1269,29 @@ QWidget* LegacySkinParser::parseSpinny(const QDomElement& node) {
SKIN_WARNING(node, *m_pContext) << "No player found for group:" << group;
return nullptr;
}
WSpinny* spinny = new WSpinny(m_pParent, group, m_pConfig, m_pVCManager, pPlayer);
commonWidgetSetup(node, spinny);
// Note: For some reasons we need to create the widget without a parent to avoid to
// create two platform windows in QWidget::create() for this widget.
// This happens, because the QWidget::create() of a parent() will populate all children
// with platform windows q_createNativeChildrenAndSetParent() while another window is already
// under construction. The ID for the first window is not cleared and leads to a segfault
// during on shutdown
WSpinny* pSpinny = new WSpinny(nullptr, group, m_pConfig, m_pVCManager, pPlayer);
pSpinny->setParent(m_pParent);
commonWidgetSetup(node, pSpinny);

connect(waveformWidgetFactory,
&WaveformWidgetFactory::renderSpinnies,
spinny,
pSpinny,
&WSpinny::render);
connect(waveformWidgetFactory, &WaveformWidgetFactory::swapSpinnies, spinny, &WSpinny::swap);
connect(spinny, &WSpinny::trackDropped, m_pPlayerManager, &PlayerManager::slotLoadToPlayer);
connect(spinny, &WSpinny::cloneDeck, m_pPlayerManager, &PlayerManager::slotCloneDeck);
connect(waveformWidgetFactory, &WaveformWidgetFactory::swapSpinnies, pSpinny, &WSpinny::swap);
connect(pSpinny, &WSpinny::trackDropped, m_pPlayerManager, &PlayerManager::slotLoadToPlayer);
connect(pSpinny, &WSpinny::cloneDeck, m_pPlayerManager, &PlayerManager::slotCloneDeck);

spinny->setup(node, *m_pContext);
spinny->installEventFilter(m_pKeyboard);
spinny->installEventFilter(m_pControllerManager->getControllerLearningEventFilter());
spinny->Init();
return spinny;
pSpinny->setup(node, *m_pContext);
pSpinny->installEventFilter(m_pKeyboard);
pSpinny->installEventFilter(m_pControllerManager->getControllerLearningEventFilter());
pSpinny->Init();
return pSpinny;
}

QWidget* LegacySkinParser::parseVuMeter(const QDomElement& node) {
Expand Down Expand Up @@ -1312,7 +1319,14 @@ QWidget* LegacySkinParser::parseVuMeter(const QDomElement& node) {
dummy->setText(tr("No OpenGL\nsupport."));
return dummy;
}
WVuMeterGL* pVuMeterWidget = new WVuMeterGL(m_pParent);
// Note: For some reasons we need to create the widget without a parent to avoid to
// create two platform windows in QWidget::create() for this widget.
// This happens, because the QWidget::create() of a parent() will populate all children
// with platform windows q_createNativeChildrenAndSetParent() while another window is already
// under construction. The ID for the first window is not cleared and leads to a segfault
// during on shutdown
WVuMeterGL* pVuMeterWidget = new WVuMeterGL();
pVuMeterWidget->setParent(m_pParent);
commonWidgetSetup(node, pVuMeterWidget);

waveformWidgetFactory->addVuMeter(pVuMeterWidget);
Expand Down

0 comments on commit c9af1e0

Please sign in to comment.