From: Vadim Zeitlin Date: Tue, 14 Dec 2010 18:43:39 +0000 (+0000) Subject: Fail in CloneGDIRefData() instead of implementing it incorrectly in wxOSX. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f9b4d680d72930c31fe14dd63421a85d97ccd739 Fail in CloneGDIRefData() instead of implementing it incorrectly in wxOSX. wxIcon and wxMetaFile implemented CloneGDIRefData() using copy ctors of the corresponding ref data classes but the copy ctors were either wrong (for wxIconRefData as using it would result in messing up IconRef reference count) or had wrong semantics (wxMetafileRefData copy ctor performed shallow copy only while CloneGDIRefData() supposes a deep copy is done). Replace the wrong implementations of these functions with assert that will be triggered if they are ever used (which doesn't seem to be the case so far). See #12768. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66373 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/carbon/icon.cpp b/src/osx/carbon/icon.cpp index e156e55a18..f391772e75 100644 --- a/src/osx/carbon/icon.cpp +++ b/src/osx/carbon/icon.cpp @@ -50,6 +50,9 @@ private: IconRef m_iconRef; int m_width; int m_height; + + // We can (easily) copy m_iconRef so we don't implement the copy ctor. + wxDECLARE_NO_COPY_CLASS(wxIconRefData); }; @@ -124,9 +127,12 @@ wxGDIRefData *wxIcon::CreateGDIRefData() const return new wxIconRefData; } -wxGDIRefData *wxIcon::CloneGDIRefData(const wxGDIRefData *data) const +wxGDIRefData * +wxIcon::CloneGDIRefData(const wxGDIRefData * WXUNUSED(data)) const { - return new wxIconRefData(*static_cast(data)); + wxFAIL_MSG( wxS("Cloning icons is not implemented in wxCarbon.") ); + + return new wxIconRefData; } WXHICON wxIcon::GetHICON() const diff --git a/src/osx/carbon/metafile.cpp b/src/osx/carbon/metafile.cpp index 13d0ef7707..6e8905e6b4 100644 --- a/src/osx/carbon/metafile.cpp +++ b/src/osx/carbon/metafile.cpp @@ -76,6 +76,11 @@ private: int m_width ; int m_height ; + + + // Our m_pdfDoc field can't be easily (deep) copied and so we don't define a + // copy ctor. + wxDECLARE_NO_COPY_CLASS(wxMetafileRefData); }; wxMetafileRefData::wxMetafileRefData(CFDataRef data) : @@ -175,9 +180,12 @@ wxGDIRefData *wxMetaFile::CreateGDIRefData() const return new wxMetafileRefData; } -wxGDIRefData *wxMetaFile::CloneGDIRefData(const wxGDIRefData *data) const +wxGDIRefData * +wxMetaFile::CloneGDIRefData(const wxGDIRefData * WXUNUSED(data)) const { - return new wxMetafileRefData(*static_cast(data)); + wxFAIL_MSG( wxS("Cloning metafiles is not implemented in wxCarbon.") ); + + return new wxMetafileRefData; } WXHMETAFILE wxMetaFile::GetHMETAFILE() const