Skip to content

Commit ca34920

Browse files
v-einhoffstadt
authored andcommitted
fix (mvThemeComponent): Preventing theme component from holding refs to other unrelated components and thus hindering their deletion.
Also, std::move in push_theme_components makes things a bit more efficient.
1 parent 79fdb17 commit ca34920

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/mvThemes.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ void mvTheme::push_theme_components()
7171
{
7272
if (_specificEnabled == comp->_specificEnabled)
7373
{
74-
comp->_oldComponent = *comp->_specificComponentPtr;
74+
comp->_oldComponent = std::move(*comp->_specificComponentPtr);
7575
*comp->_specificComponentPtr = *(std::shared_ptr<mvThemeComponent>*) & child;
7676
}
7777
else
7878
{
79-
comp->_oldComponent = *comp->_specificDisabledComponentPtr;
79+
comp->_oldComponent = std::move(*comp->_specificDisabledComponentPtr);
8080
*comp->_specificDisabledComponentPtr = *(std::shared_ptr<mvThemeComponent>*) & child;
8181
}
8282
}
@@ -100,11 +100,13 @@ void mvTheme::pop_theme_components()
100100
{
101101
if (_specificEnabled == comp->_specificEnabled)
102102
{
103-
*comp->_specificComponentPtr = comp->_oldComponent;
103+
// Nullifying comp->_oldComponent to avoid mvThemeComponent
104+
// hanging around even after being deleted from the widget tree.
105+
*comp->_specificComponentPtr = std::move(comp->_oldComponent);
104106
}
105107
else
106108
{
107-
*comp->_specificDisabledComponentPtr = comp->_oldComponent;
109+
*comp->_specificDisabledComponentPtr = std::move(comp->_oldComponent);
108110
}
109111

110112
}

0 commit comments

Comments
 (0)