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:
Diffstat (limited to 'source/blender/editors/screen/screendump.c')
-rw-r--r--source/blender/editors/screen/screendump.c53
1 files changed, 34 insertions, 19 deletions
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;