From be52b34172dede7460990c54b9f7e2dad3a6f876 Mon Sep 17 00:00:00 2001 From: Gilles Depeyrot Date: Wed, 8 May 2002 13:30:26 +0000 Subject: [PATCH] added DECLARE_NO_COPY_CLASS where appropriate since wxObject should not provide implicit copy constructor or assignement (will be corrected) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/app.h | 2 ++ include/wx/containr.h | 2 ++ include/wx/log.h | 6 ++++-- include/wx/mac/bitmap.h | 35 +++++++++++++++++++---------------- include/wx/mac/cursor.h | 8 ++++++-- include/wx/mac/dc.h | 3 ++- include/wx/mac/palette.h | 10 +++++++--- include/wx/thread.h | 13 +++++++++---- include/wx/utils.h | 2 ++ include/wx/validate.h | 1 + src/mac/bitmap.cpp | 34 ++++++++++++++++++---------------- src/mac/carbon/bitmap.cpp | 34 ++++++++++++++++++---------------- 12 files changed, 90 insertions(+), 60 deletions(-) diff --git a/include/wx/app.h b/include/wx/app.h index 801c549d64..489194ab3b 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -92,6 +92,8 @@ private: class WXDLLEXPORT wxAppBase : public wxEvtHandler { + DECLARE_NO_COPY_CLASS(wxAppBase) + public: wxAppBase(); virtual ~wxAppBase(); diff --git a/include/wx/containr.h b/include/wx/containr.h index 7139ef4242..b74b2c2a8f 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -37,6 +37,8 @@ class WXDLLEXPORT wxWindowBase; class WXDLLEXPORT wxControlContainer { + DECLARE_NO_COPY_CLASS(wxControlContainer) + public: // ctors and such wxControlContainer(wxWindow *winParent = NULL); diff --git a/include/wx/log.h b/include/wx/log.h index 28272c9b9c..f505a16237 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -240,6 +240,8 @@ private: // log everything to a "FILE *", stderr by default class WXDLLEXPORT wxLogStderr : public wxLog { + DECLARE_NO_COPY_CLASS(wxLogStderr) + public: // redirect log output to a FILE wxLogStderr(FILE *fp = (FILE *) NULL); @@ -293,8 +295,8 @@ protected: class WXDLLEXPORT wxLogNull { public: - wxLogNull() { m_flagOld = wxLog::EnableLogging(FALSE); } - ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); } + wxLogNull() : m_flagOld(wxLog::EnableLogging(FALSE)) { } + ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); } private: bool m_flagOld; // the previous value of the wxLog::ms_doLog diff --git a/include/wx/mac/bitmap.h b/include/wx/mac/bitmap.h index 02f03186fc..1b0873f0af 100644 --- a/include/wx/mac/bitmap.h +++ b/include/wx/mac/bitmap.h @@ -31,7 +31,8 @@ class WXDLLEXPORT wxImage; // transparently. class WXDLLEXPORT wxMask: public wxObject { - DECLARE_DYNAMIC_CLASS(wxMask) + DECLARE_DYNAMIC_CLASS(wxMask) + DECLARE_NO_COPY_CLASS(wxMask) public: wxMask(); @@ -65,6 +66,8 @@ enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData { + DECLARE_NO_COPY_CLASS(wxBitmapRefData) + friend class WXDLLEXPORT wxBitmap; friend class WXDLLEXPORT wxIcon; friend class WXDLLEXPORT wxCursor; @@ -81,10 +84,10 @@ public: wxPalette m_bitmapPalette; int m_quality; - int m_bitmapType ; - WXHMETAFILE m_hPict ; - WXHBITMAP m_hBitmap; - WXHICON m_hIcon ; + int m_bitmapType ; + WXHMETAFILE m_hPict ; + WXHBITMAP m_hBitmap; + WXHICON m_hIcon ; wxMask * m_bitmapMask; // Optional mask }; @@ -94,22 +97,21 @@ class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase { DECLARE_DYNAMIC_CLASS(wxBitmapHandler) public: - wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; }; -#ifdef __DARWIN__ - virtual ~wxBitmapHandler() { } -#endif + wxBitmapHandler() : m_name(), m_extension(), m_type(0) { } + virtual ~wxBitmapHandler(); virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, int desiredWidth, int desiredHeight); virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); - inline void SetName(const wxString& name) { m_name = name; } - inline void SetExtension(const wxString& ext) { m_extension = ext; } - inline void SetType(long type) { m_type = type; } - inline wxString GetName() const { return m_name; } - inline wxString GetExtension() const { return m_extension; } - inline long GetType() const { return m_type; } + void SetName(const wxString& name) { m_name = name; } + void SetExtension(const wxString& ext) { m_extension = ext; } + void SetType(long type) { m_type = type; } + wxString GetName() const { return m_name; } + wxString GetExtension() const { return m_extension; } + long GetType() const { return m_type; } + protected: wxString m_name; wxString m_extension; @@ -128,7 +130,8 @@ public: wxBitmap(); // Platform-specific // Copy constructors - inline wxBitmap(const wxBitmap& bitmap) + wxBitmap(const wxBitmap& bitmap) + : wxBitmapBase() { Ref(bitmap); } // Initialize with raw data. diff --git a/include/wx/mac/cursor.h b/include/wx/mac/cursor.h index 2500050091..7609aca59f 100644 --- a/include/wx/mac/cursor.h +++ b/include/wx/mac/cursor.h @@ -20,6 +20,8 @@ class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData { + DECLARE_NO_COPY_CLASS(wxCursorRefData) + friend class WXDLLEXPORT wxBitmap; friend class WXDLLEXPORT wxCursor; public: @@ -27,7 +29,7 @@ public: ~wxCursorRefData(); protected: - WXHCURSOR m_hCursor; + WXHCURSOR m_hCursor; }; #define M_CURSORDATA ((wxCursorRefData *)m_refData) @@ -42,7 +44,9 @@ public: wxCursor(); // Copy constructors - inline wxCursor(const wxCursor& cursor) { Ref(cursor); } + wxCursor(const wxCursor& cursor) + : wxBitmap() + { Ref(cursor); } wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, const char maskBits[] = NULL); diff --git a/include/wx/mac/dc.h b/include/wx/mac/dc.h index ead1ae68d9..e48f2b7dee 100644 --- a/include/wx/mac/dc.h +++ b/include/wx/mac/dc.h @@ -50,7 +50,8 @@ class wxMacPortStateHelper ; class WXDLLEXPORT wxDC: public wxDCBase { - DECLARE_DYNAMIC_CLASS(wxDC) + DECLARE_DYNAMIC_CLASS(wxDC) + DECLARE_NO_COPY_CLASS(wxDC) public: diff --git a/include/wx/mac/palette.h b/include/wx/mac/palette.h index 8925c53d4e..8894340703 100644 --- a/include/wx/mac/palette.h +++ b/include/wx/mac/palette.h @@ -23,13 +23,15 @@ class WXDLLEXPORT wxPalette; class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData { + DECLARE_NO_COPY_CLASS(wxPaletteRefData) + friend class WXDLLEXPORT wxPalette; public: wxPaletteRefData(); ~wxPaletteRefData(); protected: - wxColour* m_palette; - wxInt32 m_count ; + wxColour* m_palette; + wxInt32 m_count ; }; #define M_PALETTEDATA ((wxPaletteRefData *)m_refData) @@ -40,7 +42,9 @@ class WXDLLEXPORT wxPalette: public wxGDIObject public: wxPalette(); - inline wxPalette(const wxPalette& palette) { Ref(palette); } + wxPalette(const wxPalette& palette) + : wxGDIObject() + { Ref(palette); } wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue); ~wxPalette(); diff --git a/include/wx/thread.h b/include/wx/thread.h index 60f5c7c5c4..319829ba71 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -117,8 +117,9 @@ class WXDLLEXPORT wxMutexLocker { public: // lock the mutex in the ctor - wxMutexLocker(wxMutex& mutex) : m_mutex(mutex) - { m_isOk = m_mutex.Lock() == wxMUTEX_NO_ERROR; } + wxMutexLocker(wxMutex& mutex) + : m_isOk(FALSE), m_mutex(mutex) + { m_isOk = ( m_mutex.Lock() == wxMUTEX_NO_ERROR ); } // returns TRUE if mutex was successfully locked in ctor bool IsOk() const @@ -220,6 +221,8 @@ private: class WXDLLEXPORT wxCondition { + DECLARE_NO_COPY_CLASS(wxCondition) + public: // constructor and destructor @@ -275,6 +278,8 @@ private: class WXDLLEXPORT wxSemaphoreInternal; class WXDLLEXPORT wxSemaphore { + DECLARE_NO_COPY_CLASS(wxSemaphore) + public: // specifying a maxcount of 0 actually makes wxSemaphore behave as if there // is no upper limit, if maxcount is 1 the semaphore behaves as a mutex @@ -548,7 +553,7 @@ public: // wxApp then should block all "dangerous" messages extern bool WXDLLEXPORT wxIsWaitingForThread(); #elif defined(__WXMAC__) - extern void WXDLLEXPORT wxMutexGuiLeaveOrEnter(); + extern void WXDLLEXPORT wxMutexGuiLeaveOrEnter(); // returns TRUE if the main thread has GUI lock extern bool WXDLLEXPORT wxGuiOwnedByMainThread(); @@ -561,7 +566,7 @@ public: extern bool WXDLLEXPORT wxIsWaitingForThread(); // implement wxCriticalSection using mutexes - inline wxCriticalSection::wxCriticalSection() { } + inline wxCriticalSection::wxCriticalSection() : m_mutex() { } inline wxCriticalSection::~wxCriticalSection() { } inline void wxCriticalSection::Enter() { (void)m_mutex.Lock(); } diff --git a/include/wx/utils.h b/include/wx/utils.h index 73737d91dc..2b984a8d4c 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -375,6 +375,8 @@ WXDLLEXPORT void wxFlushEvents(); // ctor and enables them back in its dtor class WXDLLEXPORT wxWindowDisabler { + DECLARE_NO_COPY_CLASS(wxWindowDisabler) + public: wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL); ~wxWindowDisabler(); diff --git a/include/wx/validate.h b/include/wx/validate.h index 0cd221045c..3851adada2 100644 --- a/include/wx/validate.h +++ b/include/wx/validate.h @@ -83,6 +83,7 @@ private: static bool ms_isSilent; DECLARE_DYNAMIC_CLASS(wxValidator) + DECLARE_NO_COPY_CLASS(wxValidator) }; WXDLLEXPORT_DATA(extern const wxValidator) wxDefaultValidator; diff --git a/src/mac/bitmap.cpp b/src/mac/bitmap.cpp index c8b6ea5a43..ddabfe2384 100644 --- a/src/mac/bitmap.cpp +++ b/src/mac/bitmap.cpp @@ -59,7 +59,7 @@ void wxMacDestroyColorTable( CTabHandle colors ) void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) { (**newColors).ctTable[index].value = index; - (**newColors).ctTable[index].rgb.red = red ;// someRedValue; + (**newColors).ctTable[index].rgb.red = red ; // someRedValue; (**newColors).ctTable[index].rgb.green = green ; // someGreenValue; (**newColors).ctTable[index].rgb.blue = blue ; // someBlueValue; } @@ -341,13 +341,13 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi } wxBitmapRefData::wxBitmapRefData() + : m_width(0) + , m_height(0) + , m_depth(0) + , m_ok(FALSE) + , m_numColors(0) + , m_quality(0) { - m_ok = FALSE; - m_width = 0; - m_height = 0; - m_depth = 0; - m_quality = 0; - m_numColors = 0; m_bitmapMask = NULL; m_hBitmap = NULL ; m_hPict = NULL ; @@ -355,7 +355,7 @@ wxBitmapRefData::wxBitmapRefData() m_bitmapType = kMacBitmapTypeUnknownType ; } -// TODO move this do a public function of Bitmap Ref +// TODO move this to a public function of Bitmap Ref static void DisposeBitmapRefData(wxBitmapRefData *data) { switch (data->m_bitmapType) @@ -699,8 +699,6 @@ wxBitmap::wxBitmap(const wxImage& image, int depth) SetGWorld( (GWorldPtr) GetHBITMAP() , NULL ) ; // Render image - RGBColor colorRGB ; - register unsigned char* data = image.GetData(); char* destinationBase = GetPixBaseAddr( pixMap ); register unsigned char* destination = (unsigned char*) destinationBase ; @@ -1050,30 +1048,30 @@ WXHMETAFILE wxBitmap::GetPict() const */ wxMask::wxMask() + : m_maskBitmap(NULL) { - m_maskBitmap = 0; } // Construct a mask from a bitmap and a colour indicating // the transparent area wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) + : m_maskBitmap(NULL) { - m_maskBitmap = 0; Create(bitmap, colour); } // Construct a mask from a bitmap and a palette index indicating // the transparent area wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) + : m_maskBitmap(NULL) { - m_maskBitmap = 0; Create(bitmap, paletteIndex); } // Construct a mask from a mono bitmap (copies the bitmap). wxMask::wxMask(const wxBitmap& bitmap) + : m_maskBitmap(NULL) { - m_maskBitmap = 0; Create(bitmap); } @@ -1121,8 +1119,8 @@ bool wxMask::Create(const wxBitmap& bitmap) // the transparent area bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) { -// TODO - wxCHECK_MSG( 0, false, wxT("Not implemented")); + // TODO + wxCHECK_MSG( 0, false, wxT("wxMask::Create not yet implemented")); return FALSE; } @@ -1205,6 +1203,10 @@ bool wxMask::PointMasked(int x, int y) * wxBitmapHandler */ +wxBitmapHandler::~wxBitmapHandler() +{ +} + bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) { return FALSE; diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index c8b6ea5a43..ddabfe2384 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -59,7 +59,7 @@ void wxMacDestroyColorTable( CTabHandle colors ) void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) { (**newColors).ctTable[index].value = index; - (**newColors).ctTable[index].rgb.red = red ;// someRedValue; + (**newColors).ctTable[index].rgb.red = red ; // someRedValue; (**newColors).ctTable[index].rgb.green = green ; // someGreenValue; (**newColors).ctTable[index].rgb.blue = blue ; // someBlueValue; } @@ -341,13 +341,13 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi } wxBitmapRefData::wxBitmapRefData() + : m_width(0) + , m_height(0) + , m_depth(0) + , m_ok(FALSE) + , m_numColors(0) + , m_quality(0) { - m_ok = FALSE; - m_width = 0; - m_height = 0; - m_depth = 0; - m_quality = 0; - m_numColors = 0; m_bitmapMask = NULL; m_hBitmap = NULL ; m_hPict = NULL ; @@ -355,7 +355,7 @@ wxBitmapRefData::wxBitmapRefData() m_bitmapType = kMacBitmapTypeUnknownType ; } -// TODO move this do a public function of Bitmap Ref +// TODO move this to a public function of Bitmap Ref static void DisposeBitmapRefData(wxBitmapRefData *data) { switch (data->m_bitmapType) @@ -699,8 +699,6 @@ wxBitmap::wxBitmap(const wxImage& image, int depth) SetGWorld( (GWorldPtr) GetHBITMAP() , NULL ) ; // Render image - RGBColor colorRGB ; - register unsigned char* data = image.GetData(); char* destinationBase = GetPixBaseAddr( pixMap ); register unsigned char* destination = (unsigned char*) destinationBase ; @@ -1050,30 +1048,30 @@ WXHMETAFILE wxBitmap::GetPict() const */ wxMask::wxMask() + : m_maskBitmap(NULL) { - m_maskBitmap = 0; } // Construct a mask from a bitmap and a colour indicating // the transparent area wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) + : m_maskBitmap(NULL) { - m_maskBitmap = 0; Create(bitmap, colour); } // Construct a mask from a bitmap and a palette index indicating // the transparent area wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) + : m_maskBitmap(NULL) { - m_maskBitmap = 0; Create(bitmap, paletteIndex); } // Construct a mask from a mono bitmap (copies the bitmap). wxMask::wxMask(const wxBitmap& bitmap) + : m_maskBitmap(NULL) { - m_maskBitmap = 0; Create(bitmap); } @@ -1121,8 +1119,8 @@ bool wxMask::Create(const wxBitmap& bitmap) // the transparent area bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) { -// TODO - wxCHECK_MSG( 0, false, wxT("Not implemented")); + // TODO + wxCHECK_MSG( 0, false, wxT("wxMask::Create not yet implemented")); return FALSE; } @@ -1205,6 +1203,10 @@ bool wxMask::PointMasked(int x, int y) * wxBitmapHandler */ +wxBitmapHandler::~wxBitmapHandler() +{ +} + bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) { return FALSE; -- 2.47.2