Apply patch [#23846] Fix for [#23698] in File Browser system. Properly removes handler and sfile when File selector disapears.
Patch by Alexander Kuznetsov Reported by Chidozie Oku From patch description: " Handler is now released on every exit from File Selector. For example pressing ctrl-up and then changing editor type to another also releases the handler. When an area is changed from SPACE_FILE, ED_fileselect_exit is called for clean up. It takes function of freeing folder list and files (before it was done in cancel or exec functions) because they must be released on every exit anyway. op!=null means cancel or exec was not executed so a handler was not released. ED_fileselect_exit then releases the handler without changing screens. " Thanks!
This commit is contained in:
@@ -1095,13 +1095,6 @@ void ED_area_prevspace(bContext *C, ScrArea *sa)
|
||||
{
|
||||
SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
|
||||
|
||||
/* Special handling of filebrowser to stop background thread for
|
||||
thumbnail creation - don't want to waste cpu resources if not showing
|
||||
the filebrowser */
|
||||
if (sl->spacetype == SPACE_FILE) {
|
||||
ED_fileselect_exit(C, (SpaceFile*)sl);
|
||||
}
|
||||
|
||||
if(sl->next) {
|
||||
/* workaround for case of double prevspace, render window
|
||||
with a file browser on top of it */
|
||||
|
||||
@@ -1090,6 +1090,10 @@ void ED_area_exit(bContext *C, ScrArea *sa)
|
||||
ScrArea *prevsa= CTX_wm_area(C);
|
||||
ARegion *ar;
|
||||
|
||||
if (sa->spacetype == SPACE_FILE) {
|
||||
ED_fileselect_exit(C, (SpaceFile*)(sa) ? sa->spacedata.first : CTX_wm_space_data(C));
|
||||
}
|
||||
|
||||
CTX_wm_area_set(C, sa);
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
ED_region_exit(C, ar);
|
||||
|
||||
@@ -507,18 +507,11 @@ void FILE_OT_highlight(struct wmOperatorType *ot)
|
||||
int file_cancel_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
folderlist_free(sfile->folders_prev);
|
||||
folderlist_free(sfile->folders_next);
|
||||
|
||||
WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_CANCEL);
|
||||
sfile->op = NULL;
|
||||
wmOperator *op = sfile->op;
|
||||
|
||||
if (sfile->files) {
|
||||
ED_fileselect_clear(C, sfile);
|
||||
MEM_freeN(sfile->files);
|
||||
sfile->files= NULL;
|
||||
}
|
||||
sfile->op = NULL;
|
||||
|
||||
WM_event_fileselect_event(C, op, EVT_FILESELECT_CANCEL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -686,17 +679,11 @@ int file_exec(bContext *C, wmOperator *exec_op)
|
||||
|
||||
file_sfile_to_operator(op, sfile, filepath);
|
||||
|
||||
folderlist_free(sfile->folders_prev);
|
||||
folderlist_free(sfile->folders_next);
|
||||
|
||||
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
|
||||
BLI_make_file_string(G.sce, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
|
||||
fsmenu_write_file(fsmenu_get(), filepath);
|
||||
WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
|
||||
|
||||
ED_fileselect_clear(C, sfile);
|
||||
MEM_freeN(sfile->files);
|
||||
sfile->files= NULL;
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
@@ -531,5 +531,18 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile)
|
||||
|
||||
void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile)
|
||||
{
|
||||
thumbnails_stop(sfile->files, C);
|
||||
if(!sfile) return;
|
||||
if(sfile->op)
|
||||
WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL);
|
||||
sfile->op = NULL;
|
||||
|
||||
folderlist_free(sfile->folders_prev);
|
||||
folderlist_free(sfile->folders_next);
|
||||
|
||||
if (sfile->files) {
|
||||
ED_fileselect_clear(C, sfile);
|
||||
MEM_freeN(sfile->files);
|
||||
sfile->files= NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1224,18 +1224,20 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
||||
|
||||
case EVT_FILESELECT_EXEC:
|
||||
case EVT_FILESELECT_CANCEL:
|
||||
case EVT_FILESELECT_EXTERNAL_CANCEL:
|
||||
{
|
||||
/* XXX validate area and region? */
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
|
||||
if(screen != handler->filescreen)
|
||||
ED_screen_full_prevspace(C, CTX_wm_area(C));
|
||||
else
|
||||
ED_area_prevspace(C, CTX_wm_area(C));
|
||||
|
||||
/* remlink now, for load file case */
|
||||
|
||||
/* remlink now, for load file case before removing*/
|
||||
BLI_remlink(handlers, handler);
|
||||
|
||||
if(event->val!=EVT_FILESELECT_EXTERNAL_CANCEL)
|
||||
if(screen != handler->filescreen)
|
||||
ED_screen_full_prevspace(C, CTX_wm_area(C));
|
||||
else
|
||||
ED_area_prevspace(C, CTX_wm_area(C));
|
||||
|
||||
wm_handler_op_context(C, handler);
|
||||
|
||||
/* needed for uiPupMenuReports */
|
||||
|
||||
@@ -269,10 +269,11 @@
|
||||
#define EVT_FILESELECT 0x5020
|
||||
|
||||
/* event->val */
|
||||
#define EVT_FILESELECT_OPEN 1
|
||||
#define EVT_FILESELECT_FULL_OPEN 2
|
||||
#define EVT_FILESELECT_EXEC 3
|
||||
#define EVT_FILESELECT_CANCEL 4
|
||||
#define EVT_FILESELECT_OPEN 1
|
||||
#define EVT_FILESELECT_FULL_OPEN 2
|
||||
#define EVT_FILESELECT_EXEC 3
|
||||
#define EVT_FILESELECT_CANCEL 4
|
||||
#define EVT_FILESELECT_EXTERNAL_CANCEL 5
|
||||
|
||||
/* event->type */
|
||||
#define EVT_BUT_OPEN 0x5021
|
||||
|
||||
Reference in New Issue
Block a user