diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-23 20:42:36 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-23 20:42:36 +0300 |
commit | 4531e8e6a731af71936d09bb79a15297685ff0dc (patch) | |
tree | de2f6a492c6b00d376de9084612e8c470de202a3 | |
parent | 66437a62a73966de8ccb673473ba69d6c1ed66a3 (diff) |
2.5
File reading of 2.50 files fixed.
- it now exits nicely from queues without using free'd memory
(checks CTX_wm_window(C) to be NULL)
- code that matched current (ghost) window with new situation
lacked setting a pointer good.
Overall cleaned some parts too; like context clears now all
wm related pointers when you set a new wm, window or area.
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm.c | 4 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 27 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 10 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 28 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 27 |
6 files changed, 70 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 81712acee5c..2a24e5a9d0f 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -197,6 +197,10 @@ struct uiBlock *CTX_wm_ui_block(const bContext *C) void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { C->wm.manager= wm; + C->wm.window= NULL; + C->wm.screen= NULL; + C->wm.area= NULL; + C->wm.region= NULL; } void CTX_wm_window_set(bContext *C, wmWindow *win) @@ -204,17 +208,22 @@ void CTX_wm_window_set(bContext *C, wmWindow *win) C->wm.window= win; C->wm.screen= (win)? win->screen: NULL; C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL; + C->wm.area= NULL; + C->wm.region= NULL; } void CTX_wm_screen_set(bContext *C, bScreen *screen) { C->wm.screen= screen; C->data.scene= (C->wm.screen)? C->wm.screen->scene: NULL; + C->wm.area= NULL; + C->wm.region= NULL; } void CTX_wm_area_set(bContext *C, ScrArea *area) { C->wm.area= area; + C->wm.region= NULL; } void CTX_wm_region_set(bContext *C, ARegion *region) diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 164a49ac63d..d264b096012 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -100,7 +100,7 @@ void wm_check(bContext *C) wmWindowManager *wm= CTX_wm_manager(C); /* wm context */ - if(CTX_wm_manager(C)==NULL) { + if(wm==NULL) { wm= CTX_data_main(C)->wm.first; CTX_wm_manager_set(C, wm); } @@ -118,6 +118,8 @@ void wm_check(bContext *C) ED_screens_initialize(wm); wm->initialized= 1; + + WM_event_add_notifier(C, NC_WINDOW, NULL); } } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 0746322e336..344cd73b727 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -135,6 +135,9 @@ void wm_event_do_notifiers(bContext *C) wmNotifier *note; wmWindow *win; + if(wm==NULL) + return; + /* cache & catch WM level notifiers, such as frame change */ /* XXX todo, multiwindow scenes */ for(win= wm->windows.first; win; win= win->next) { @@ -194,7 +197,6 @@ void wm_event_do_notifiers(bContext *C) ED_area_do_refresh(C, sa); } } - CTX_wm_area_set(C, NULL); } CTX_wm_window_set(C, NULL); } @@ -686,6 +688,9 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) break; } + /* fileread case */ + if(CTX_wm_window(C)==NULL) + break; } return action; } @@ -794,6 +799,12 @@ void wm_event_do_handlers(bContext *C) action= wm_handlers_do(C, event, &win->handlers); + /* fileread case */ + if(CTX_wm_window(C)==NULL) { + wm_event_free(event); + break; + } + if(wm_event_always_pass(event) || action==WM_HANDLER_CONTINUE) { ScrArea *sa; ARegion *ar; @@ -843,6 +854,10 @@ void wm_event_do_handlers(bContext *C) CTX_wm_area_set(C, NULL); CTX_wm_region_set(C, NULL); } + + /* fileread case */ + if(CTX_wm_window(C)==NULL) + break; } } @@ -867,12 +882,12 @@ wmEventHandler *WM_event_add_modal_handler(bContext *C, ListBase *handlers, wmOp wmEventHandler *WM_event_add_keymap_handler(ListBase *handlers, ListBase *keymap) { wmEventHandler *handler; - + /* only allow same keymap once */ for(handler= handlers->first; handler; handler= handler->next) if(handler->keymap==keymap) return handler; - + handler= MEM_callocN(sizeof(wmEventHandler), "event keymap handler"); BLI_addtail(handlers, handler); handler->keymap= keymap; @@ -897,9 +912,11 @@ wmEventHandler *WM_event_add_keymap_handler_priority(ListBase *handlers, ListBas wmEventHandler *WM_event_add_keymap_handler_bb(ListBase *handlers, ListBase *keymap, rcti *bblocal, rcti *bbwin) { wmEventHandler *handler= WM_event_add_keymap_handler(handlers, keymap); - handler->bblocal= bblocal; - handler->bbwin= bbwin; + if(handler) { + handler->bblocal= bblocal; + handler->bbwin= bbwin; + } return handler; } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 684f133c973..20258f3f2d3 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -78,6 +78,8 @@ #include "ED_screen.h" #include "ED_util.h" +#include "GHOST_C-api.h" + #include "UI_interface.h" // XXX #include "BPY_extern.h" @@ -462,7 +464,11 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) if(oldwin->winid == win->winid ) { win->ghostwin= oldwin->ghostwin; + GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ oldwin->ghostwin= NULL; + + win->eventstate= oldwin->eventstate; + oldwin->eventstate= NULL; } } } @@ -492,6 +498,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); + wm_check(C); /* opens window(s), checks keymaps */ // XXX mainwindow_set_filename_to_title(G.main->name); // countall(); <-- will be listener @@ -549,7 +556,8 @@ int WM_read_homefile(bContext *C, int from_memory) /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); - + wm_check(C); /* opens window(s), checks keymaps */ + strcpy(G.sce, scestr); /* restore */ init_userdef_themes(); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index dc36cf2d62c..01e4cd10b3d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -93,20 +93,6 @@ #include "GPU_draw.h" -static void initbuttons(void) -{ - UI_init(); - -// glClearColor(.7f, .7f, .6f, 0.0); - - G.font= BMF_GetFont(BMF_kHelvetica12); - G.fonts= BMF_GetFont(BMF_kHelvetica10); - G.fontss= BMF_GetFont(BMF_kHelveticaBold8); - -// clear_matcopybuf(); /* XXX */ - -// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); -} /* XXX */ static void sound_init_listener(void) @@ -135,11 +121,17 @@ void WM_init(bContext *C) /* get the default database, plus a wm */ WM_read_homefile(C, 0); - wm_check(C); /* opens window(s), checks keymaps */ + UI_init(); + + /* goes away */ + G.font= BMF_GetFont(BMF_kHelvetica12); + G.fonts= BMF_GetFont(BMF_kHelvetica10); + G.fontss= BMF_GetFont(BMF_kHelveticaBold8); + + // clear_matcopybuf(); /* XXX */ + + // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); -// initscreen(); /* for (visual) speed, this first, then setscreen */ - initbuttons(); -// InitCursorData(); sound_init_listener(); // init_node_butfuncs(); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 130d72dffd8..06ec8f6819a 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -102,6 +102,8 @@ void wm_window_free(bContext *C, wmWindow *win) wm->winactive= NULL; if(CTX_wm_window(C)==win) CTX_wm_window_set(C, NULL); + + WM_event_remove_handlers(C, &win->handlers); } if(win->eventstate) MEM_freeN(win->eventstate); @@ -160,14 +162,13 @@ wmWindow *wm_window_copy(bContext *C, wmWindow *winorig) return win; } -/* this is event from ghost */ +/* this is event from ghost, or exit-blender op */ static void wm_window_close(bContext *C, wmWindow *win) { wmWindowManager *wm= CTX_wm_manager(C); BLI_remlink(&wm->windows, win); wm_draw_window_clear(win); - WM_event_remove_handlers(C, &win->handlers); ED_screen_exit(C, win, win->screen); wm_window_free(C, win); @@ -203,7 +204,6 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow 0 /* no stereo */); if (ghostwin) { - ListBase *keymap; win->ghostwin= ghostwin; GHOST_SetWindowUserData(ghostwin, win); /* pointer back */ @@ -211,13 +211,6 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow if(win->eventstate==NULL) win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); - /* add keymap handlers (1 handler for all keys in map!) */ - keymap= WM_keymap_listbase(wm, "Window", 0, 0); - WM_event_add_keymap_handler(&win->handlers, keymap); - - keymap= WM_keymap_listbase(wm, "Screen", 0, 0); - WM_event_add_keymap_handler(&win->handlers, keymap); - /* until screens get drawn, make it nice grey */ glClearColor(.55, .55, .55, 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -232,8 +225,10 @@ static void wm_window_add_ghostwindow(wmWindowManager *wm, char *title, wmWindow /* for wmWindows without ghostwin, open these and clear */ /* window size is read from window, if 0 it uses prefsize */ +/* called in wm_check, also inits stuff after file read */ void wm_window_add_ghostwindows(wmWindowManager *wm) { + ListBase *keymap; wmWindow *win; /* no commandline prefsize? then we set this */ @@ -264,6 +259,18 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) } wm_window_add_ghostwindow(wm, "Blender", win); } + /* happens after fileread */ + if(win->eventstate==NULL) + win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state"); + + + /* add keymap handlers (1 handler for all keys in map!) */ + keymap= WM_keymap_listbase(wm, "Window", 0, 0); + WM_event_add_keymap_handler(&win->handlers, keymap); + + keymap= WM_keymap_listbase(wm, "Screen", 0, 0); + WM_event_add_keymap_handler(&win->handlers, keymap); + } } |