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
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2011-01-04 17:37:21 +0300
committerTon Roosendaal <ton@blender.org>2011-01-04 17:37:21 +0300
commit8b1bfbcfea8af306dbf42743b5f67d46159015c5 (patch)
tree8e0b3b9a2b193b679ffa0048dfacc7369481c169
parentc2bc82c9fcd14bcaec14e54c867757baa45b52d6 (diff)
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.
-rw-r--r--source/blender/editors/screen/area.c6
-rw-r--r--source/blender/editors/screen/screendump.c53
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c16
3 files changed, 49 insertions, 26 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index fd8afd63bb8..c482ba4a9e8 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -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)
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index a536b4ea1a4..d4235a09d37 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -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;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 7ad52f8fcb1..b84a00097b1 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -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");