X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2FLAssert.h;h=6a937266024f62faa7a5fa1e7b9fa94b6b73e94c;hb=5296e9e9952cf6e2f306077c62a1caeaf8479eed;hp=e429df8c11cf99ad5e82ea59f1d47c6aacfb434d;hpb=ed22adefc6ca3060a1d271d26f2908486182f396;p=lyx.git diff --git a/src/support/LAssert.h b/src/support/LAssert.h index e429df8c11..6a93726602 100644 --- a/src/support/LAssert.h +++ b/src/support/LAssert.h @@ -2,47 +2,40 @@ #ifndef LASSERT_H #define LASSERT_H -//namespace LyX { +#include "support/lyxlib.h" + +extern void emergencyCleanup(); + +namespace lyx { #ifdef ENABLE_ASSERTIONS -//template inline void Assert(A assertion) -template inline void Assert(A assertion) +/** Live assertion. + This is a debug tool to ensure that the assertion holds. If it don't hole + we run #emergencyCleanup()# and then #lyx::abort". + @param assertion this should evaluate to true unless you want an abort. +*/ +template +inline +void Assert(A assertion) { - //if (!assertion) throw X(); if (!assertion) { - abort(); - } -} - -#ifdef HAVE_PARTIAL_SPECIALIZATION -// Not too sure if this is the correct way to specialize -template inline void Assert(A * ptr) -{ - Assert(ptr); -} -template<> inline void Assert(void const * ptr) -{ - if (!ptr) { - abort(); + ::emergencyCleanup(); + lyx::abort(); } } -#endif /* HAVE_PARTIAL_SPECIALIZATION */ - -//template inline void Assert(A assertion, E except) -//{ -// if (!assertion) except; -//} #else -template inline void Assert(A /*assertion*/) {} +/** Dummy assertion. + When compiling without assertions we use this no-op function. +*/ +template +inline +void Assert(A /*assertion*/) {} #endif /* ENABLE_ASSERTIONS */ - -//} // end of namespace LyX - +} // end of namespace LyX #endif /* LASSERT_H */ -