[Bf-blender-cvs] [70924a7] master: Fix T38548: Edit externally always uses first frame only
Sergey Sharybin
noreply at git.blender.org
Wed Feb 26 00:59:26 CET 2014
Commit: 70924a7b2e018d18badfd731cac39702acfa5b08
Author: Sergey Sharybin
Date: Wed Feb 26 10:58:14 2014 +1100
https://developer.blender.org/rB70924a7b2e018d18badfd731cac39702acfa5b08
Fix T38548: Edit externally always uses first frame only
===================================================================
M release/scripts/startup/bl_operators/image.py
M source/blender/makesrna/intern/rna_image_api.c
===================================================================
diff --git a/release/scripts/startup/bl_operators/image.py b/release/scripts/startup/bl_operators/image.py
index 0d3d45d..1653459 100644
--- a/release/scripts/startup/bl_operators/image.py
+++ b/release/scripts/startup/bl_operators/image.py
@@ -90,8 +90,9 @@ class EditExternally(Operator):
def invoke(self, context, event):
import os
+ sd = context.space_data
try:
- image = context.space_data.image
+ image = sd.image
except AttributeError:
self.report({'ERROR'}, "Context incorrect, image not found")
return {'CANCELLED'}
@@ -100,7 +101,12 @@ class EditExternally(Operator):
self.report({'ERROR'}, "Image is packed, unpack before editing")
return {'CANCELLED'}
- filepath = bpy.path.abspath(image.filepath, library=image.library)
+ if sd.type == 'IMAGE_EDITOR':
+ filepath = image.filepath_from_user(sd.image_user)
+ else:
+ filepath = image.filepath
+
+ filepath = bpy.path.abspath(filepath, library=image.library)
self.filepath = os.path.normpath(filepath)
self.execute(context)
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index 8b6849a..57d74c9 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -37,6 +37,7 @@
#include "DNA_packedFile_types.h"
#include "BLI_utildefines.h"
+#include "BLI_path_util.h"
#include "BIF_gl.h"
@@ -277,6 +278,11 @@ static void rna_Image_gl_free(Image *image)
image->flag &= ~IMA_NOCOLLECT;
}
+static void rna_Image_filepath_from_user(Image *image, ImageUser *image_user, char *filepath)
+{
+ BKE_image_user_file_path(image_user, image, filepath);
+}
+
#else
void RNA_api_image(StructRNA *srna)
@@ -350,6 +356,15 @@ void RNA_api_image(StructRNA *srna)
func = RNA_def_function(srna, "gl_free", "rna_Image_gl_free");
RNA_def_function_ui_description(func, "Free the image from OpenGL graphics memory");
+ /* path to an frame specified by image user */
+ func = RNA_def_function(srna, "filepath_from_user", "rna_Image_filepath_from_user");
+ RNA_def_function_ui_description(func, "Return the absolute path to the filepath of an image frame specified by the image user");
+ RNA_def_pointer(func, "image_user", "ImageUser", "", "Image user of the image to get filepath for");
+ parm = RNA_def_string_file_path(func, "filepath", NULL, FILE_MAX, "File Path",
+ "The resulting filepath from the image and it's user");
+ RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
+ RNA_def_function_output(func, parm);
+
/* TODO, pack/unpack, maybe should be generic functions? */
}
More information about the Bf-blender-cvs
mailing list