diff --git a/source/blender/include/BIF_imasel.h b/source/blender/include/BIF_imasel.h index a3a3b7531d6..cbd547602e1 100644 --- a/source/blender/include/BIF_imasel.h +++ b/source/blender/include/BIF_imasel.h @@ -34,6 +34,7 @@ struct ScrArea; struct ID; void free_imasel(struct SpaceImaSel *simasel); +void reset_imaselspace(struct ScrArea *sa); void clever_numbuts_imasel(void); diff --git a/source/blender/include/BSE_filesel.h b/source/blender/include/BSE_filesel.h index 13e38d50c47..b46b2328ea4 100644 --- a/source/blender/include/BSE_filesel.h +++ b/source/blender/include/BSE_filesel.h @@ -54,6 +54,7 @@ void activate_databrowse(struct ID *id, int idcode, int fromcode, int retval, sh void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *menup, void (*func)(char *, void *, void *), void *arg1, void *arg2); void filesel_prevspace(void); +void reset_filespace(struct ScrArea *sa); void free_filesel_spec(char *dir); void winqreadfilespace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt); void main_to_filelist(struct SpaceFile *sfile); diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index 19372dcbee6..bfff2f10ab6 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -1299,6 +1299,27 @@ void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *me sfile->ipotype= fromcode; } +/* resets a previous file space type */ +/* is used when opening a filebrowser directly from windowtype_pupmenu, + since in that case we don't want any load/save/append/link action +*/ +void reset_filespace(ScrArea *sa) +{ + if (sa->spacetype == SPACE_FILE) { + SpaceFile *sfile= sa->spacedata.first; + + if(sfile->type==FILE_MAIN) { + freefilelist(sfile); + } else { + sfile->type= FILE_UNIX; + } + + sfile->returnfunc= NULL; + sfile->title[0]= 0; + if(sfile->filelist) test_flags_file(sfile); + } +} + void filesel_prevspace() { SpaceFile *sfile= curarea->spacedata.first; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index b91a8f74f80..81ad135f514 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -1434,6 +1434,8 @@ void do_global_buttons(unsigned short event) break; case B_NEWSPACE: newspace(curarea, curarea->butspacetype); + reset_filespace(curarea); + reset_imaselspace(curarea); break; case B_LOADTEMP: /* is button from space.c */ BIF_read_autosavefile(); diff --git a/source/blender/src/imasel.c b/source/blender/src/imasel.c index be9f489ea49..f502445d329 100644 --- a/source/blender/src/imasel.c +++ b/source/blender/src/imasel.c @@ -80,3 +80,26 @@ void free_imasel(SpaceImaSel *simasel) } } +/* resets a previous imagebrowser space type */ +/* is used when opening an imagebrowser directly from windowtype_pupmenu, + since in that case we don't want any load/save/append/link action +*/ +void reset_imaselspace(ScrArea *sa) +{ + if(sa->spacetype==SPACE_IMASEL) { + SpaceImaSel *simasel= sa->spacedata.first; + if(simasel->type==FILE_MAIN) { + if (simasel->files) { + BIF_filelist_free(simasel->files); + BIF_filelist_settype(simasel->files, FILE_MAIN); + } + } else { + if (simasel->files) { + simasel->type= FILE_UNIX; + BIF_filelist_settype(simasel->files, simasel->type); + } + } + simasel->returnfunc= NULL; + simasel->title[0]= 0; + } +} diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 41e539c3d1a..3cffed48224 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -5611,6 +5611,7 @@ static void init_imaselspace(ScrArea *sa) simasel->files = BIF_filelist_new(); } + /* ******************** SPACE: OOPS ********************** */ extern void drawoopsspace(ScrArea *sa, void *spacedata); @@ -6155,39 +6156,7 @@ void newspace(ScrArea *sa, int type) } } - - /* exception: filespace */ - if(sa->spacetype==SPACE_FILE) { - SpaceFile *sfile= sa->spacedata.first; - - if(sfile->type==FILE_MAIN) { - freefilelist(sfile); - } else { - sfile->type= FILE_UNIX; - } - - sfile->returnfunc= NULL; - sfile->title[0]= 0; - if(sfile->filelist) test_flags_file(sfile); - } - /* exception: imasel space */ - else if(sa->spacetype==SPACE_IMASEL) { - SpaceImaSel *simasel= sa->spacedata.first; - if(simasel->type==FILE_MAIN) { - if (simasel->files) { - BIF_filelist_free(simasel->files); - BIF_filelist_settype(simasel->files, FILE_MAIN); - } - } else { - if (simasel->files) { - simasel->type= FILE_UNIX; - BIF_filelist_settype(simasel->files, simasel->type); - } - } - simasel->returnfunc= NULL; - simasel->title[0]= 0; - } - else if(sa->spacetype==SPACE_OOPS) { + if(sa->spacetype==SPACE_OOPS) { SpaceOops *so= sa->spacedata.first; if(xtra && so->type!=SO_OUTLINER) { so->type= SO_OUTLINER;