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>2017-08-24 17:03:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-24 17:20:14 +0300
commit1b5a690c721e257f4d2b6b0df3ad87c011af121e (patch)
tree51baccb732a82d886b2562f34a427d8123731790 /source/blender/windowmanager/manipulators
parent33f9b6d0163f72945c3889c6e5ccb75d22a68113 (diff)
Fix crash handling manipulator events before drawing
Diffstat (limited to 'source/blender/windowmanager/manipulators')
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_types.h11
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c9
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h1
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c8
4 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index 82bf556ce20..23c0fa305a9 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -97,6 +97,15 @@ typedef enum eWM_ManipulatorGroupTypeFlag {
WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5),
} eWM_ManipulatorGroupTypeFlag;
+
+/**
+ * #wmManipulatorGroup.init_flag
+ */
+typedef enum eWM_ManipulatorGroupInitFlag {
+ /* mgroup has been initialized */
+ WM_MANIPULATORGROUP_INIT_SETUP = (1 << 0),
+} eWM_ManipulatorGroupInitFlag;
+
/**
* #wmManipulatorMapType.type_update_flag
* Manipulator-map type update flag
@@ -362,7 +371,7 @@ typedef struct wmManipulatorGroup {
void *customdata;
void (*customdata_free)(void *); /* for freeing customdata from above */
- int init_flag; /* private (C source only) */
+ eWM_ManipulatorGroupInitFlag init_flag;
} wmManipulatorGroup;
/* -------------------------------------------------------------------- */
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
index 808051560bc..94064c84701 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_group.c
@@ -66,11 +66,6 @@
*
* \{ */
-/* wmManipulatorGroup.flag */
-enum {
- WM_MANIPULATORGROUP_INITIALIZED = (1 << 2), /* mgroup has been initialized */
-};
-
/**
* Create a new manipulator-group from \a wgt.
*/
@@ -179,7 +174,7 @@ void wm_manipulatorgroup_intersectable_manipulators_to_list(const wmManipulatorG
void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bContext *C)
{
/* prepare for first draw */
- if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INITIALIZED) == 0)) {
+ if (UNLIKELY((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0)) {
mgroup->type->setup(C, mgroup);
/* Not ideal, initialize keymap here, needed for RNA runtime generated manipulators. */
@@ -190,7 +185,7 @@ void wm_manipulatorgroup_ensure_initialized(wmManipulatorGroup *mgroup, const bC
BLI_assert(wgt->keymap != NULL);
}
- mgroup->init_flag |= WM_MANIPULATORGROUP_INITIALIZED;
+ mgroup->init_flag |= WM_MANIPULATORGROUP_INIT_SETUP;
}
}
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
index 06578fee555..8682ec4e390 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
@@ -75,6 +75,7 @@ struct wmManipulator *wm_manipulatorgroup_find_intersected_mainpulator(
void wm_manipulatorgroup_intersectable_manipulators_to_list(
const struct wmManipulatorGroup *mgroup, struct ListBase *listbase);
void wm_manipulatorgroup_ensure_initialized(struct wmManipulatorGroup *mgroup, const struct bContext *C);
+bool wm_manipulatorgroup_is_initialized(const wmManipulatorGroup *mgroup);
bool wm_manipulatorgroup_is_visible(const struct wmManipulatorGroup *mgroup, const struct bContext *C);
bool wm_manipulatorgroup_is_visible_in_drawstep(
const struct wmManipulatorGroup *mgroup, const eWM_ManipulatorMapDrawStep drawstep);
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
index 9155c03db2a..cece24df85f 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
@@ -560,6 +560,14 @@ wmManipulator *wm_manipulatormap_highlight_find(
ListBase visible_3d_manipulators = {NULL};
for (wmManipulatorGroup *mgroup = mmap->groups.first; mgroup; mgroup = mgroup->next) {
+
+ /* If it were important we could initialize here,
+ * but this only happens when events are handled before drawing,
+ * just skip to keep code-path for initializing manipulators simple. */
+ if ((mgroup->init_flag & WM_MANIPULATORGROUP_INIT_SETUP) == 0) {
+ continue;
+ }
+
if (wm_manipulatorgroup_is_visible(mgroup, C)) {
if (mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) {
if ((mmap->update_flag[WM_MANIPULATORMAP_DRAWSTEP_3D] & MANIPULATORMAP_IS_REFRESH_CALLBACK) &&