Fix glitch updating manipulator after undo

Running undo would notify manipulators to refresh,
but this still allowed for events in the queue to be handled,
where manipulators could be drawn for selection before
their refresh callback runs.

This made Python manipulators raise exceptions
about referencing invalid data (or crash).

Now tag manipulator update on file load (including undo)
and ensure the refresh callback runs
before drawing manipulator selection.

Also split manipulator map refresh flag in two since selection doesn't
perform the same operations as regular drawing.
This commit is contained in:
2017-07-31 14:35:10 +10:00
parent 3b15ff3fb4
commit 39e1518d41
6 changed files with 61 additions and 13 deletions

View File

@@ -292,6 +292,32 @@ void BKE_spacedata_id_unref(struct ScrArea *sa, struct SpaceLink *sl, struct ID
}
}
/**
* Avoid bad-level calls to #WM_manipulatormap_tag_refresh.
*/
static void (*region_refresh_tag_manipulatormap_callback)(struct wmManipulatorMap *) = NULL;
void BKE_region_callback_refresh_tag_manipulatormap_set(void (*callback)(struct wmManipulatorMap *))
{
region_refresh_tag_manipulatormap_callback = callback;
}
void BKE_screen_manipulator_tag_refresh(struct bScreen *sc)
{
if (region_refresh_tag_manipulatormap_callback == NULL) {
return;
}
ScrArea *sa;
ARegion *ar;
for (sa = sc->areabase.first; sa; sa = sa->next) {
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->manipulator_map != NULL) {
region_refresh_tag_manipulatormap_callback(ar->manipulator_map);
}
}
}
}
/**
* Avoid bad-level calls to #WM_manipulatormap_delete.