Cleanup: remove bad-level call

This commit is contained in:
Campbell Barton 2016-06-25 21:10:30 +10:00
parent 0a99072f0d
commit 9c96585f3c
6 changed files with 19 additions and 11 deletions

View File

@ -45,6 +45,8 @@ extern const char *BKE_undo_get_name(int nr, bool *r_active);
extern bool BKE_undo_save_file(const char *filename);
extern struct Main *BKE_undo_get_main(struct Scene **r_scene);
extern void BKE_undo_callback_wm_kill_jobs_set(void (*callback)(struct bContext *C));
#ifdef __cplusplus
}
#endif

View File

@ -49,9 +49,6 @@ set(INC
../../../intern/smoke/extern
../../../intern/atomic
../../../intern/libmv
# XXX - BAD LEVEL CALL WM_api.h
../windowmanager
)
set(INC_SYS

View File

@ -66,9 +66,6 @@
#include "BLO_readfile.h"
#include "BLO_writefile.h"
#include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie
/* -------------------------------------------------------------------- */
/** \name Global Undo
@ -87,6 +84,15 @@ typedef struct UndoElem {
static ListBase undobase = {NULL, NULL};
static UndoElem *curundo = NULL;
/**
* Avoid bad-level call to #WM_jobs_kill_all_except()
*/
static void (*undo_wm_job_kill_callback)(struct bContext *C) = NULL;
void BKE_undo_callback_wm_kill_jobs_set(void (*callback)(struct bContext *C))
{
undo_wm_job_kill_callback = callback;
}
static int read_undosave(bContext *C, UndoElem *uel)
{
@ -94,7 +100,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
int success = 0, fileflags;
/* This is needed so undoing/redoing doesn't crash with threaded previews going */
WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
undo_wm_job_kill_callback(C);
BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */

View File

@ -95,8 +95,6 @@
#include "DNA_screen_types.h"
#include "DNA_view3d_types.h"
#include "WM_api.h"
static SpinLock image_spin;
/* prototypes */

View File

@ -55,8 +55,6 @@
#include "PIL_time.h"
#include "WM_api.h"
#include "BKE_appdir.h"
#include "BKE_anim.h"
#include "BKE_cloth.h"

View File

@ -141,6 +141,11 @@ static void wm_free_reports(bContext *C)
BKE_reports_clear(reports);
}
static void wm_undo_kill_callback(bContext *C)
{
WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
}
bool wm_start_with_console = false; /* used in creator.c */
/* only called once, for startup */
@ -159,6 +164,8 @@ void WM_init(bContext *C, int argc, const char **argv)
WM_menutype_init();
WM_uilisttype_init();
BKE_undo_callback_wm_kill_jobs_set(wm_undo_kill_callback);
BKE_library_callback_free_window_manager_set(wm_close_and_free); /* library.c */
BKE_library_callback_free_notifier_reference_set(WM_main_remove_notifier_reference); /* library.c */
BKE_library_callback_remap_editor_id_reference_set(WM_main_remap_editor_id_reference); /* library.c */