Add Q_ASSERT_RETURN and friends
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled

This commit is contained in:
GriffinR
2026-05-24 03:06:03 -04:00
parent 31c3fbd0a9
commit a430b3e203
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#pragma once
#include <QtAssert>
// A series of wrappers around Qt assert macros,
// with the addition that each will return if the test fails.
// This makes it easy to raise asserts in situations where you
// may want to do an early return even if debug is disabled.
#define Q_ASSERT_RETURN(test, ...) \
do { \
Q_ASSERT(test); \
if (!test) return __VA_ARGS__; \
} while (false);
#define Q_ASSERT_RETURN_X(test, where, what, ...) \
do { \
Q_ASSERT_X(test, where, what); \
if (!test) return __VA_ARGS__; \
} while (false);
#define Q_CHECK_PTR_RETURN(pointer, ...) \
do { \
Q_CHECK_PTR(pointer); \
if (pointer == nullptr) return __VA_ARGS__; \
} while (false);

View File

@@ -179,6 +179,7 @@ HEADERS += include/config/keyvalueconfigbase.h \
include/config/projectconfig.h \
include/config/shortcutsconfig.h \
include/config/userconfig.h \
include/core/assert_return.h \
include/core/advancemapparser.h \
include/core/block.h \
include/core/bitpacker.h \