From 661f4897b297fb529ec372ec14f42696ccdacb94 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 20 Oct 2020 09:50:27 -0300 Subject: [PATCH] Check that we're in the UI thread when modifying the widgets collection --- src/ui/intern.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ui/intern.cpp b/src/ui/intern.cpp index 75f3e94aa..96d490d61 100644 --- a/src/ui/intern.cpp +++ b/src/ui/intern.cpp @@ -1,4 +1,5 @@ // Aseprite UI Library +// Copyright (C) 2020 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -9,6 +10,7 @@ #endif #include "ui/manager.h" +#include "ui/system.h" #include "ui/theme.h" #include "ui/widget.h" #include "ui/window.h" @@ -22,21 +24,29 @@ static std::list* widgets; void initWidgets() { + assert_ui_thread(); + widgets = new std::list; } void exitWidgets() { + assert_ui_thread(); + delete widgets; } void addWidget(Widget* widget) { + assert_ui_thread(); + widgets->push_back(widget); } void removeWidget(Widget* widget) { + assert_ui_thread(); + ASSERT(!Manager::widgetAssociatedToManager(widget)); auto it = std::find(widgets->begin(), widgets->end(), widget); @@ -46,6 +56,8 @@ void removeWidget(Widget* widget) void reinitThemeForAllWidgets() { + assert_ui_thread(); + // Reinitialize the theme of each widget auto theme = get_theme(); for (auto widget : *widgets)