From f8abbfbb4487ad3630add33f61716ed01ca0bdf6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 16 Oct 2012 16:16:32 +0200 Subject: [PATCH] assert: use xmessage to block on assert failed --- src/assert.cc | 12 ++++++++++++ src/assert.hh | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/assert.cc b/src/assert.cc index 40e9f6b3..0c4e85f3 100644 --- a/src/assert.cc +++ b/src/assert.cc @@ -13,4 +13,16 @@ String assert_failed::description() const return m_message; } +void on_assert_failed(const String& message) +{ + int res = system(("xmessage -buttons 'quit:0,ignore:1' '" + message + "'").c_str()); + switch (res) + { + case 0: + throw assert_failed(message); + case 1: + return; + } +} + } diff --git a/src/assert.hh b/src/assert.hh index 975ddca1..0ec5db90 100644 --- a/src/assert.hh +++ b/src/assert.hh @@ -15,6 +15,8 @@ private: String m_message; }; +void on_assert_failed(const String& message); + } #define STRINGIFY(X) #X @@ -27,6 +29,6 @@ private: #define assert(condition) \ if (not (condition)) \ - throw assert_failed("assert failed \"" #condition "\" at " __FILE__ ":" TOSTRING(__LINE__)) + on_assert_failed("assert failed \"" #condition "\" at " __FILE__ ":" TOSTRING(__LINE__)) #endif // assert_hh_INCLUDED