Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d72ce237 authored by Sihua Ma's avatar Sihua Ma
Browse files

Fix ConcurrentModificationException in QuickstepWidgetHolder

If the listeners would modify the listener list in the widget holder, this would cause a ConcurrentModificationException.

Fix: 275100497
Test: N/A
Change-Id: I3ae0e92db71f1c21d35dbf391dfcb92b46dd30f1
parent 71d05f96
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -95,7 +95,11 @@ public final class QuickstepWidgetHolder extends LauncherWidgetHolder {
                    i -> MAIN_EXECUTOR.execute(() ->
                            sHolders.forEach(h -> h.mAppWidgetRemovedCallback.accept(i))),
                    () -> MAIN_EXECUTOR.execute(() ->
                            sHolders.forEach(h -> h.mProviderChangedListeners.forEach(
                            sHolders.forEach(h ->
                                    // Listeners might remove themselves from the list during the
                                    // iteration. Creating a copy of the list to avoid exceptions
                                    // for concurrent modification.
                                    new ArrayList<>(h.mProviderChangedListeners).forEach(
                                    ProviderChangedListener::notifyWidgetProvidersChanged))),
                    UI_HELPER_EXECUTOR.getLooper());
            if (!WidgetsModel.GO_DISABLE_WIDGETS) {