Fix T74699: File browser closing while loading crash.
Owner of filelisting job was changed, without proper update of all access/usages of that owner to reach the job, leading to failure of timer removal from the WM, and attempt to double-free the job... Caused by rB2c4dfbb00246ff.
This commit is contained in:
@@ -133,9 +133,13 @@ void ED_fileselect_layout_tilepos(FileLayout *layout, int tile, int *x, int *y);
|
||||
|
||||
void ED_operatormacros_file(void);
|
||||
|
||||
void ED_fileselect_clear(struct wmWindowManager *wm, struct ScrArea *sa, struct SpaceFile *sfile);
|
||||
void ED_fileselect_clear(struct wmWindowManager *wm,
|
||||
struct Scene *owner_scene,
|
||||
struct SpaceFile *sfile);
|
||||
|
||||
void ED_fileselect_exit(struct wmWindowManager *wm, struct ScrArea *sa, struct SpaceFile *sfile);
|
||||
void ED_fileselect_exit(struct wmWindowManager *wm,
|
||||
struct Scene *owner_scene,
|
||||
struct SpaceFile *sfile);
|
||||
|
||||
void ED_fileselect_window_params_get(const struct wmWindow *win,
|
||||
int win_size[2],
|
||||
|
||||
@@ -382,7 +382,6 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
|
||||
char filename[FILE_MAX + 12];
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
|
||||
BLI_join_dirfile(orgname, sizeof(orgname), sfile->params->dir, oldname);
|
||||
@@ -410,7 +409,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
|
||||
}
|
||||
|
||||
/* to make sure we show what is on disk */
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
|
||||
}
|
||||
|
||||
ED_region_tag_redraw(region);
|
||||
|
||||
@@ -1649,10 +1649,9 @@ static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
struct FSMenu *fsmenu = ED_fsmenu_get();
|
||||
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
|
||||
|
||||
/* refresh system directory menu */
|
||||
fsmenu_refresh_system_category(fsmenu);
|
||||
@@ -1988,7 +1987,6 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
|
||||
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
const bool do_diropen = RNA_boolean_get(op->ptr, "open");
|
||||
|
||||
if (!sfile->params) {
|
||||
@@ -2047,13 +2045,13 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
|
||||
/* set timer to smoothly view newly generated file */
|
||||
/* max 30 frs/sec */
|
||||
if (sfile->smoothscroll_timer != NULL) {
|
||||
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
|
||||
WM_event_remove_timer(wm, CTX_wm_window(C), sfile->smoothscroll_timer);
|
||||
}
|
||||
sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0);
|
||||
sfile->scroll_offset = 0;
|
||||
|
||||
/* reload dir to make sure we're seeing what's in the directory */
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
|
||||
|
||||
if (do_diropen) {
|
||||
BLI_strncpy(sfile->params->dir, path, sizeof(sfile->params->dir));
|
||||
@@ -2302,11 +2300,10 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused))
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
if (sfile->params) {
|
||||
sfile->params->flag ^= FILE_HIDE_DOT;
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
|
||||
}
|
||||
|
||||
@@ -2491,7 +2488,6 @@ int file_delete_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
int numfiles = filelist_files_ensure(sfile->files);
|
||||
|
||||
const char *error_message = NULL;
|
||||
@@ -2520,7 +2516,7 @@ int file_delete_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
|
||||
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
@@ -3067,12 +3067,12 @@ void filelist_readjob_start(FileList *filelist, const bContext *C)
|
||||
WM_jobs_start(CTX_wm_manager(C), wm_job);
|
||||
}
|
||||
|
||||
void filelist_readjob_stop(wmWindowManager *wm, ScrArea *sa)
|
||||
void filelist_readjob_stop(wmWindowManager *wm, Scene *owner_scene)
|
||||
{
|
||||
WM_jobs_kill_type(wm, sa, WM_JOB_TYPE_FILESEL_READDIR);
|
||||
WM_jobs_kill_type(wm, owner_scene, WM_JOB_TYPE_FILESEL_READDIR);
|
||||
}
|
||||
|
||||
int filelist_readjob_running(wmWindowManager *wm, ScrArea *sa)
|
||||
int filelist_readjob_running(wmWindowManager *wm, Scene *owner_scene)
|
||||
{
|
||||
return WM_jobs_test(wm, sa, WM_JOB_TYPE_FILESEL_READDIR);
|
||||
return WM_jobs_test(wm, owner_scene, WM_JOB_TYPE_FILESEL_READDIR);
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ bool filelist_islibrary(struct FileList *filelist, char *dir, char **group);
|
||||
void filelist_freelib(struct FileList *filelist);
|
||||
|
||||
void filelist_readjob_start(struct FileList *filelist, const struct bContext *C);
|
||||
void filelist_readjob_stop(struct wmWindowManager *wm, struct ScrArea *sa);
|
||||
int filelist_readjob_running(struct wmWindowManager *wm, struct ScrArea *sa);
|
||||
void filelist_readjob_stop(struct wmWindowManager *wm, struct Scene *owner_scene);
|
||||
int filelist_readjob_running(struct wmWindowManager *wm, struct Scene *owner_scene);
|
||||
|
||||
bool filelist_cache_previews_update(struct FileList *filelist);
|
||||
void filelist_cache_previews_set(struct FileList *filelist, const bool use_previews);
|
||||
|
||||
@@ -829,10 +829,9 @@ void ED_file_change_dir(bContext *C)
|
||||
{
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
SpaceFile *sfile = CTX_wm_space_file(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
if (sfile->params) {
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, CTX_data_scene(C), sfile);
|
||||
|
||||
/* Clear search string, it is very rare to want to keep that filter while changing dir,
|
||||
* and usually very annoying to keep it actually! */
|
||||
@@ -951,11 +950,11 @@ int autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
|
||||
return match;
|
||||
}
|
||||
|
||||
void ED_fileselect_clear(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
|
||||
void ED_fileselect_clear(wmWindowManager *wm, Scene *owner_scene, SpaceFile *sfile)
|
||||
{
|
||||
/* only NULL in rare cases - [#29734] */
|
||||
if (sfile->files) {
|
||||
filelist_readjob_stop(wm, sa);
|
||||
filelist_readjob_stop(wm, owner_scene);
|
||||
filelist_freelib(sfile->files);
|
||||
filelist_clear(sfile->files);
|
||||
}
|
||||
@@ -964,7 +963,7 @@ void ED_fileselect_clear(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_LIST, NULL);
|
||||
}
|
||||
|
||||
void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
|
||||
void ED_fileselect_exit(wmWindowManager *wm, Scene *owner_scene, SpaceFile *sfile)
|
||||
{
|
||||
if (!sfile) {
|
||||
return;
|
||||
@@ -990,7 +989,7 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
|
||||
folderlist_free(sfile->folders_next);
|
||||
|
||||
if (sfile->files) {
|
||||
ED_fileselect_clear(wm, sa, sfile);
|
||||
ED_fileselect_clear(wm, owner_scene, sfile);
|
||||
filelist_free(sfile->files);
|
||||
MEM_freeN(sfile->files);
|
||||
sfile->files = NULL;
|
||||
|
||||
@@ -191,7 +191,7 @@ static void file_exit(wmWindowManager *wm, ScrArea *sa)
|
||||
sfile->previews_timer = NULL;
|
||||
}
|
||||
|
||||
ED_fileselect_exit(wm, sa, sfile);
|
||||
ED_fileselect_exit(wm, NULL, sfile);
|
||||
}
|
||||
|
||||
static SpaceLink *file_duplicate(SpaceLink *sl)
|
||||
@@ -301,7 +301,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
|
||||
sfile->recentnr = fsmenu_get_active_indices(fsmenu, FS_CATEGORY_RECENT, params->dir);
|
||||
|
||||
if (filelist_force_reset(sfile->files)) {
|
||||
filelist_readjob_stop(wm, sa);
|
||||
filelist_readjob_stop(wm, CTX_data_scene(C));
|
||||
filelist_clear(sfile->files);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user