Skip to content
Snippets Groups Projects
Commit fca56390 authored by Pierre Lamot's avatar Pierre Lamot Committed by Steve Lhomme
Browse files

qt: fix race condition when SystemPalette is destroyed

As we don't control the destruction order of QML component, when scene is unloading
SystemPalette may be destroyed before ColorContext item that uses this palette, with
palette change not propagated in time.
parent 62ff2e00
No related branches found
No related tags found
1 merge request!6349qt: fix race condition when SystemPalette is destroyed
Pipeline #536568 failed with stage
in 50 minutes and 3 seconds
......@@ -189,8 +189,7 @@ bool ColorContext::setInheritedPalette(SystemPalette* palette)
return false;
if (m_palette)
{
disconnect(m_palette, &SystemPalette::sourceChanged, this, &ColorContext::colorsChanged);
disconnect(m_palette, &SystemPalette::paletteChanged, this, &ColorContext::colorsChanged);
disconnect(m_palette, nullptr, this, nullptr);
}
m_palette = palette;
......@@ -199,6 +198,17 @@ bool ColorContext::setInheritedPalette(SystemPalette* palette)
{
connect(m_palette, &SystemPalette::sourceChanged, this, &ColorContext::colorsChanged);
connect(m_palette, &SystemPalette::paletteChanged, this, &ColorContext::colorsChanged);
connect(m_palette, &SystemPalette::destroyed, this, [this](){
if (m_parentContext)
{
if (m_hasExplicitPalette)
connect(m_parentContext, &ColorContext::paletteChanged, this, &ColorContext::setInheritedPalette);
setInheritedPalette(m_parentContext->m_palette);
}
else
setInheritedPalette(nullptr);
m_hasExplicitPalette = false;
});
}
else
m_initialized = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment