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 <ideasman42@gmail.com>2021-03-02 09:02:57 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-02 09:02:57 +0300
commitae96db0cf5576a2995132e6478dbb3508c02e58f (patch)
treec80ea801e08f0c75e7c751152b718c17483f1269
parentf8415261a6d37b219aaeab24f8ed67456f22ede8 (diff)
WM: log errors when wmWindow.eventstate values are invalid
Ensure they're working as documented (only for debug builds).
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 4928bd5187d..a1a9c24d178 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4458,6 +4458,22 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
event = *evt;
event.is_repeat = false;
+ /* Ensure the event state is correct, any deviation from this may cause bugs. */
+#ifndef NDEBUG
+ if ((evt->type || evt->val) && /* Ignore cleared event state. */
+ !(ISMOUSE_BUTTON(evt->type) || ISKEYBOARD(evt->type))) {
+ CLOG_WARN(WM_LOG_HANDLERS,
+ "Non-keyboard/mouse button found in 'win->eventstate->type = %d'",
+ evt->type);
+ }
+ if ((evt->prevtype || evt->prevval) && /* Ignore cleared event state. */
+ !(ISMOUSE_BUTTON(evt->prevtype) || ISKEYBOARD(evt->prevtype))) {
+ CLOG_WARN(WM_LOG_HANDLERS,
+ "Non-keyboard/mouse button found in 'win->eventstate->prevtype = %d'",
+ evt->prevtype);
+ }
+#endif
+
switch (type) {
/* Mouse move, also to inactive window (X11 does this). */
case GHOST_kEventCursorMove: {