From f6081a0462089eaa1da4d38b260af032b349a041 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 30 Jan 2000 13:43:37 +0000 Subject: [PATCH] Cured memory leak report in wxDateTime; wxGLCanvas corrections git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/bcc.t | 2 +- docs/html/faqmsw.htm | 28 ++++++++++++++++++++++++++++ docs/latex/wx/image.tex | 2 +- include/wx/datetime.h | 2 ++ src/common/datetime.cpp | 1 + src/common/filesys.cpp | 4 ++-- src/msw/dcprint.cpp | 5 +++++ src/msw/dir.cpp | 5 +++++ src/msw/makefile.bcc | 2 +- src/msw/window.cpp | 4 ++++ utils/glcanvas/win/glcanvas.cpp | 24 ++++++++++++++++++------ 11 files changed, 68 insertions(+), 11 deletions(-) diff --git a/distrib/msw/tmake/bcc.t b/distrib/msw/tmake/bcc.t index 87cd636126..f72497fc81 100644 --- a/distrib/msw/tmake/bcc.t +++ b/distrib/msw/tmake/bcc.t @@ -144,7 +144,7 @@ wx: $(CFG) $(DUMMY).obj $(OBJECTS) $(PERIPH_TARGET) $(LIBTARGET) $(LIBTARGET): $(DUMMY).obj $(OBJECTS) $(PERIPH_LIBS) erase $(LIBTARGET) - tlib $(LIBTARGET) /P1024 @&&! + tlib $(LIBTARGET) /P2048 @&&! +$(COMMONOBJS:.obj =.obj +)\ +$(GENERICOBJS:.obj =.obj +)\ +$(MSWOBJS:.obj =.obj +)\ diff --git a/docs/html/faqmsw.htm b/docs/html/faqmsw.htm index 085980f7b7..e5a7e96019 100644 --- a/docs/html/faqmsw.htm +++ b/docs/html/faqmsw.htm @@ -240,6 +240,34 @@ generated. At least it will divide the number of files in samples directory by 10 (and the number of files to be maintained too). +

+ +

How do you use VC++'s memory leak checking instead of that in wxWindows?

