Skip to content

Commit 791da60

Browse files
committed
Use stable_sort to avoid accidentally mis-sorting children
1 parent e9a0322 commit 791da60

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

applications/windowserver/src/components/component.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ void component_t::addChild(component_t* comp, component_child_reference_type_t t
213213

214214
g_mutex_acquire(childrenLock);
215215
children.push_back(reference);
216-
std::sort(children.begin(), children.end(), [](component_child_reference_t& c1, component_child_reference_t& c2)
217-
{
218-
return c1.component->zIndex < c2.component->zIndex;
219-
});
216+
std::stable_sort(children.begin(), children.end(),
217+
[](const component_child_reference_t& c1, const component_child_reference_t& c2)
218+
{
219+
return c1.component->zIndex < c2.component->zIndex;
220+
});
220221
g_mutex_release(childrenLock);
221222

222223
comp->markFor(COMPONENT_REQUIREMENT_ALL);

0 commit comments

Comments
 (0)