kanarip / rpms / blender

Forked from rpms/blender 5 years ago
Clone
60bb507
--- a/intern/cycles/blender/blender_python.cpp
60bb507
+++ b/intern/cycles/blender/blender_python.cpp
83c72d2
@@ -493,7 +493,7 @@ static PyObject *osl_update_node_func(Py
60bb507
 				socket_type = "NodeSocketString";
60bb507
 				data_type = BL::NodeSocket::type_STRING;
60bb507
 				if(param->validdefault)
60bb507
-					default_string = param->sdefault[0];
60bb507
+					default_string = param->sdefault[0].string();
60bb507
 			}
60bb507
 			else
60bb507
 				continue;
60bb507
--- a/intern/cycles/graph/node_xml.cpp
60bb507
+++ b/intern/cycles/graph/node_xml.cpp
83c72d2
@@ -250,7 +250,7 @@ void xml_read_node(XMLReader& reader, No
60bb507
 		}
60bb507
 	}
60bb507
 
60bb507
-	if(node->name)
60bb507
+	if(!node->name.empty())
60bb507
 		reader.node_map[node->name] = node;
60bb507
 }
60bb507
 
18c1f6b
--- a/intern/cycles/render/buffers.cpp
18c1f6b
+++ b/intern/cycles/render/buffers.cpp
18c1f6b
@@ -27,6 +27,7 @@
18c1f6b
 #include "util/util_opengl.h"
18c1f6b
 #include "util/util_time.h"
18c1f6b
 #include "util/util_types.h"
60bb507
+#include "util/util_unique_ptr.h"
60bb507
 
60bb507
 CCL_NAMESPACE_BEGIN
60bb507
 
83c72d2
@@ -453,7 +454,7 @@ void DisplayBuffer::write(Device *device
18c1f6b
 	device->pixels_copy_from(rgba, 0, w, h);
18c1f6b
 
18c1f6b
 	/* write image */
18c1f6b
-	ImageOutput *out = ImageOutput::create(filename);
18c1f6b
+	unique_ptr<ImageOutput> out(ImageOutput::create(filename));
18c1f6b
 	ImageSpec spec(w, h, 4, TypeDesc::UINT8);
18c1f6b
 	int scanlinesize = w*4*sizeof(uchar);
18c1f6b
 
83c72d2
@@ -467,8 +468,6 @@ void DisplayBuffer::write(Device *device
18c1f6b
 		AutoStride);
18c1f6b
 
18c1f6b
 	out->close();
18c1f6b
-
18c1f6b
-	delete out;
18c1f6b
 }
18c1f6b
 
18c1f6b
 device_memory& DisplayBuffer::rgba_data()
60bb507
--- a/intern/cycles/render/image.cpp
60bb507
+++ b/intern/cycles/render/image.cpp
60bb507
@@ -23,6 +23,7 @@
60bb507
 #include "util/util_path.h"
60bb507
 #include "util/util_progress.h"
60bb507
 #include "util/util_texture.h"
60bb507
+#include "util/util_unique_ptr.h"
60bb507
 
60bb507
 #ifdef WITH_OSL
60bb507
 #include <OSL/oslexec.h>
83c72d2
@@ -148,7 +149,7 @@ ImageDataType ImageManager::get_image_me
60bb507
 		return IMAGE_DATA_TYPE_BYTE4;
60bb507
 	}
60bb507
 
60bb507
-	ImageInput *in = ImageInput::create(filename);
60bb507
+	unique_ptr<ImageInput> in(ImageInput::create(filename));
60bb507
 
60bb507
 	if(in) {
60bb507
 		ImageSpec spec;
83c72d2
@@ -193,8 +194,6 @@ ImageDataType ImageManager::get_image_me
18c1f6b
 
60bb507
 			in->close();
60bb507
 		}
18c1f6b
-
60bb507
-		delete in;
60bb507
 	}
60bb507
 
