diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-08 17:03:04 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-08 17:03:04 +0400 |
commit | 85e53317be8f2d390752878dfc0a1aafc33df7ca (patch) | |
tree | 7ef81e83d7319fe4ac567759a932457179040acb /source/blender/blenkernel | |
parent | 3fbaece0d63f9bf9826fee988624f195a8431fa4 (diff) |
fix for bug where notifiers could hold pointers to freed data which listeners would operate on.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 99247414cff..3c5406c4a77 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -119,6 +119,7 @@ void flag_all_listbases_ids(short flag, short value); void recalc_all_library_objects(struct Main *main); void set_free_windowmanager_cb(void (*func)(struct bContext *, struct wmWindowManager *) ); +void set_free_notifier_reference_cb(void (*func)(const void *) ); /* use when "" is given to new_id() */ #define ID_FALLBACK_NAME N_("Untitled") diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 1674fbd55a7..da642f11e8d 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -823,6 +823,14 @@ void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) ) free_windowmanager_cb = func; } +static void (*free_notifier_reference_cb)(const void *) = NULL; + +void set_free_notifier_reference_cb(void (*func)(const void *) ) +{ + free_notifier_reference_cb = func; +} + + static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata) { ChannelDriver *driver; @@ -969,6 +977,10 @@ void BKE_libblock_free(ListBase *lb, void *idv) break; } + /* avoid notifying on removed data */ + if (free_notifier_reference_cb) + free_notifier_reference_cb(id); + BLI_remlink(lb, id); BKE_libblock_free_data(id); |