Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-06-14 13:34:13 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-06-14 13:34:13 +0300
commit66407e15cb5136bdbed45b9e0576b1e9863c3f4f (patch)
treefb4134f9ae1c846504e92c5816d8db83883509e8 /source
parent0eb32467131543f224a222f0caf42df4ff9d7d65 (diff)
Cleanup: Remove last G.main's from WM code.
Was mostly validating valid usages of G.main -> G_MAIN actually.
Diffstat (limited to 'source')
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c10
-rw-r--r--source/blender/windowmanager/intern/wm_files.c37
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c9
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c2
-rw-r--r--source/blender/windowmanager/wm_files.h3
7 files changed, 34 insertions, 31 deletions
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 6aef38a320b..24ec3aef759 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -176,7 +176,7 @@ void WM_cursor_modal_restore(wmWindow *win)
void WM_cursor_wait(bool val)
{
if (!G.background) {
- wmWindowManager *wm = G.main->wm.first;
+ wmWindowManager *wm = G_MAIN->wm.first;
wmWindow *win = wm ? wm->windows.first : NULL;
for (; win; win = win->next) {
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 951bfb12dd0..b9fe7d28838 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -210,7 +210,7 @@ void WM_event_add_notifier(const bContext *C, unsigned int type, void *reference
void WM_main_add_notifier(unsigned int type, void *reference)
{
- Main *bmain = G.main;
+ Main *bmain = G_MAIN;
wmWindowManager *wm = bmain->wm.first;
wmNotifier *note;
@@ -235,7 +235,7 @@ void WM_main_add_notifier(unsigned int type, void *reference)
*/
void WM_main_remove_notifier_reference(const void *reference)
{
- Main *bmain = G.main;
+ Main *bmain = G_MAIN;
wmWindowManager *wm = bmain->wm.first;
if (wm) {
@@ -255,7 +255,7 @@ void WM_main_remove_notifier_reference(const void *reference)
void WM_main_remap_editor_id_reference(ID *old_id, ID *new_id)
{
- Main *bmain = G.main;
+ Main *bmain = G_MAIN;
bScreen *sc;
for (sc = bmain->screen.first; sc; sc = sc->id.next) {
@@ -611,7 +611,7 @@ void WM_event_print(const wmEvent *event)
*/
void WM_report_banner_show(void)
{
- wmWindowManager *wm = G.main->wm.first;
+ wmWindowManager *wm = G_MAIN->wm.first;
ReportList *wm_reports = &wm->reports;
ReportTimerInfo *rti;
@@ -646,7 +646,7 @@ static void wm_add_reports(ReportList *reports)
{
/* if the caller owns them, handle this */
if (reports->list.first && (reports->flag & RPT_OP_HOLD) == 0) {
- wmWindowManager *wm = G.main->wm.first;
+ wmWindowManager *wm = G_MAIN->wm.first;
/* add reports to the global list, otherwise they are not seen */
BLI_movelisttolist(&wm->reports.list, &reports->list);
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 31b39f1f736..d110f7cd3ed 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -147,8 +147,8 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
wmWindowManager *wm;
wmWindow *win, *active_win;
- *wmlist = G.main->wm;
- BLI_listbase_clear(&G.main->wm);
+ *wmlist = G_MAIN->wm;
+ BLI_listbase_clear(&G_MAIN->wm);
active_win = CTX_wm_window(C);
@@ -188,7 +188,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
for (win = wm->windows.first; win; win = win->next) {
BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME);
if (win != wm->winactive) {
- BLI_remlink(&G.main->screen, win->screen);
+ BLI_remlink(&G_MAIN->screen, win->screen);
//BLI_addtail(screenbase, win->screen);
}
}
@@ -423,12 +423,12 @@ void WM_file_autoexec_init(const char *filepath)
}
}
-void wm_file_read_report(bContext *C)
+void wm_file_read_report(bContext *C, Main *bmain)
{
ReportList *reports = NULL;
Scene *sce;
- for (sce = G.main->scene.first; sce; sce = sce->id.next) {
+ for (sce = bmain->scene.first; sce; sce = sce->id.next) {
if (sce->r.engine[0] &&
BLI_findstring(&R_engines, sce->r.engine, offsetof(RenderEngineType, idname)) == NULL)
{
@@ -455,6 +455,7 @@ void wm_file_read_report(bContext *C)
*/
static void wm_file_read_post(bContext *C, const bool is_startup_file, const bool use_userdef)
{
+ Main *bmain = CTX_data_main(C);
bool addons_loaded = false;
wmWindowManager *wm = CTX_wm_manager(C);
@@ -466,7 +467,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
CTX_wm_window_set(C, wm->windows.first);
ED_editors_init(C);
- DAG_on_visible_update(CTX_data_main(C), true);
+ DAG_on_visible_update(bmain, true);
#ifdef WITH_PYTHON
if (is_startup_file) {
@@ -496,8 +497,8 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
WM_operatortype_last_properties_clear_all();
/* important to do before NULL'ing the context */
- BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE);
- BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST);
/* Would otherwise be handled by event loop.
*
@@ -505,7 +506,6 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
* While its possible state of startup file may be wrong,
* in this case users nearly always load a file to replace the startup file. */
if (G.background && (is_startup_file == false)) {
- Main *bmain = CTX_data_main(C);
BKE_scene_update_tagged(bmain->eval_ctx, bmain, CTX_data_scene(C));
}
@@ -514,7 +514,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
/* report any errors.
* currently disabled if addons aren't yet loaded */
if (addons_loaded) {
- wm_file_read_report(C);
+ wm_file_read_report(C, bmain);
}
if (!G.background) {
@@ -524,7 +524,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
else {
BKE_undosys_stack_clear(wm->undo_stack);
}
- BKE_undosys_stack_init_from_main(wm->undo_stack, CTX_data_main(C));
+ BKE_undosys_stack_init_from_main(wm->undo_stack, bmain);
BKE_undosys_stack_init_from_context(wm->undo_stack, C);
}
@@ -659,7 +659,7 @@ int wm_homefile_read(
bool use_factory_settings, bool use_empty_data, bool use_userdef,
const char *filepath_startup_override, const char *app_template_override)
{
- Main *bmain = G.main; /* Context does not always have valid main pointer here... */
+ Main *bmain = G_MAIN; /* Context does not always have valid main pointer here... */
ListBase wmbase;
bool success = false;
@@ -1088,7 +1088,7 @@ bool write_crash_blend(void)
BLI_strncpy(path, BKE_main_blendfile_path_from_global(), sizeof(path));
BLI_replace_extension(path, sizeof(path), "_crash.blend");
- if (BLO_write_file(G.main, path, fileflags, NULL, NULL)) {
+ if (BLO_write_file(G_MAIN, path, fileflags, NULL, NULL)) {
printf("written: %s\n", path);
return 1;
}
@@ -1224,7 +1224,7 @@ void wm_autosave_location(char *filepath)
const char *savedir;
#endif
- if (G.main && G.relbase_valid) {
+ if (G_MAIN && G.relbase_valid) {
const char *basename = BLI_path_basename(BKE_main_blendfile_path_from_global());
int len = strlen(basename) - 6;
BLI_snprintf(path, sizeof(path), "%.*s.blend", len, basename);
@@ -1374,7 +1374,7 @@ void wm_open_init_use_scripts(wmOperator *op, bool use_prefs)
void WM_file_tag_modified(void)
{
- wmWindowManager *wm = G.main->wm.first;
+ wmWindowManager *wm = G_MAIN->wm.first;
if (wm->file_saved) {
wm->file_saved = 0;
/* notifier that data changed, for save-over warning or header */
@@ -1391,6 +1391,7 @@ void WM_file_tag_modified(void)
*/
static int wm_homefile_write_exec(bContext *C, wmOperator *op)
{
+ Main *bmain = CTX_data_main(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
char filepath[FILE_MAX];
@@ -1403,7 +1404,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_PRE);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE);
/* check current window and close it if temp */
if (win && win->screen->temp)
@@ -1421,7 +1422,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
/* force save as regular blend file */
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_HISTORY);
- if (BLO_write_file(CTX_data_main(C), filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) {
+ if (BLO_write_file(bmain, filepath, fileflags | G_FILE_USERPREFS, op->reports, NULL) == 0) {
printf("fail\n");
return OPERATOR_CANCELLED;
}
@@ -1430,7 +1431,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op)
G.save_over = 0;
- BLI_callback_exec(G.main, NULL, BLI_CB_EVT_SAVE_POST);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 826c7b03713..38aa18a029e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -260,7 +260,7 @@ void WM_init(bContext *C, int argc, const char **argv)
/* allow a path of "", this is what happens when making a new file */
#if 0
if (BKE_main_blendfile_path_from_global()[0] == '\0')
- BLI_make_file_string("/", G.main->name, BKE_appdir_folder_default(), "untitled.blend");
+ BLI_make_file_string("/", G_MAIN->name, BKE_appdir_folder_default(), "untitled.blend");
#endif
BLI_strncpy(G.lib, BKE_main_blendfile_path_from_global(), sizeof(G.lib));
@@ -278,6 +278,7 @@ void WM_init(bContext *C, int argc, const char **argv)
/* that prevents loading both the kept session, and the file on the command line */
}
else {
+ Main *bmain = CTX_data_main(C);
/* note, logic here is from wm_file_read_post,
* call functions that depend on Python being initialized. */
@@ -288,10 +289,10 @@ void WM_init(bContext *C, int argc, const char **argv)
* note that recovering the last session does its own callbacks. */
CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first);
- BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE);
- BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE);
+ BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST);
- wm_file_read_report(C);
+ wm_file_read_report(C, bmain);
if (!G.background) {
CTX_wm_window_set(C, NULL);
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index a7edcbf73eb..8b166a9364f 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -804,7 +804,7 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, const Enu
if (!items) {
/* init modal items from default config */
- wmWindowManager *wm = G.main->wm.first;
+ wmWindowManager *wm = G_MAIN->wm.first;
if (wm->defaultconf) {
wmKeyMap *defaultkm = WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index de3c48ceaa4..2d7ed9d0295 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -502,7 +502,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
char str[sizeof(((Main *)NULL)->name) + 24];
BLI_snprintf(str, sizeof(str), "Blender%s [%s%s]", wm->file_saved ? "" : "*",
BKE_main_blendfile_path_from_global(),
- G.main->recovered ? " (Recovered)" : "");
+ G_MAIN->recovered ? " (Recovered)" : "");
GHOST_SetTitle(win->ghostwin, str);
}
else
diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h
index 2a364f53859..80777a904a1 100644
--- a/source/blender/windowmanager/wm_files.h
+++ b/source/blender/windowmanager/wm_files.h
@@ -31,6 +31,7 @@
#ifndef __WM_FILES_H__
#define __WM_FILES_H__
+struct Main;
struct wmOperatorType;
/* wm_files.c */
@@ -39,7 +40,7 @@ int wm_homefile_read(
struct bContext *C, struct ReportList *reports,
bool use_factory_settings, bool use_empty_data, bool use_userdef,
const char *filepath_startup_override, const char *app_template_override);
-void wm_file_read_report(bContext *C);
+void wm_file_read_report(bContext *C, struct Main *bmain);
void WM_OT_save_homefile(struct wmOperatorType *ot);
void WM_OT_userpref_autoexec_path_add(struct wmOperatorType *ot);