60bb507
 	if(is_half) {
83c72d2
@@ -449,7 +448,7 @@ void ImageManager::tag_reload_image(cons
60bb507
 }
60bb507
 
60bb507
 bool ImageManager::file_load_image_generic(Image *img,
60bb507
-                                           ImageInput **in,
60bb507
+                                           unique_ptr<ImageInput> *in,
60bb507
                                            int &width,
60bb507
                                            int &height,
60bb507
                                            int &depth,
83c72d2
@@ -465,7 +464,7 @@ bool ImageManager::file_load_image_gener
60bb507
 		}
60bb507
 
60bb507
 		/* load image from file through OIIO */
60bb507
-		*in = ImageInput::create(img->filename);
60bb507
+		*in = unique_ptr<ImageInput>(ImageInput::create(img->filename));
60bb507
 
60bb507
 		if(!*in)
60bb507
 			return false;
83c72d2
@@ -477,8 +476,6 @@ bool ImageManager::file_load_image_gener
60bb507
 			config.attribute("oiio:UnassociatedAlpha", 1);
60bb507
 
60bb507
 		if(!(*in)->open(img->filename, spec, config)) {
60bb507
-			delete *in;
60bb507
-			*in = NULL;
60bb507
 			return false;
60bb507
 		}
60bb507
 
83c72d2
@@ -500,10 +497,7 @@ bool ImageManager::file_load_image_gener
60bb507
 	if(!(components >= 1 && components <= 4)) {
60bb507
 		if(*in) {
60bb507
 			(*in)->close();
60bb507
-			delete *in;
60bb507
-			*in = NULL;
60bb507
 		}
60bb507
-
60bb507
 		return false;
60bb507
 	}
60bb507
 
83c72d2
@@ -519,7 +513,7 @@ bool ImageManager::file_load_image(Image
60bb507
                                    device_vector<DeviceType>& tex_img)
60bb507
 {
60bb507
 	const StorageType alpha_one = (FileFormat == TypeDesc::UINT8)? 255 : 1;
60bb507
-	ImageInput *in = NULL;
60bb507
+	unique_ptr<ImageInput> in = NULL;
60bb507
 	int width, height, depth, components;
60bb507
 	if(!file_load_image_generic(img, &in, width, height, depth, components)) {
60bb507
 		return false;
83c72d2
@@ -575,7 +569,6 @@ bool ImageManager::file_load_image(Image
60bb507
 		}
60bb507
 		cmyk = strcmp(in->format_name(), "jpeg") == 0 && components == 4;
60bb507
 		in->close();
60bb507
-		delete in;
60bb507
 	}
60bb507
 	else {
60bb507
 		if(FileFormat == TypeDesc::FLOAT) {
18c1f6b
--- a/intern/cycles/render/image.h
18c1f6b
+++ b/intern/cycles/render/image.h
18c1f6b
@@ -23,6 +23,7 @@
18c1f6b
 #include "util/util_image.h"
18c1f6b
 #include "util/util_string.h"
18c1f6b
 #include "util/util_thread.h"
18c1f6b
+#include "util/util_unique_ptr.h"
18c1f6b
 #include "util/util_vector.h"
18c1f6b
 
18c1f6b
 CCL_NAMESPACE_BEGIN
18c1f6b
@@ -133,7 +134,7 @@ private:
18c1f6b
 	bool pack_images;
18c1f6b
 
18c1f6b
 	bool file_load_image_generic(Image *img,
18c1f6b
-	                             ImageInput **in,
18c1f6b
+	                             unique_ptr<ImageInput> *in,
18c1f6b
 	                             int &width,
18c1f6b
 	                             int &height,
18c1f6b
 	                             int &depth,
60bb507
--- /dev/null
60bb507
+++ b/intern/cycles/util/util_unique_ptr.h
60bb507
@@ -0,0 +1,28 @@
60bb507
+/*
60bb507
+ * Copyright 2011-2013 Blender Foundation
60bb507
+ *
60bb507
+ * Licensed under the Apache License, Version 2.0 (the "License");
60bb507
+ * you may not use this file except in compliance with the License.
60bb507
+ * You may obtain a copy of the License at
60bb507
+ *
60bb507
+ * http://www.apache.org/licenses/LICENSE-2.0
60bb507
+ *
60bb507
+ * Unless required by applicable law or agreed to in writing, software
60bb507
+ * distributed under the License is distributed on an "AS IS" BASIS,
60bb507
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60bb507
+ * See the License for the specific language governing permissions and
60bb507
+ * limitations under the License.
60bb507
+ */
60bb507
+
60bb507
+#ifndef __UTIL_UNIQUE_PTR_H__
60bb507
+#define __UTIL_UNIQUE_PTR_H__
60bb507
+
60bb507
+#include <memory>
60bb507
+
60bb507
+CCL_NAMESPACE_BEGIN
60bb507
+
60bb507
+using std::unique_ptr;
60bb507
+
60bb507
+CCL_NAMESPACE_END
60bb507
+
60bb507
+#endif  /* __UTIL_UNIQUE_PTR_H__ */
60bb507
--- a/source/blender/imbuf/intern/oiio/openimageio_api.cpp
60bb507
+++ b/source/blender/imbuf/intern/oiio/openimageio_api.cpp
60bb507
@@ -35,6 +35,11 @@
60bb507
 #include "utfconv.h"
60bb507
 #endif
60bb507
 
60bb507
+// NOTE: Keep first, BLI_path_util conflicts with OIIO's format.
60bb507
+#include <memory>
60bb507
+#include <openimageio_api.h>
60bb507
+#include <OpenImageIO/imageio.h>
60bb507
+
60bb507
 extern "C"
60bb507
 {
60bb507
 #include "MEM_guardedalloc.h"
60bb507
@@ -48,12 +53,10 @@ extern "C"
60bb507
 #include "IMB_colormanagement_intern.h"
60bb507
 }
60bb507
 
60bb507
-#include <openimageio_api.h>
60bb507
-#include <OpenImageIO/imageio.h>
60bb507
-
60bb507
 OIIO_NAMESPACE_USING
60bb507
 
60bb507
 using std::string;
60bb507
+using std::unique_ptr;
60bb507
 
60bb507
 typedef unsigned char uchar;
60bb507
 
83c72d2
@@ -197,7 +200,6 @@ int imb_save_photoshop(struct ImBuf *ibu
60bb507
 
60bb507
 struct ImBuf *imb_load_photoshop(const char *filename, int flags, char colorspace[IM_MAX_SPACE])
60bb507
 {
60bb507
-	ImageInput *in = NULL;
60bb507
 	struct ImBuf *ibuf = NULL;
60bb507
 	int width, height, components;
60bb507
 	bool is_float, is_alpha;
83c72d2
@@ -210,7 +212,7 @@ struct ImBuf *imb_load_photoshop(const c
60bb507
 
60bb507
 	colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
60bb507
 
60bb507
-	in = ImageInput::create(filename);
60bb507
+	unique_ptr<ImageInput> in(ImageInput::create(filename));
60bb507
 	if (!in) {
60bb507
 		std::cerr << __func__ << ": ImageInput::create() failed:" << std::endl
60bb507
 		          << OIIO_NAMESPACE::geterror() << std::endl;
83c72d2
@@ -223,7 +225,6 @@ struct ImBuf *imb_load_photoshop(const c
60bb507
 	if (!in->open(filename, spec, config)) {
60bb507
 		std::cerr << __func__ << ": ImageInput::open() failed:" << std::endl
60bb507
 		          << in->geterror() << std::endl;
60bb507
-		delete in;
60bb507
 		return NULL;
60bb507
 	}
60bb507
 
83c72d2
@@ -249,19 +250,17 @@ struct ImBuf *imb_load_photoshop(const c
60bb507
 	if (!(components >= 1 && components <= 4)) {
60bb507
 		if (in) {
60bb507
 			in->close();
60bb507
-			delete in;
60bb507
 		}
60bb507
 		return NULL;
60bb507
 	}
60bb507
 
60bb507
 	if (is_float)
60bb507
-		ibuf = imb_oiio_load_image_float(in, width, height, components, flags, is_alpha);
60bb507
+		ibuf = imb_oiio_load_image_float(in.get(), width, height, components, flags, is_alpha);
60bb507
 	else
60bb507
-		ibuf = imb_oiio_load_image(in, width, height, components, flags, is_alpha);
60bb507
+		ibuf = imb_oiio_load_image(in.get(), width, height, components, flags, is_alpha);
60bb507
 
60bb507
 	if (in) {
60bb507
 		in->close();
60bb507
-		delete in;
60bb507
 	}
60bb507
 
83c72d2
 	if (!ibuf)