]> git.lyx.org Git - lyx.git/blobdiff - src/boost.C
* lyx_main.C: remove duplicate function assertion_failed
[lyx.git] / src / boost.C
index f16fcfe92f46e4afab46d71ef5ba3b061285b601..ff420ec555311da2a44d247c96dd3096e4951ec3 100644 (file)
 
 #include <config.h>
 
+#include "lyx_main.h"
 #include "debug.h"
-#include "support/LAssert.h"
+#include "support/lyxlib.h"
 
-#include <exception>
+#include <boost/assert.hpp>
 
-using namespace lyx::support;
+#include <exception>
 
 using std::endl;
+using lyx::lyxerr;
+using lyx::LyX;
 
 namespace boost {
 
+#ifndef BOOST_NO_EXCEPTIONS
 void throw_exception(std::exception const & e)
 {
        lyxerr << "Exception caught:\n"
            << e.what() << endl;
-       Assert(false);
+       BOOST_ASSERT(false);
+}
+#endif
+
+
+void emergencyCleanup()
+{
+       static bool didCleanup;
+       if (didCleanup)
+               return;
+
+       didCleanup = true;
+
+       LyX::cref().emergencyCleanup();
 }
 
 
+void assertion_failed(char const * expr, char const * function,
+                     char const * file, long line)
+{
+       lyxerr << "Assertion triggered in " << function
+              << " by failing check \"" << expr << "\""
+              << " in file " << file << ":" << line << endl;
+       emergencyCleanup();
+       lyx::support::abort();
 }
+
+} // namespace boost