From 89a43902a865ebd1da12cf41b2906279b8662361 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 23 Feb 1999 19:05:55 +0000 Subject: [PATCH] another wxBeginBusyCursor fix git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/cursor.cpp | 9 ++++++++- src/gtk1/cursor.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gtk/cursor.cpp b/src/gtk/cursor.cpp index 93c10ada60..7c497e454c 100644 --- a/src/gtk/cursor.cpp +++ b/src/gtk/cursor.cpp @@ -140,9 +140,13 @@ GdkCursor *wxCursor::GetCursor() const extern wxCursor *g_globalCursor; static wxCursor *gs_savedCursor = NULL; +static int gs_busyCount = 0; void wxEndBusyCursor() { + if ( --gs_busyCount > 0 ) + return; + wxCHECK_RET( gs_savedCursor && gs_savedCursor->Ok(), "calling wxEndBusyCursor() without wxBeginBusyCursor()?" ); @@ -153,6 +157,9 @@ void wxEndBusyCursor() void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) { + if ( gs_busyCount++ > 0 ) + return; + wxASSERT_MSG( !gs_savedCursor, "forgot to call wxEndBusyCursor, will leak memory" ); @@ -166,7 +173,7 @@ void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) bool wxIsBusy() { - return gs_savedCursor != NULL; + return gs_busyCount > 0; } void wxSetCursor( const wxCursor& cursor ) diff --git a/src/gtk1/cursor.cpp b/src/gtk1/cursor.cpp index 93c10ada60..7c497e454c 100644 --- a/src/gtk1/cursor.cpp +++ b/src/gtk1/cursor.cpp @@ -140,9 +140,13 @@ GdkCursor *wxCursor::GetCursor() const extern wxCursor *g_globalCursor; static wxCursor *gs_savedCursor = NULL; +static int gs_busyCount = 0; void wxEndBusyCursor() { + if ( --gs_busyCount > 0 ) + return; + wxCHECK_RET( gs_savedCursor && gs_savedCursor->Ok(), "calling wxEndBusyCursor() without wxBeginBusyCursor()?" ); @@ -153,6 +157,9 @@ void wxEndBusyCursor() void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) { + if ( gs_busyCount++ > 0 ) + return; + wxASSERT_MSG( !gs_savedCursor, "forgot to call wxEndBusyCursor, will leak memory" ); @@ -166,7 +173,7 @@ void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) bool wxIsBusy() { - return gs_savedCursor != NULL; + return gs_busyCount > 0; } void wxSetCursor( const wxCursor& cursor ) -- 2.47.2