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]: 0aaff9a07d
This commit is contained in:
parent
955032ffb0
commit
578dff7863
|
@ -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)
|
||||
|
|
|
@ -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(¬e_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);
|
||||
|
|
Loading…
Reference in New Issue