From 8a9c22462aec446d06267ac10b99f1115704b9d1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Mar 2000 01:03:52 +0000 Subject: [PATCH] 1. fixed memory leak in GAddress 2. fixed memory leak with wxLogStderr in wxBase 3. updated tmake files/makefiles for wxBase with wxSocket under MSW 4. fixed wxSashWindow cursor bug by allowing SetCursor(wxNullCursor) 5. fixed warning in gsock*.c git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/window.tex | 10 +++++++--- src/common/init.cpp | 10 +++++++--- src/common/wincmn.cpp | 9 ++++----- src/generic/sashwin.cpp | 4 ++-- src/msw/gsocket.c | 14 ++++++++++++++ src/msw/gsockmsw.c | 13 +++++++++++++ src/msw/window.cpp | 22 +++++++++++----------- 7 files changed, 58 insertions(+), 24 deletions(-) diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex index 424cc23d72..73f5674491 100644 --- a/docs/latex/wx/window.tex +++ b/docs/latex/wx/window.tex @@ -1832,9 +1832,13 @@ implements the following methods:\par \func{virtual void}{SetCursor}{\param{const wxCursor\&}{cursor}} -Sets the window's cursor. Notice that setting the cursor for this window does -not set it for its children so you'll need to explicitly call SetCursor() for -them too if you need it. +% VZ: the docs are correct, if the code doesn't behave like this, it must be +% changed +Sets the window's cursor. Notice that the window cursor also sets it for the +children of the window implicitly. + +The {\it cursor} may be {\tt wxNullCursor} in which case the window cursor will +be reset back to default. \wxheading{Parameters} diff --git a/src/common/init.cpp b/src/common/init.cpp index 78576fb3c5..70c9dafcdb 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -219,9 +219,8 @@ static void DoCleanUp() // continuing to use user defined log target is unsafe from now on because // some resources may be already unavailable, so replace it by something // more safe - wxLog *oldlog = wxLog::SetActiveTarget(new wxLogStderr); - if ( oldlog ) - delete oldlog; + wxLog::DontCreateOnDemand(); + delete wxLog::SetActiveTarget(new wxLogStderr); #endif // wxUSE_LOG wxModule::CleanUpModules(); @@ -231,4 +230,9 @@ static void DoCleanUp() // delete the application object delete wxTheApp; wxTheApp = (wxApp *)NULL; + +#if wxUSE_LOG + // and now delete the last logger as well + delete wxLog::SetActiveTarget(NULL); +#endif // wxUSE_LOG } diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index bd49ebf5dd..e3c669216f 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -586,16 +586,15 @@ bool wxWindowBase::SetForegroundColour( const wxColour &colour ) bool wxWindowBase::SetCursor(const wxCursor& cursor) { - // don't try to set invalid cursor, always fall back to the default - const wxCursor& cursorOk = cursor.Ok() ? cursor : *wxSTANDARD_CURSOR; - - if ( (wxCursor&)cursorOk == m_cursor ) + // setting an invalid cursor is ok, it means that we don't have any special + // cursor + if ( cursor == m_cursor ) { // no change return FALSE; } - m_cursor = cursorOk; + m_cursor = cursor; return TRUE; } diff --git a/src/generic/sashwin.cpp b/src/generic/sashwin.cpp index 5f0bbe3ba1..6daf05f134 100644 --- a/src/generic/sashwin.cpp +++ b/src/generic/sashwin.cpp @@ -115,7 +115,7 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event) SetCursor(* wxSTANDARD_CURSOR); #endif #ifdef __WXMSW__ - SetCursor(wxCursor()); + SetCursor(wxNullCursor); #endif if (event.LeftDown()) @@ -306,7 +306,7 @@ void wxSashWindow::OnMouseEvent(wxMouseEvent& event) } else { - SetCursor(* wxSTANDARD_CURSOR); + SetCursor(wxNullCursor); } } else if ( event.Dragging() && diff --git a/src/msw/gsocket.c b/src/msw/gsocket.c index 7417b834bc..eb4d669270 100644 --- a/src/msw/gsocket.c +++ b/src/msw/gsocket.c @@ -11,6 +11,14 @@ * PLEASE don't put C++ comments here - this is a C source file. */ +/* including rasasync.h (included from windows.h itself included from + * wx/setup.h and/or winsock.h results in this warning for + * RPCNOTIFICATION_ROUTINE + */ +#ifdef _MSC_VER +# pragma warning(disable:4115) /* named type definition in parentheses */ +#endif + #ifndef __GSOCKET_STANDALONE__ #include "wx/setup.h" #endif @@ -40,8 +48,13 @@ #include #include #include + #include +#ifdef _MSC_VER +# pragma warning(default:4115) /* named type definition in parentheses */ +#endif + /* if we use configure for MSW SOCKLEN_T will be already defined */ #ifndef SOCKLEN_T # define SOCKLEN_T int @@ -1061,6 +1074,7 @@ void GAddress_destroy(GAddress *address) { assert(address != NULL); + free(address->m_addr); free(address); } diff --git a/src/msw/gsockmsw.c b/src/msw/gsockmsw.c index b8a3bda683..e853b8b1bd 100644 --- a/src/msw/gsockmsw.c +++ b/src/msw/gsockmsw.c @@ -11,6 +11,14 @@ * PLEASE don't put C++ comments here - this is a C source file. */ +/* including rasasync.h (included from windows.h itself included from + * wx/setup.h and/or winsock.h results in this warning for + * RPCNOTIFICATION_ROUTINE + */ +#ifdef _MSC_VER +# pragma warning(disable:4115) /* named type definition in parentheses */ +#endif + #ifndef __GSOCKET_STANDALONE__ #include "wx/setup.h" #endif @@ -43,8 +51,13 @@ #include #include #include + #include +#ifdef _MSC_VER +# pragma warning(default:4115) /* named type definition in parentheses */ +#endif + #define CLASSNAME "_GSocket_Internal_Window_Class" #define WINDOWNAME "_GSocket_Internal_Window_Name" diff --git a/src/msw/window.cpp b/src/msw/window.cpp index dcd6b8cce0..33b7de5dcd 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -469,20 +469,20 @@ bool wxWindow::SetCursor(const wxCursor& cursor) return FALSE; } - wxASSERT_MSG( m_cursor.Ok(), - wxT("cursor must be valid after call to the base version")); - - HWND hWnd = GetHwnd(); + if ( m_cursor.Ok() ) + { + HWND hWnd = GetHwnd(); - // Change the cursor NOW if we're within the correct window - POINT point; - ::GetCursorPos(&point); + // Change the cursor NOW if we're within the correct window + POINT point; + ::GetCursorPos(&point); - RECT rect; - ::GetWindowRect(hWnd, &rect); + RECT rect; + ::GetWindowRect(hWnd, &rect); - if ( ::PtInRect(&rect, point) && !wxIsBusy() ) - ::SetCursor(GetHcursorOf(m_cursor)); + if ( ::PtInRect(&rect, point) && !wxIsBusy() ) + ::SetCursor(GetHcursorOf(m_cursor)); + } return TRUE; } -- 2.45.2