/** * Cause a delayed WM_exit() call to avoid leaking memory when trying to exit from within operators. */ void wm_exit_schedule_delayed(const bContext *C) { /* What we do here is a little bit hacky, but quite simple and doesn't require bigger * changes: Add a handler wrapping WM_exit() to cause a delayed call of it. */ wmWindow *win = CTX_wm_window(C); /* Use modal UI handler for now. Could add separate WM handlers or so, but probably not worth it. */ WM_event_add_ui_handler(C, &win->modalhandlers, wm_exit_handler, NULL, NULL, 0); WM_event_add_mousemove(C); /* ensure handler actually gets called */ }
static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state) { uiHandlePanelData *data= pa->activedata; wmWindow *win= CTX_wm_window(C); ARegion *ar= CTX_wm_region(C); if(data && data->state == state) return; if(state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) { if(data && data->state != PANEL_STATE_ANIMATION) { /* XXX: * - the panel tabbing function call below (test_add_new_tabs()) has been commented out * "It is too easy to do by accident when reordering panels, is very hard to control and use, and has no real benefit." - BillRey * Aligorith, 2009Sep */ //test_add_new_tabs(ar); // also copies locations of tabs in dragged panel check_panel_overlap(ar, NULL); // clears } pa->flag &= ~PNL_SELECT; } else pa->flag |= PNL_SELECT; if(data && data->animtimer) { WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer); data->animtimer= NULL; } if(state == PANEL_STATE_EXIT) { MEM_freeN(data); pa->activedata= NULL; WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa); } else { if(!data) { data= MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData"); pa->activedata= data; WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa); } if(ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) data->animtimer= WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL); data->state= state; data->startx= win->eventstate->x; data->starty= win->eventstate->y; data->startofsx= pa->ofsx; data->startofsy= pa->ofsy; data->startsizex= pa->sizex; data->startsizey= pa->sizey; data->starttime= PIL_check_seconds_timer(); } ED_region_tag_redraw(ar); /* XXX exception handling, 3d window preview panel */ /* if(block->drawextra==BIF_view3d_previewdraw) BIF_view3d_previewrender_clear(curarea);*/ /* XXX exception handling, 3d window preview panel */ /* if(block->drawextra==BIF_view3d_previewdraw) BIF_view3d_previewrender_signal(curarea, PR_DISPRECT); else if(strcmp(block->name, "image_panel_preview")==0) image_preview_event(2); */ }