2.5
authorTon Roosendaal <ton@blender.org>
Tue, 6 Jan 2009 17:38:44 +0000 (17:38 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 6 Jan 2009 17:38:44 +0000 (17:38 +0000)
File window: load now happens with proper free of operator.
still a bit of mystery how main handler loop survives after
a file load... will investigate once. :)

source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/space_file.c
source/blender/windowmanager/intern/wm_operators.c

index 347cd6c747ef592634f0a0e8c78ccbed9e49dfc6..b2b77e9dfb93ac7bcec06ebbce348e4c9534bb35 100644 (file)
@@ -98,14 +98,22 @@ static void do_file_buttons(bContext *C, void *arg, int event)
                                char name[FILE_MAX];
 
                                area_prevspace(C);
-                               BLI_strncpy(name, sfile->params->dir, sizeof(name));
-                               strcat(name, sfile->params->file);
-                               RNA_string_set(sfile->op->ptr, "filename", name);
-                               sfile->op->type->exec(C, sfile->op);
-                               /* XXX for Ton: the call to WM_operator_free crashes
-                                  WM_operator_free(sfile->op);
-                                  sfile->op = NULL;
-                               */
+                               if(sfile->op) {
+                                       wmOperator *op= sfile->op;
+                                       
+                                       /* if load .blend, all UI pointers after exec are invalid! */
+                                       /* but, operator can be freed still */
+                                       
+                                       sfile->op = NULL;
+                                       BLI_strncpy(name, sfile->params->dir, sizeof(name));
+                                       strcat(name, sfile->params->file);
+                                       RNA_string_set(op->ptr, "filename", name);
+                               
+                                       op->type->exec(C, op);
+                               
+                                       WM_operator_free(op);
+                               }
+
                        }
                        break;
                case B_FS_CANCEL:
index f5e7ffa77731a2dd41b54e447bdd77c8952362a0..d5d16c074175f69c5eee080b7b3f98cd81af66b6 100644 (file)
@@ -173,7 +173,7 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
 static void file_main_area_draw(const bContext *C, ARegion *ar)
 {
        /* draw entirely, view changes should be handled here */
-       SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
+//     SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
        FileSelectParams* params = ED_fileselect_get_params(C);
        View2D *v2d= &ar->v2d;
        View2DScrollers *scrollers;
@@ -322,10 +322,10 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_view_restore(C);
 }
 
-static void file_main_area_listener(ARegion *ar, wmNotifier *wmn)
-{
+//static void file_main_area_listener(ARegion *ar, wmNotifier *wmn)
+//{
        /* context changes */
-}
+//}
 
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_file(void)
index a703f2b5c0e8a4d49a798b478207904d86f5f3a0..9e7988ab6e9400ccaf4686d326dbcf85cae1aa05 100644 (file)
@@ -402,7 +402,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
        ot->exec= wm_mainfile_exec;
        ot->poll= WM_operator_winactive;
        
-       ot->flag= OPTYPE_REGISTER;
+       ot->flag= 0;
        
        RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);