+ +Vadim Zeitlin: + +
+On the VC++ level, it's just the matter of calling _CrtSetDbgFlag() in the very
+beginning of the program. In wxWindows, this is done automatically when
+compiling with VC++ in debug mode unless wxUSE_GLOBAL_MEMORY_OPERATORS or
+__NO_VC_CRTDBG__ are defined - this check is done in wx/msw/msvcrt.h which
+is included from app.cpp which then calls wxCrtSetDbgFlag() without any
+#ifdefs.
+
+This works quite well: at the end of the program, all leaked blocks with their
+malloc count are shown. This number (malloc count) can be used to determine
+where exactly the object was allocated: for this it's enough to set the variable
+_crtBreakAlloc (look in VC98\crt\srs\dbgheap.c line 326) to this number and
+a breakpoint will be triggered when the block with this number is allocated.
+
+For simple situations it works like a charm. For something more complicated
+like reading uninitialized memory a specialized tool is probably better...
+
+Regards,
+VZ
+
+ + diff --git a/docs/latex/wx/image.tex b/docs/latex/wx/image.tex index b77ec8f799..ca43c0fbcc 100644 --- a/docs/latex/wx/image.tex +++ b/docs/latex/wx/image.tex @@ -49,7 +49,7 @@ PNM format, {\bf wxPNMHandler} will always save as raw RGB. \wxheading{See also} -\helpref{wxBitmap}{wxbitmap} +\helpref{wxBitmap}{wxbitmap}, \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers} \latexignore{\rtfignore{\wxheading{Members}}} diff --git a/include/wx/datetime.h b/include/wx/datetime.h index d7f994b915..1d7a329e67 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -1259,8 +1259,10 @@ WX_DECLARE_OBJARRAY(wxDateTime, wxDateTimeArray); class WXDLLEXPORT wxDateTimeHolidayAuthority; WX_DEFINE_EXPORTED_ARRAY(wxDateTimeHolidayAuthority *, wxHolidayAuthoritiesArray); +class wxDateTimeHolidaysModule; class WXDLLEXPORT wxDateTimeHolidayAuthority { + friend wxDateTimeHolidaysModule; public: // returns TRUE if the given date is a holiday static bool IsHoliday(const wxDateTime& dt); diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index b24efdb41f..04fac9daaf 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -122,6 +122,7 @@ public: virtual void OnExit() { wxDateTimeHolidayAuthority::ClearAllAuthorities(); + wxDateTimeHolidayAuthority::ms_authorities.Clear(); } private: diff --git a/src/common/filesys.cpp b/src/common/filesys.cpp index ebefb2ef97..1f9cbc486f 100644 --- a/src/common/filesys.cpp +++ b/src/common/filesys.cpp @@ -230,7 +230,7 @@ static wxString MakeCorrectPath(const wxString& path) cnt = p.Length(); for (i = 0; i < cnt; i++) - if (p.GetChar(i) == wxT('\\')); p.GetWritableChar(i) = wxT('/'); // wanna be windows-safe + if (p.GetChar(i) == wxT('\\')) p.GetWritableChar(i) = wxT('/'); // Want to be windows-safe if (p.Left(2) == wxT("./")) { p = p.Mid(2); cnt -= 2; } @@ -382,7 +382,7 @@ wxString wxFileSystem::FindFirst(const wxString& spec, int flags) m_FindFileHandler = NULL; for (int i = spec2.Length()-1; i >= 0; i--) - if (spec2[(unsigned int) i] == wxT('\\')) spec2.GetWritableChar(i) = wxT('/'); // wanna be windows-safe + if (spec2[(unsigned int) i] == wxT('\\')) spec2.GetWritableChar(i) = wxT('/'); // Want to be windows-safe node = m_Handlers.GetFirst(); while (node) diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 1fabf5e6df..c39d15dc3f 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -415,6 +415,11 @@ WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) // wxPrinterDC bit blitting/bitmap drawing // ---------------------------------------------------------------------------- +// Win16 doesn't define GDI_ERROR. +#ifndef GDI_ERROR +#define GDI_ERROR -1 +#endif + void wxPrinterDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index 5fe20263aa..adfa2dd7e3 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -28,6 +28,11 @@ #pragma hdrstop #endif +// For _A_SUBDIR, etc. +#if defined(__BORLANDC__) && defined(__WIN16__) +#include +#endif + #ifndef WX_PRECOMP #include "wx/intl.h" #include "wx/log.h" diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index c8aa1c79f8..2bd4d53af2 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -273,7 +273,7 @@ wx: $(CFG) $(DUMMY).obj $(OBJECTS) $(PERIPH_TARGET) $(LIBTARGET) $(LIBTARGET): $(DUMMY).obj $(OBJECTS) $(PERIPH_LIBS) erase $(LIBTARGET) - tlib $(LIBTARGET) /P1024 @&&! + tlib $(LIBTARGET) /P2048 @&&! +$(COMMONOBJS:.obj =.obj +)\ +$(GENERICOBJS:.obj =.obj +)\ +$(MSWOBJS:.obj =.obj +)\ diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 11f6526ba6..7fd9425101 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2283,12 +2283,16 @@ bool wxWindow::MSWCreate(int id, if ( width > -1 ) width1 = width; if ( height > -1 ) height1 = height; + // Unfortunately this won't work in WIN16. Unless perhaps + // we define WS_EX_CONTROLPARENT ourselves? +#ifndef __WIN16__ // if we have wxTAB_TRAVERSAL style, we want WS_EX_CONTROLPARENT or // IsDialogMessage() won't work for us if ( GetWindowStyleFlag() & wxTAB_TRAVERSAL ) { extendedStyle |= WS_EX_CONTROLPARENT; } +#endif HWND hParent = (HWND)NULL; if ( parent ) diff --git a/utils/glcanvas/win/glcanvas.cpp b/utils/glcanvas/win/glcanvas.cpp index bbd7d026b9..28defce46d 100644 --- a/utils/glcanvas/win/glcanvas.cpp +++ b/utils/glcanvas/win/glcanvas.cpp @@ -129,14 +129,25 @@ END_EVENT_TABLE() wxGLCanvas::wxGLCanvas(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attribList /* not used yet! */, const wxPalette& palette): - wxScrolledWindow(parent, id, pos, size, style, name) + wxScrolledWindow() { - m_hDC = (WXHDC) ::GetDC((HWND) GetHWND()); + m_glContext = (wxGLContext*) NULL; - SetupPixelFormat(); - SetupPalette(palette); + bool ret = Create(parent, id, pos, size, style, name); + + if ( ret ) + { + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); + } + + m_hDC = (WXHDC) ::GetDC((HWND) GetHWND()); + + SetupPixelFormat(); + SetupPalette(palette); + + m_glContext = new wxGLContext(TRUE, this, palette); - m_glContext = new wxGLContext(TRUE, this, palette); } wxGLCanvas::wxGLCanvas( wxWindow *parent, @@ -144,8 +155,9 @@ wxGLCanvas::wxGLCanvas( wxWindow *parent, const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attribList, const wxPalette& palette ) : wxScrolledWindow() -// : wxScrolledWindow(parent, id, pos, size, style, name) { + m_glContext = (wxGLContext*) NULL; + bool ret = Create(parent, id, pos, size, style, name); if ( ret ) -- 2.45.2