diff --git a/VVGL/src/GLBufferPool.cpp b/VVGL/src/GLBufferPool.cpp index 1ead25a..bf1b19d 100644 --- a/VVGL/src/GLBufferPool.cpp +++ b/VVGL/src/GLBufferPool.cpp @@ -2126,8 +2126,21 @@ GLBufferRef CreateBufferForQImage(QImage * inImg, const bool & createInCurrentCo desc.texClientStorageFlag = true; desc.msAmount = 0; desc.localSurfaceID = 0; + + // this bit copies the image data to a manually-allocated block of memory. i'm not sure why, but if i don't do this, i get crashes under some circumstances + void *tmpData = malloc(desc.backingLengthForSize(gpuSize)); + char *rPtr = static_cast(pixelData); + char *wPtr = static_cast(tmpData); + int rLineStride = inImg->bytesPerLine(); + int rBytesPerLine = imgSize.width * 32 / 8; + for (int i=0; icreateBufferRef(desc, gpuSize, pixelData, repSize, createInCurrentContext); + //GLBufferRef returnMe = inPoolRef->createBufferRef(desc, gpuSize, pixelData, repSize, createInCurrentContext); + GLBufferRef returnMe = inPoolRef->createBufferRef(desc, gpuSize, tmpData, repSize, createInCurrentContext); returnMe->parentBufferPool = inPoolRef; returnMe->srcRect = VVGL::Rect(0,0,imgSize.width,imgSize.height); returnMe->backingID = GLBuffer::BackingID_None; @@ -2136,6 +2149,8 @@ GLBufferRef CreateBufferForQImage(QImage * inImg, const bool & createInCurrentCo returnMe->flipped = true; returnMe->preferDeletion = true; + + free(tmpData); return returnMe; } diff --git a/VVISF/include/ISFScene.hpp b/VVISF/include/ISFScene.hpp index 5886da7..3f54672 100644 --- a/VVISF/include/ISFScene.hpp +++ b/VVISF/include/ISFScene.hpp @@ -81,7 +81,7 @@ class VVISF_EXPORT ISFScene : public VVGL::GLScene { //! Unloads whatever ISF file is currently loaded. void useFile() noexcept(false); //! Loads the ISF file at the passed path. - void useFile(const string & inPath) noexcept(false); + void useFile(const string & inPath, const bool & inThrowExc=true) noexcept(false); //! Starts using the ISF file represented by the passed ISFDoc. void useDoc(ISFDocRef & inDoc); //! Returns the ISFDoc currently being used by the scene. Interacting with this doc by setting the value of its inputs will directly affect rendering. diff --git a/VVISF/include/nlohmann_json/json.hpp b/VVISF/include/nlohmann_json/json.hpp index c9ef758..c9af0be 100644 --- a/VVISF/include/nlohmann_json/json.hpp +++ b/VVISF/include/nlohmann_json/json.hpp @@ -1,10 +1,11 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.1.2 +| | |__ | | | | | | version 3.5.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . +SPDX-License-Identifier: MIT Copyright (c) 2013-2018 Niels Lohmann . Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,8 +31,8 @@ SOFTWARE. #define NLOHMANN_JSON_HPP #define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 1 -#define NLOHMANN_JSON_VERSION_PATCH 2 +#define NLOHMANN_JSON_VERSION_MINOR 5 +#define NLOHMANN_JSON_VERSION_PATCH 0 #include // all_of, find, for_each #include // assert @@ -40,7 +41,7 @@ SOFTWARE. #include // hash, less #include // initializer_list #include // istream, ostream -#include // iterator_traits, random_access_iterator_tag +#include // random_access_iterator_tag #include // accumulate #include // string, stoi, to_string #include // declval, forward, move, pair, swap @@ -66,10 +67,10 @@ namespace nlohmann @brief default JSONSerializer template argument This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](http://en.cppreference.com/w/cpp/language/adl)) +([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) for serialization. */ -template +template struct adl_serializer; template class ObjectType = @@ -107,7 +108,7 @@ uses the standard template types. @since version 1.0.0 */ using json = basic_json<>; -} +} // namespace nlohmann #endif @@ -118,13 +119,15 @@ using json = basic_json<>; // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them // exclude unsupported compilers -#if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif -#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif #endif #endif @@ -154,10 +157,12 @@ using json = basic_json<>; #define JSON_THROW(exception) throw exception #define JSON_TRY try #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) #else #define JSON_THROW(exception) std::abort() #define JSON_TRY if(true) #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) #endif // override exception macros @@ -172,6 +177,12 @@ using json = basic_json<>; #if defined(JSON_CATCH_USER) #undef JSON_CATCH #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif // manual branch prediction @@ -191,6 +202,37 @@ using json = basic_json<>; #define JSON_HAS_CPP_14 #endif +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. @@ -207,62 +249,17 @@ using json = basic_json<>; NumberIntegerType, NumberUnsignedType, NumberFloatType, \ AllocatorType, JSONSerializer> -/*! -@brief Helper to determine whether there's a key_type for T. - -This helper is used to tell associative containers apart from other containers -such as sequence containers. For instance, `std::map` passes the test as it -contains a `mapped_type`, whereas `std::vector` fails the test. - -@sa http://stackoverflow.com/a/7728728/266378 -@since version 1.0.0, overworked in version 2.0.6 -*/ -#define NLOHMANN_JSON_HAS_HELPER(type) \ - template struct has_##type { \ - private: \ - template \ - static int detect(U &&); \ - static void detect(...); \ - public: \ - static constexpr bool value = \ - std::is_integral()))>::value; \ - } - -// #include +// #include #include // not #include // size_t -#include // numeric_limits #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // declval - -// #include - -// #include - namespace nlohmann { -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ namespace detail { -///////////// -// helpers // -///////////// - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - // alias templates to reduce boilerplate template using enable_if_t = typename std::enable_if::type; @@ -301,321 +298,665 @@ template<> struct make_index_sequence<1> : index_sequence<0> {}; template using index_sequence_for = make_index_sequence; -/* -Implementation of two C++17 constructs: conjunction, negation. This is needed -to avoid evaluating all the traits in a condition +// dispatch utility (taken from ranges-v3) +template struct priority_tag : priority_tag < N - 1 > {}; +template<> struct priority_tag<0> {}; -For example: not std::is_same::value and has_value_type::value -will not compile when T = void (on MSVC at least). Whereas -conjunction>, has_value_type>::value will -stop evaluating if negation<...>::value == false +// taken from ranges-v3 +template +struct static_const +{ + static constexpr T value{}; +}; -Please note that those constructs must be used with caution, since symbols can -become very long quickly (which can slow down compilation and cause MSVC -internal compiler errors). Only use it when you have to (see example ahead). -*/ -template struct conjunction : std::true_type {}; -template struct conjunction : B1 {}; -template -struct conjunction : std::conditional, B1>::type {}; +template +constexpr T static_const::value; +} // namespace detail +} // namespace nlohmann -template struct negation : std::integral_constant {}; +// #include -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; -//////////////////////// -// has_/is_ functions // -//////////////////////// +#include // not +#include // numeric_limits +#include // false_type, is_constructible, is_integral, is_same, true_type +#include // declval -// source: https://stackoverflow.com/a/37193089/4116453 +// #include -template -struct is_complete_type : std::false_type {}; +// #include -template -struct is_complete_type : std::true_type {}; -NLOHMANN_JSON_HAS_HELPER(mapped_type); -NLOHMANN_JSON_HAS_HELPER(key_type); -NLOHMANN_JSON_HAS_HELPER(value_type); -NLOHMANN_JSON_HAS_HELPER(iterator); +#include // random_access_iterator_tag -template -struct is_compatible_object_type_impl : std::false_type {}; +// #include -template -struct is_compatible_object_type_impl -{ - static constexpr auto value = - std::is_constructible::value and - std::is_constructible::value; -}; -template -struct is_compatible_object_type +namespace nlohmann +{ +namespace detail +{ +template struct make_void { - static auto constexpr value = is_compatible_object_type_impl < - conjunction>, - has_mapped_type, - has_key_type>::value, - typename BasicJsonType::object_t, CompatibleObjectType >::value; + using type = void; }; +template using void_t = typename make_void::type; +} // namespace detail +} // namespace nlohmann -template -struct is_basic_json_nested_type +// #include + + +namespace nlohmann +{ +namespace detail +{ +template +struct iterator_types {}; + +template +struct iterator_types < + It, + void_t> { - static auto constexpr value = std::is_same::value or - std::is_same::value or - std::is_same::value or - std::is_same::value; + using difference_type = typename It::difference_type; + using value_type = typename It::value_type; + using pointer = typename It::pointer; + using reference = typename It::reference; + using iterator_category = typename It::iterator_category; }; -template -struct is_compatible_array_type +// This is required as some compilers implement std::iterator_traits in a way that +// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. +template +struct iterator_traits { - static auto constexpr value = - conjunction>, - negation>, - negation>, - negation>, - has_value_type, - has_iterator>::value; }; -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl +template +struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> + : iterator_types { - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - std::is_constructible::value and - CompatibleLimits::is_integer and - RealLimits::is_signed == CompatibleLimits::is_signed; }; -template -struct is_compatible_integer_type +template +struct iterator_traits::value>> { - static constexpr auto value = - is_compatible_integer_type_impl < - std::is_integral::value and - not std::is_same::value, - RealIntegerType, CompatibleNumberIntegerType > ::value; + using iterator_category = std::random_access_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T*; + using reference = T&; }; +} +} -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json -{ - private: - // also check the return type of from_json - template::from_json( - std::declval(), std::declval()))>::value>> - static int detect(U&&); - static void detect(...); +// #include - public: - static constexpr bool value = std::is_integral>()))>::value; -}; +// #include -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json -{ - private: - template < - typename U, - typename = enable_if_t::from_json(std::declval()))>::value >> - static int detect(U&&); - static void detect(...); - public: - static constexpr bool value = std::is_integral>()))>::value; -}; +#include -// This trait checks if BasicJsonType::json_serializer::to_json exists -template -struct has_to_json -{ - private: - template::to_json( - std::declval(), std::declval()))> - static int detect(U&&); - static void detect(...); +// #include - public: - static constexpr bool value = std::is_integral>()))>::value; -}; -template -struct is_compatible_complete_type +// http://en.cppreference.com/w/cpp/experimental/is_detected +namespace nlohmann { - static constexpr bool value = - not std::is_base_of::value and - not is_basic_json::value and - not is_basic_json_nested_type::value and - has_to_json::value; +namespace detail +{ +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + void operator=(nonesuch const&) = delete; }; -template -struct is_compatible_type - : conjunction, - is_compatible_complete_type> +template class Op, + class... Args> +struct detector { + using value_t = std::false_type; + using type = Default; }; -// taken from ranges-v3 -template -struct static_const +template class Op, class... Args> +struct detector>, Op, Args...> { - static constexpr T value{}; + using value_t = std::true_type; + using type = Op; }; -template -constexpr T static_const::value; -} -} +template