Fix T64407: crash adding workspace after appending datablock
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 13 May 2019 20:18:11 +0000 (22:18 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 13 May 2019 20:20:49 +0000 (22:20 +0200)
The files operator property should not be remembered for next
operator executions, gives unexpected effects when using the
operator again.

source/blender/editors/screen/workspace_edit.c
source/blender/windowmanager/intern/wm_operator_props.c

index 2dfa05cf6b0837d013f26c1c4d39b6463ae30c7e..863e3a151208d13efcff0e9cf6cdea8372e5bfcc 100644 (file)
@@ -373,13 +373,15 @@ static int workspace_append_activate_exec(bContext *C, wmOperator *op)
         &bmain->workspaces, idname, offsetof(ID, name) + 2);
     BLI_assert(appended_workspace != NULL);
 
-    /* Reorder to last position. */
-    BKE_id_reorder(&bmain->workspaces, &appended_workspace->id, NULL, true);
+    if (appended_workspace) {
+      /* Reorder to last position. */
+      BKE_id_reorder(&bmain->workspaces, &appended_workspace->id, NULL, true);
 
-    /* Changing workspace changes context. Do delayed! */
-    WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, appended_workspace);
+      /* Changing workspace changes context. Do delayed! */
+      WM_event_add_notifier(C, NC_SCREEN | ND_WORKSPACE_SET, appended_workspace);
 
-    return OPERATOR_FINISHED;
+      return OPERATOR_FINISHED;
+    }
   }
 
   return OPERATOR_CANCELLED;
index db1f9a32935974ca3b39d8b2dc093afd460a6d27..3ad7247d99347896a9edd7c1a68a35d39d2297d9 100644 (file)
@@ -94,7 +94,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
   }
 
   if (flag & WM_FILESEL_FILES) {
-    RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
+    prop = RNA_def_collection_runtime(
+        ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
+    RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
   }
 
   if (action == FILE_SAVE) {