1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

WindowServer: Remove applets from AppletManager on client disconnection

Disconnecting from WindowServer without explicit calls to DestroyWindow
would leave nulled-out WeakPtr's in the AppletManager applet list.

This led to a null dereference when adding a new applet, since we were
assuming the list contained no nulled-out applets.

This patch fixes the issue by always unregistering applet windows from
the AppletManager in ~ClientConnection(). We also do an extra pass of
pruning any nulled-out WeakPtrs from the applet list when adding to it.

Fixes #1551.
This commit is contained in:
Andreas Kling 2020-03-31 13:52:35 +02:00
parent c54855682c
commit c56c8c8953
2 changed files with 9 additions and 1 deletions

View file

@ -71,6 +71,11 @@ void AppletManager::add_applet(Window& applet)
{
m_applets.append(applet.make_weak_ptr());
// Prune any dead weak pointers from the applet list.
m_applets.remove_all_matching([](auto& entry) {
return entry.is_null();
});
quick_sort(m_applets, [](auto& a, auto& b) {
auto index_a = order_vector.find_first_index(a->title());
auto index_b = order_vector.find_first_index(b->title());