Make version_update() callback being invoked when linking/appending datablocks
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 13 Jan 2015 13:24:53 +0000 (18:24 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 13 Jan 2015 13:24:53 +0000 (18:24 +0500)
This way addons and render engines which needs to do versioning code on files will properly
do it when something is being linked or appended to the scene. Previously that callback was
only called for the local main only, making it impossible to do tweaks on linking.

source/blender/blenloader/intern/readfile.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_init_exit.c

index 7e10bff49a4ed81ad8e0fa78a70ecfb8979405af..5a3e9141fad4964ae4fc9bb06ec3bdf539b5acf4 100644 (file)
 
 #include "BLI_endian_switch.h"
 #include "BLI_blenlib.h"
+#include "BLI_callbacks.h"
 #include "BLI_math.h"
 #include "BLI_threads.h"
 #include "BLI_mempool.h"
@@ -7889,8 +7890,12 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
        }
        
        /* do before read_libraries, but skip undo case */
-       if (fd->memfile==NULL)
+       if (fd->memfile==NULL) {
                do_versions(fd, NULL, bfd->main);
+               if (BLI_thread_is_main()) {
+                       BLI_callback_exec(bfd->main, NULL, BLI_CB_EVT_VERSION_UPDATE);
+               }
+       }
        
        do_versions_userdef(fd, bfd);
        
@@ -9527,6 +9532,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
                                do_versions(mainptr->curlib->filedata, mainptr->curlib, mainptr);
                        else
                                do_versions(basefd, NULL, mainptr);
+                       if (BLI_thread_is_main()) {
+                               BLI_callback_exec(mainptr, NULL, BLI_CB_EVT_VERSION_UPDATE);
+                       }
                }
                
                if (mainptr->curlib->filedata)
index c1c31f6795d5872f5b25921a3d61ff9ecffb1abe..c6f12f558405699ea3f8a0d513f7f512b1acb4f7 100644 (file)
@@ -478,7 +478,6 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
                WM_operatortype_last_properties_clear_all();
 
                /* important to do before NULL'ing the context */
-               BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE);
                BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
 
                if (!G.background) {
@@ -672,7 +671,6 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
        WM_operatortype_last_properties_clear_all();
 
        /* important to do before NULL'ing the context */
-       BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE);
        BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
 
        WM_event_add_notifier(C, NC_WM | ND_FILEREAD, NULL);
index cb03d022afd7f793183bb354650db5c8e71bd1ca..03c6414ef7685030493d59b265494d65b3a692b7 100644 (file)
@@ -240,7 +240,6 @@ void WM_init(bContext *C, int argc, const char **argv)
                 *
                 * unlikely any handlers are set but its possible,
                 * note that recovering the last session does its own callbacks. */
-               BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE);
                BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
        }
 }