diff options
| -rw-r--r-- | gtk/PlatGTK.cxx | 15 | ||||
| -rw-r--r-- | include/Platform.h | 8 | ||||
| -rw-r--r-- | win32/PlatWin.cxx | 30 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 2 | 
4 files changed, 52 insertions, 3 deletions
| diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index f9141255e..5276d75f2 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -864,6 +864,21 @@ void Platform::DebugPrintf(const char *, ...) {  }  #endif +// Not supported for GTK+ +static bool assertionPopUps = true; + +void Platform::ShowAssertionPopUps(bool assertionPopUps_) { +	assertionPopUps = assertionPopUps_; +} + +void Platform::Assert(const char *c, const char *file, int line) { +	char buffer[2000]; +	sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); +	strcat(buffer, "\r\n"); +	Platform::DebugDisplay(buffer); +	abort(); +} +  int Platform::Clamp(int val, int minVal, int maxVal) {  	if (val > maxVal)  		val = maxVal; diff --git a/include/Platform.h b/include/Platform.h index de9cf202a..afcc4f61c 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -405,7 +405,15 @@ public:  		return static_cast<short>(x & 0xffff);  	}  	static void DebugPrintf(const char *format, ...); +	static void ShowAssertionPopUps(bool assertionPopUps_); +	static void Assert(const char *c, const char *file, int line);  	static int Clamp(int val, int minVal, int maxVal);  }; +#ifdef  NDEBUG +#define PLATFORM_ASSERT(c) ((void)0) +#else +#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__)) +#endif +  #endif diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 2eb2d12f0..654cf3a27 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -147,10 +147,10 @@ class FontCached : Font {  	FontCached *next;  	int usage;  	LOGFONT lf; -    int hash; +	int hash;  	FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);  	~FontCached() {} -    bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); +	bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);  	virtual void Release();  	static FontCached *first; @@ -878,6 +878,32 @@ void Platform::DebugPrintf(const char *, ...) {  }  #endif +static bool assertionPopUps = true; + +void Platform::ShowAssertionPopUps(bool assertionPopUps_) { +	assertionPopUps = assertionPopUps_; +} + +void Platform::Assert(const char *c, const char *file, int line) { +	char buffer[2000]; +	sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); +	if (assertionPopUps) { +		int idButton = ::MessageBox(0, buffer, "Assertion failure",  +			MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); +		if (idButton == IDRETRY) { +			::DebugBreak(); +		} else if (idButton == IDIGNORE) { +			// all OK +		} else { +			abort(); +		} +	} else { +		strcat(buffer, "\r\n"); +		Platform::DebugDisplay(buffer); +		abort(); +	} +} +  int Platform::Clamp(int val, int minVal, int maxVal) {  	if (val > maxVal)  		val = maxVal; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 1b20d05b9..00e127f98 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -264,7 +264,7 @@ static int InputCodePage() {  // Map the key codes to their equivalent SCK_ form  static int KeyTranslate(int keyIn) { -//assert(!keyIn); +//PLATFORM_ASSERT(!keyIn);  	switch (keyIn) {  		case VK_DOWN:		return SCK_DOWN;  		case VK_UP:		return SCK_UP; | 
