Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-27 05:16:13 +0300
committerCampbell Barton <campbell@blender.org>2022-08-27 05:28:18 +0300
commit578dff786362ba0d1426d1d3d15d579886c0f4fd (patch)
tree595d3c484ca859504903717cb1bc7c731af532ee /source/blender/windowmanager
parent955032ffb0c5ca671b24d04bd45cc0f6604d66c6 (diff)
Fix assertion when notifiers weren't removed from the notifier queue set
Since [0] notifiers were cleared and left in the queue, while harmless it meant the call to remove the notifier from the set was redundant. Now set aside a category to tag notifiers as having been cleared and skip them entirely. [0]: 0aaff9a07d3bdf8588cef15d502aeb4fdab22e5e
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_types.h1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.cc14
2 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 9d9e0fe8fee..6526b7bec0e 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -321,6 +321,7 @@ typedef struct wmNotifier {
/* category */
#define NOTE_CATEGORY 0xFF000000
+#define NOTE_CATEGORY_TAG_CLEARED NOTE_CATEGORY
#define NC_WM (1 << 24)
#define NC_WINDOW (2 << 24)
#define NC_WORKSPACE (3 << 24)
diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc
index d6368e73f5a..9cb5194a73b 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -91,6 +91,7 @@
#define USE_GIZMO_MOUSE_PRIORITY_HACK
static void wm_notifier_clear(wmNotifier *note);
+static bool wm_notifier_is_clear(const wmNotifier *note);
static int wm_operator_call_internal(bContext *C,
wmOperatorType *ot,
@@ -287,9 +288,10 @@ void WM_event_add_notifier_ex(wmWindowManager *wm, const wmWindow *win, uint typ
note_test.data = type & NOTE_DATA;
note_test.subtype = type & NOTE_SUBTYPE;
note_test.action = type & NOTE_ACTION;
-
note_test.reference = reference;
+ BLI_assert(!wm_notifier_is_clear(&note_test));
+
if (wm->notifier_queue_set == nullptr) {
wm->notifier_queue_set = BLI_gset_new_ex(
note_hash_for_queue_fn, note_cmp_for_queue_fn, __func__, 1024);
@@ -385,6 +387,12 @@ static void wm_notifier_clear(wmNotifier *note)
{
/* nullptr the entire notifier, only leaving (`next`, `prev`) members intact. */
memset(((char *)note) + sizeof(Link), 0, sizeof(*note) - sizeof(Link));
+ note->category = NOTE_CATEGORY_TAG_CLEARED;
+}
+
+static bool wm_notifier_is_clear(const wmNotifier *note)
+{
+ return note->category == NOTE_CATEGORY_TAG_CLEARED;
}
void wm_event_do_depsgraph(bContext *C, bool is_after_open_file)
@@ -578,6 +586,10 @@ void wm_event_do_notifiers(bContext *C)
/* The notifiers are sent without context, to keep it clean. */
wmNotifier *note;
while ((note = static_cast<wmNotifier *>(BLI_pophead(&wm->notifier_queue)))) {
+ if (wm_notifier_is_clear(note)) {
+ MEM_freeN(note);
+ continue;
+ }
const bool removed = BLI_gset_remove(wm->notifier_queue_set, note, nullptr);
BLI_assert(removed);
UNUSED_VARS_NDEBUG(removed);