mirror of
https://github.com/videolan/vlc.git
synced 2024-11-23 18:03:48 +08:00
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.
This commit is contained in:
parent
62ff2e006c
commit
fca563901c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user