From 08ff290e0c871487aa4b44f24369a67ca6a886ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 4 Feb 2016 22:54:08 -0800 Subject: [PATCH] Fixed bx::open. --- include/bx/error.h | 9 ++++++--- include/bx/readerwriter.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/bx/error.h b/include/bx/error.h index 1d30a90..d98a111 100644 --- a/include/bx/error.h +++ b/include/bx/error.h @@ -14,10 +14,13 @@ _ptr->setError(_result, "" _msg); \ BX_MACRO_BLOCK_END +#define BX_ERROR_USE_TEMP_WHEN_NULL(_ptr) \ + const bx::Error tmpError; /* It should not be used directly! */ \ + _ptr = NULL == _ptr ? const_cast(&tmpError) : _ptr + #define BX_ERROR_SCOPE(_ptr) \ - const bx::Error tmpError /* It should not be used directly! */; \ - _ptr = NULL == _ptr ? const_cast(&tmpError) : _ptr; \ - bx::ErrorScope bxErrorScope(const_cast(&tmpError)) + BX_ERROR_USE_TEMP_WHEN_NULL(_ptr); \ + bx::ErrorScope bxErrorScope(const_cast(&tmpError) ) #define BX_ERROR_RESULT(_err, _code) \ BX_STATIC_ASSERT(_code != 0, "ErrorCode 0 is reserved!"); \ diff --git a/include/bx/readerwriter.h b/include/bx/readerwriter.h index f8d05d1..ef8c810 100644 --- a/include/bx/readerwriter.h +++ b/include/bx/readerwriter.h @@ -224,7 +224,7 @@ namespace bx inline bool open(FileReaderI* _reader, const char* _filePath, Error* _err = NULL) { - BX_ERROR_SCOPE(_err); + BX_ERROR_USE_TEMP_WHEN_NULL(_err); return _reader->open(_filePath, _err); } @@ -235,7 +235,7 @@ namespace bx inline bool open(FileWriterI* _writer, const char* _filePath, bool _append = false, Error* _err = NULL) { - BX_ERROR_SCOPE(_err); + BX_ERROR_USE_TEMP_WHEN_NULL(_err); return _writer->open(_filePath, _append, _err); }