Todo items:
- File Window: when opened with operator (save, load, etc), you couldn't start a new one, causing memleaks. Now it nicely refreshes file window for new operator. Also means you can make CTRL+F3 screenies of filewindow now. - CTRL+F3 screenshot had memleak on cancel.
This commit is contained in:
@@ -1103,10 +1103,12 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
|
||||
|
||||
/*send space change notifyer*/
|
||||
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa);
|
||||
|
||||
ED_area_tag_redraw(sa);
|
||||
|
||||
ED_area_tag_refresh(sa);
|
||||
}
|
||||
|
||||
/* also redraw when re-used */
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
|
||||
void ED_area_prevspace(bContext *C, ScrArea *sa)
|
||||
|
||||
@@ -70,29 +70,31 @@ static int screenshot_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ScreenshotData *scd= op->customdata;
|
||||
|
||||
if(scd && scd->dumprect) {
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ImBuf *ibuf;
|
||||
char path[FILE_MAX];
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", path);
|
||||
|
||||
strcpy(G.ima, path);
|
||||
BLI_path_abs(path, G.main->name);
|
||||
if(scd) {
|
||||
if(scd->dumprect) {
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
ImBuf *ibuf;
|
||||
char path[FILE_MAX];
|
||||
|
||||
/* BKE_add_image_extension() checks for if extension was already set */
|
||||
if(scene->r.scemode & R_EXTENSION)
|
||||
if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5)
|
||||
BKE_add_image_extension(path, scene->r.imtype);
|
||||
RNA_string_get(op->ptr, "filepath", path);
|
||||
|
||||
ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
|
||||
ibuf->rect= scd->dumprect;
|
||||
|
||||
BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
strcpy(G.ima, path);
|
||||
BLI_path_abs(path, G.main->name);
|
||||
|
||||
/* BKE_add_image_extension() checks for if extension was already set */
|
||||
if(scene->r.scemode & R_EXTENSION)
|
||||
if(strlen(path)<FILE_MAXDIR+FILE_MAXFILE-5)
|
||||
BKE_add_image_extension(path, scene->r.imtype);
|
||||
|
||||
ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0);
|
||||
ibuf->rect= scd->dumprect;
|
||||
|
||||
BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality);
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
||||
MEM_freeN(scd->dumprect);
|
||||
MEM_freeN(scd->dumprect);
|
||||
}
|
||||
MEM_freeN(scd);
|
||||
op->customdata= NULL;
|
||||
}
|
||||
@@ -159,6 +161,18 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
ScreenshotData *scd= op->customdata;
|
||||
|
||||
if(scd) {
|
||||
if(scd->dumprect)
|
||||
MEM_freeN(scd->dumprect);
|
||||
MEM_freeN(scd);
|
||||
op->customdata= NULL;
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void SCREEN_OT_screenshot(wmOperatorType *ot)
|
||||
{
|
||||
@@ -168,6 +182,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
|
||||
ot->invoke= screenshot_invoke;
|
||||
ot->exec= screenshot_exec;
|
||||
ot->poll= WM_operator_winactive;
|
||||
ot->cancel= screenshot_cancel;
|
||||
|
||||
ot->flag= 0;
|
||||
|
||||
|
||||
@@ -1893,14 +1893,20 @@ void WM_event_fileselect_event(bContext *C, void *ophandle, int eventval)
|
||||
|
||||
void WM_event_add_fileselect(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmEventHandler *handler;
|
||||
wmEventHandler *handler, *handlernext;
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
int full= 1; // XXX preset?
|
||||
|
||||
/* only allow file selector open per window bug [#23553] */
|
||||
for(handler= win->modalhandlers.first; handler; handler=handler->next) {
|
||||
if(handler->type == WM_HANDLER_FILESELECT)
|
||||
return;
|
||||
/* only allow 1 file selector open per window */
|
||||
for(handler= win->modalhandlers.first; handler; handler=handlernext) {
|
||||
handlernext= handler->next;
|
||||
|
||||
if(handler->type == WM_HANDLER_FILESELECT) {
|
||||
if(handler->op)
|
||||
WM_operator_free(handler->op);
|
||||
BLI_remlink(&win->modalhandlers, handler);
|
||||
wm_event_free_handler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
handler = MEM_callocN(sizeof(wmEventHandler), "fileselect handler");
|
||||
|
||||
Reference in New Issue
Block a user