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. :)
This commit is contained in:
Ton Roosendaal
2009-01-06 17:38:44 +00:00
parent 650c63ec22
commit e99d12508e
3 changed files with 21 additions and 13 deletions

View 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:

View 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)

View 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);