Library linking code: proper early out in case there is nothing to link.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 7 Feb 2018 21:09:44 +0000 (22:09 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 7 Feb 2018 21:09:44 +0000 (22:09 +0100)
source/blender/windowmanager/intern/wm_files_link.c

index dca1077ebc7cb2a45257628d3fa830d8df21d2e1..171863454d92610b1e288b9cc27faa87b6fdd6f2 100644 (file)
@@ -282,7 +282,6 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
        char path[FILE_MAX_LIBEXTRA], root[FILE_MAXDIR], libname[FILE_MAX_LIBEXTRA], relname[FILE_MAX];
        char *group, *name;
        int totfiles = 0;
-       short flag;
 
        RNA_string_get(op->ptr, "filename", relname);
        RNA_string_get(op->ptr, "directory", root);
@@ -319,7 +318,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       flag = wm_link_append_flag(op);
+       short flag = wm_link_append_flag(op);
 
        /* sanity checks for flag */
        if (scene && scene->id.lib) {
@@ -401,6 +400,12 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
                BLI_BITMAP_ENABLE(item->libraries, 0);
        }
 
+       if (lapp_data->num_items == 0) {
+               /* Early out in case there is nothing to link. */
+               wm_link_append_data_free(lapp_data);
+               return;
+       }
+
        /* XXX We'd need re-entrant locking on Main for this to work... */
        /* BKE_main_lock(bmain); */