Skip to content

Commit 29bd217

Browse files
authored
Cherry picked fixes for proposed 1.1.x release (#678)
* Fix wrong display returned by getDefaultDisplay() (#638) * Fix window-specific issue in GetEnv() While the content of result was correct, its length was set to a wrong size. This is a patch by Patrick Hodoul. * Fix wrong display returned by getDefaultDisplay() Solved by ignoring environment variable if it's an empty string. Ideally, need to test it to be NULL instead to support obscure case when empty string is passed. Unfortunately, this is not possible with the current API, and is unlikely scenario anyway. The issue was caused by wrong logic around parsing display/views override environment variable: if it is missing, it was converted to an empty string. That empty string was considered an override of one element display, with an empty name. Additionally, make it so getDisplay() returns displays in order of either active_displays configuration variable or environment variable override. the issue there was caused by wrong order of arguments to vector intersection. Conflicts: src/OpenColorIO/Platform.cpp src/core/Config.cpp This commit was cherry-picked from 718cc7f. Changes were made for compatibility with the older version of Platform.cpp; mainly reverting "Getenv" to "getenv". * Add Compatibility with OIIO 1.9+ API changes (#601) This fix adds compatibility with OIIO 1.9+, minor ImageInput/ImageOutput API changes. At a certain point ImageInput::create switched from returning a raw pointer (that later needed to be deleted) to returning a std::unique_ptr. * Correct ImageInput/ImageOutput swaps * Restore C++03 compat when using old OIIO (#682) We recently tried to change the OCIO code so that it would build against both OIIO 2.0 as well as the older 1.x versions. In doing so, we inadvertently broke OCIO for C++03. This patch still requires C++11 when building against OIIO 2.x (it has to), but is fine with C++03 if using older OIIO. (cherry picked from commit 65a08db) * Add note about C++11 requirement when building with newer OIIO version * Add error directive to apps when incompatable C++ std and OIIO lib are used
1 parent 52e4e59 commit 29bd217

File tree

6 files changed

+443
-15
lines changed

6 files changed

+443
-15
lines changed

src/apps/ocioconvert/main.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ namespace OCIO = OCIO_NAMESPACE;
3939
namespace OIIO = OIIO_NAMESPACE;
4040
#endif
4141

42+
#if OIIO_VERSION >= 10903 && __cplusplus < 201103
43+
#error While not officially supported, compile with C++11 (or higher) to use OIIO versions 1.9.3 or newer
44+
#endif
4245

4346
#include "argparse.h"
4447

@@ -119,7 +122,11 @@ int main(int argc, const char **argv)
119122
std::cerr << "Loading " << inputimage << std::endl;
120123
try
121124
{
125+
#if OIIO_VERSION < 10903
122126
OIIO::ImageInput* f = OIIO::ImageInput::create(inputimage);
127+
#else
128+
auto f = OIIO::ImageInput::create(inputimage);
129+
#endif
123130
if(!f)
124131
{
125132
std::cerr << "Could not create image input." << std::endl;
@@ -143,7 +150,9 @@ int main(int argc, const char **argv)
143150
memset(&img[0], 0, imgwidth*imgheight*components*sizeof(float));
144151

145152
f->read_image(OIIO::TypeDesc::TypeFloat, &img[0]);
146-
delete f;
153+
#if OIIO_VERSION < 10903
154+
OIIO::ImageInput::destroy(f);
155+
#endif
147156

148157
std::vector<int> kchannels;
149158
//parse --ch argument
@@ -308,7 +317,11 @@ int main(int argc, const char **argv)
308317
// Write out the result
309318
try
310319
{
320+
#if OIIO_VERSION < 10903
311321
OIIO::ImageOutput* f = OIIO::ImageOutput::create(outputimage);
322+
#else
323+
auto f = OIIO::ImageOutput::create(outputimage);
324+
#endif
312325
if(!f)
313326
{
314327
std::cerr << "Could not create output input." << std::endl;
@@ -318,7 +331,9 @@ int main(int argc, const char **argv)
318331
f->open(outputimage, spec);
319332
f->write_image(OIIO::TypeDesc::FLOAT, &img[0]);
320333
f->close();
321-
delete f;
334+
#if OIIO_VERSION < 10903
335+
OIIO::ImageOutput::destroy(f);
336+
#endif
322337
}
323338
catch(...)
324339
{

src/apps/ociodisplay/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ namespace OCIO = OCIO_NAMESPACE;
4141

4242
#include <OpenImageIO/imageio.h>
4343
#include <OpenImageIO/typedesc.h>
44-
#if (OIIO_VERSION < 10100)
45-
namespace OIIO = OIIO_NAMESPACE;
44+
45+
#if OIIO_VERSION >= 10903 && __cplusplus < 201103
46+
#error While not officially supported, compile with C++11 (or higher) to use OIIO versions 1.9.3 or newer
4647
#endif
4748

4849
#ifdef __APPLE__
@@ -106,7 +107,11 @@ static void InitImageTexture(const char * filename)
106107
std::cout << "loading: " << filename << std::endl;
107108
try
108109
{
110+
#if OIIO_VERSION < 10903
109111
OIIO::ImageInput* f = OIIO::ImageInput::create(filename);
112+
#else
113+
auto f = OIIO::ImageInput::create(filename);
114+
#endif
110115
if(!f)
111116
{
112117
std::cerr << "Could not create image input." << std::endl;
@@ -137,7 +142,9 @@ static void InitImageTexture(const char * filename)
137142
OIIO::TypeDesc::TypeFloat,
138143
#endif
139144
&img[0]);
145+
#if OIIO_VERSION < 10903
140146
OIIO::ImageInput::destroy(f);
147+
#endif
141148
}
142149
catch(...)
143150
{

src/apps/ociolutimage/main.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ OCIO_NAMESPACE_USING;
3232

3333
#include <OpenImageIO/imageio.h>
3434
#include <OpenImageIO/typedesc.h>
35-
#if (OIIO_VERSION < 10100)
36-
namespace OIIO = OIIO_NAMESPACE;
35+
36+
#if OIIO_VERSION >= 10903 && __cplusplus < 201103
37+
#error While not officially supported, compile with C++11 (or higher) to use OIIO versions 1.9.3 or newer
3738
#endif
3839

3940
#include "argparse.h"
@@ -116,7 +117,11 @@ void Generate(int cubesize, int maxwidth,
116117
processor->apply(imgdesc);
117118
}
118119

120+
#if OIIO_VERSION < 10903
119121
OIIO::ImageOutput* f = OIIO::ImageOutput::create(outputfile);
122+
#else
123+
auto f = OIIO::ImageOutput::create(outputfile);
124+
#endif
120125
if(!f)
121126
{
122127
throw Exception( "Could not create output image.");
@@ -128,7 +133,9 @@ void Generate(int cubesize, int maxwidth,
128133
f->open(outputfile, spec);
129134
f->write_image(OIIO::TypeDesc::FLOAT, &img[0]);
130135
f->close();
131-
delete f;
136+
#if OIIO_VERSION < 10903
137+
OIIO::ImageOutput::destroy(f);
138+
#endif
132139
}
133140

134141

@@ -137,7 +144,11 @@ void Extract(int cubesize, int maxwidth,
137144
const std::string & outputfile)
138145
{
139146
// Read the image
147+
#if OIIO_VERSION < 10903
140148
OIIO::ImageInput* f = OIIO::ImageInput::create(inputfile);
149+
#else
150+
auto f = OIIO::ImageInput::create(inputfile);
151+
#endif
141152
if(!f)
142153
{
143154
throw Exception("Could not create input image.");
@@ -183,7 +194,9 @@ void Extract(int cubesize, int maxwidth,
183194
std::vector<float> img;
184195
img.resize(spec.width*spec.height*spec.nchannels, 0);
185196
f->read_image(OIIO::TypeDesc::TypeFloat, &img[0]);
186-
delete f;
197+
#if OIIO_VERSION < 10903
198+
OIIO::ImageInput::destroy(f);
199+
#endif
187200

188201
// Repack into rgb
189202
// Convert the RGB[...] image to an RGB image, in place.

0 commit comments

Comments
 (0)