renamed IsRefTo() to IsSameAs() (do complain if this is not more clear) and
changed its signature to take a const reference instead of a pointer which simplifies the code and makes it safer as well git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -30,7 +30,7 @@ Changes in behaviour which may result in compilation errors
|
|||||||
used to work in somewhat unexpected way as it compared only internal pointers
|
used to work in somewhat unexpected way as it compared only internal pointers
|
||||||
and not the object data. The code using it will have to be updated:
|
and not the object data. The code using it will have to be updated:
|
||||||
* If the object was compared with wxNullXXX, use IsOk() method instead
|
* If the object was compared with wxNullXXX, use IsOk() method instead
|
||||||
* If valid object need to be compated, use IsRefTo() to reproduce the old
|
* If valid object need to be compated, use IsSameAs() to reproduce the old
|
||||||
behaviour or change the code to avoid comparing bitmaps &c
|
behaviour or change the code to avoid comparing bitmaps &c
|
||||||
- wxFontData::GetColour() now returns a const colour.
|
- wxFontData::GetColour() now returns a const colour.
|
||||||
- wxDC objects can't be created directly now (this never worked, now it doesn't
|
- wxDC objects can't be created directly now (this never worked, now it doesn't
|
||||||
|
@@ -116,12 +116,15 @@ this one or is derived from it.
|
|||||||
bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
|
bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
\membersection{wxObject::IsRefTo}\label{wxobjectisrefto}
|
\membersection{wxObject::IsSameAs}\label{wxobjectissameas}
|
||||||
|
|
||||||
\func{bool}{IsRefTo}{\param{const wxObject *}{ obj}}
|
\func{bool}{IsSameAs}{\param{const wxObject\& }{ obj}}
|
||||||
|
|
||||||
Returns \true if this object is referencing the \arg{obj}'s data.
|
Returns \true if this object has the same data pointer as \arg{obj}. Notice
|
||||||
Note that this function only does a {\tt shallow} comparison.
|
that \true is returned if the data pointers are \NULL in both objects.
|
||||||
|
|
||||||
|
This function only does a \emph{shallow} comparison, i.e. it doesn't compare
|
||||||
|
the objects pointed to by the data pointers of these objects.
|
||||||
|
|
||||||
\membersection{wxObject::Ref}\label{wxobjectref}
|
\membersection{wxObject::Ref}\label{wxobjectref}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ That's why not all reference-counted wxWidgets classes provide comparison operat
|
|||||||
|
|
||||||
Also note that if you only need to do a {\tt shallow} comparison between two
|
Also note that if you only need to do a {\tt shallow} comparison between two
|
||||||
\helpref{wxObject}{wxobject}-derived classes, you should not use the $==$ and $!=$ operators
|
\helpref{wxObject}{wxobject}-derived classes, you should not use the $==$ and $!=$ operators
|
||||||
but rather the \helpref{wxObject::IsRefTo}{wxobjectisrefto} function.
|
but rather the \helpref{wxObject::IsSameAs}{wxobjectissameas} function.
|
||||||
|
|
||||||
|
|
||||||
\subsection{Object destruction}\label{refcountdestruct}
|
\subsection{Object destruction}\label{refcountdestruct}
|
||||||
|
@@ -36,7 +36,7 @@ public:
|
|||||||
m_join == data.m_join &&
|
m_join == data.m_join &&
|
||||||
m_cap == data.m_cap &&
|
m_cap == data.m_cap &&
|
||||||
m_colour == data.m_colour &&
|
m_colour == data.m_colour &&
|
||||||
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
|
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
||||||
(m_style != wxUSER_DASH ||
|
(m_style != wxUSER_DASH ||
|
||||||
(m_nbDash == data.m_nbDash &&
|
(m_nbDash == data.m_nbDash &&
|
||||||
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
||||||
|
@@ -36,7 +36,7 @@ public:
|
|||||||
m_join == data.m_join &&
|
m_join == data.m_join &&
|
||||||
m_cap == data.m_cap &&
|
m_cap == data.m_cap &&
|
||||||
m_colour == data.m_colour &&
|
m_colour == data.m_colour &&
|
||||||
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
|
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
||||||
(m_style != wxUSER_DASH ||
|
(m_style != wxUSER_DASH ||
|
||||||
(m_nbDash == data.m_nbDash &&
|
(m_nbDash == data.m_nbDash &&
|
||||||
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
||||||
|
@@ -476,9 +476,8 @@ public:
|
|||||||
// Make sure this object has only one reference
|
// Make sure this object has only one reference
|
||||||
void UnShare() { AllocExclusive(); }
|
void UnShare() { AllocExclusive(); }
|
||||||
|
|
||||||
// Do a shallow comparison of our referenced data with the given object's
|
// check if this object references the same data as the other one
|
||||||
// refdata
|
bool IsSameAs(const wxObject& o) const { return m_refData == o.m_refData; }
|
||||||
bool IsRefTo(const wxObject *p) const { return m_refData == p->m_refData; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ensure that our data is not shared with anybody else: if we have no
|
// ensure that our data is not shared with anybody else: if we have no
|
||||||
|
@@ -35,7 +35,7 @@ public:
|
|||||||
m_nJoin == data.m_nJoin &&
|
m_nJoin == data.m_nJoin &&
|
||||||
m_nCap == data.m_nCap &&
|
m_nCap == data.m_nCap &&
|
||||||
m_vColour == data.m_vColour &&
|
m_vColour == data.m_vColour &&
|
||||||
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
|
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
||||||
(m_style != wxUSER_DASH ||
|
(m_style != wxUSER_DASH ||
|
||||||
(m_dash == data.m_dash &&
|
(m_dash == data.m_dash &&
|
||||||
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
||||||
|
@@ -36,7 +36,7 @@ public:
|
|||||||
m_join == data.m_join &&
|
m_join == data.m_join &&
|
||||||
m_cap == data.m_cap &&
|
m_cap == data.m_cap &&
|
||||||
m_colour == data.m_colour &&
|
m_colour == data.m_colour &&
|
||||||
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
|
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
||||||
(m_style != wxUSER_DASH ||
|
(m_style != wxUSER_DASH ||
|
||||||
(m_nbDash == data.m_nbDash &&
|
(m_nbDash == data.m_nbDash &&
|
||||||
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
||||||
|
@@ -397,7 +397,7 @@ bool classname##VariantData::Eq(wxVariantData& data) const \
|
|||||||
|
|
||||||
|
|
||||||
// implements a wxVariantData-derived class using for the Eq() method a shallow
|
// implements a wxVariantData-derived class using for the Eq() method a shallow
|
||||||
// comparison (through wxObject::IsRefTo function)
|
// comparison (through wxObject::IsSameAs function)
|
||||||
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname,expdecl) \
|
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname,expdecl) \
|
||||||
IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
|
IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
|
||||||
\
|
\
|
||||||
@@ -407,7 +407,7 @@ bool classname##VariantData::Eq(wxVariantData& data) const \
|
|||||||
\
|
\
|
||||||
classname##VariantData & otherData = (classname##VariantData &) data;\
|
classname##VariantData & otherData = (classname##VariantData &) data;\
|
||||||
\
|
\
|
||||||
return (otherData.m_value.IsRefTo(&m_value));\
|
return (otherData.m_value.IsSameAs(m_value));\
|
||||||
}\
|
}\
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1023,7 +1023,7 @@ bool wxWindowBase::SetCursor(const wxCursor& cursor)
|
|||||||
{
|
{
|
||||||
// setting an invalid cursor is ok, it means that we don't have any special
|
// setting an invalid cursor is ok, it means that we don't have any special
|
||||||
// cursor
|
// cursor
|
||||||
if ( m_cursor.IsRefTo(&cursor) )
|
if ( m_cursor.IsSameAs(cursor) )
|
||||||
{
|
{
|
||||||
// no change
|
// no change
|
||||||
return false;
|
return false;
|
||||||
|
@@ -631,7 +631,7 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
|
|||||||
if ( !bmpPrev.Ok() )
|
if ( !bmpPrev.Ok() )
|
||||||
bmpPrev = m_bitmap;
|
bmpPrev = m_bitmap;
|
||||||
|
|
||||||
if ( !bmp.IsRefTo(&bmpPrev) )
|
if ( !bmp.IsSameAs(bmpPrev) )
|
||||||
m_statbmp->SetBitmap(bmp);
|
m_statbmp->SetBitmap(bmp);
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STATBMP
|
#endif // wxUSE_STATBMP
|
||||||
|
@@ -40,7 +40,7 @@ public:
|
|||||||
bool operator == (const wxBrushRefData& data) const
|
bool operator == (const wxBrushRefData& data) const
|
||||||
{
|
{
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
m_stipple.IsRefTo(&data.m_stipple) &&
|
m_stipple.IsSameAs(data.m_stipple) &&
|
||||||
m_colour == data.m_colour);
|
m_colour == data.m_colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ public:
|
|||||||
bool operator == (const wxBrushRefData& data) const
|
bool operator == (const wxBrushRefData& data) const
|
||||||
{
|
{
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
m_stipple.IsRefTo(&data.m_stipple) &&
|
m_stipple.IsSameAs(data.m_stipple) &&
|
||||||
m_colour == data.m_colour);
|
m_colour == data.m_colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ public:
|
|||||||
bool operator == ( const wxBrushRefData& brush ) const
|
bool operator == ( const wxBrushRefData& brush ) const
|
||||||
{
|
{
|
||||||
return m_style == brush.m_style &&
|
return m_style == brush.m_style &&
|
||||||
m_stipple.IsRefTo(&brush.m_stipple) &&
|
m_stipple.IsSameAs(brush.m_stipple) &&
|
||||||
m_colour == brush.m_colour &&
|
m_colour == brush.m_colour &&
|
||||||
m_macBrushKind == brush.m_macBrushKind &&
|
m_macBrushKind == brush.m_macBrushKind &&
|
||||||
m_macThemeBrush == brush.m_macThemeBrush &&
|
m_macThemeBrush == brush.m_macThemeBrush &&
|
||||||
|
@@ -1661,7 +1661,7 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const
|
|||||||
|
|
||||||
bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
bool wxWindowMac::SetCursor(const wxCursor& cursor)
|
||||||
{
|
{
|
||||||
if (m_cursor.IsRefTo(&cursor))
|
if (m_cursor.IsSameAs(cursor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!cursor.IsOk())
|
if (!cursor.IsOk())
|
||||||
|
@@ -79,7 +79,7 @@ public:
|
|||||||
bool operator == (const wxBrushRefData& data) const
|
bool operator == (const wxBrushRefData& data) const
|
||||||
{
|
{
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
m_stipple.IsRefTo(&data.m_stipple) &&
|
m_stipple.IsSameAs(data.m_stipple) &&
|
||||||
m_colour == data.m_colour);
|
m_colour == data.m_colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ class wxPenRefData: public wxObjectRefData
|
|||||||
m_capStyle == data.m_capStyle &&
|
m_capStyle == data.m_capStyle &&
|
||||||
m_joinStyle == data.m_joinStyle &&
|
m_joinStyle == data.m_joinStyle &&
|
||||||
m_colour == data.m_colour &&
|
m_colour == data.m_colour &&
|
||||||
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
|
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
||||||
(m_style != wxUSER_DASH ||
|
(m_style != wxUSER_DASH ||
|
||||||
(m_dash == data.m_dash &&
|
(m_dash == data.m_dash &&
|
||||||
memcmp(m_dash, data.m_dash, m_countDashes*sizeof(wxDash)) == 0));
|
memcmp(m_dash, data.m_dash, m_countDashes*sizeof(wxDash)) == 0));
|
||||||
|
@@ -124,7 +124,7 @@ bool wxBrushRefData::operator==(const wxBrushRefData& data) const
|
|||||||
// don't compare HBRUSHes
|
// don't compare HBRUSHes
|
||||||
return m_style == data.m_style &&
|
return m_style == data.m_style &&
|
||||||
m_colour == data.m_colour &&
|
m_colour == data.m_colour &&
|
||||||
m_stipple.IsRefTo(&data.m_stipple);
|
m_stipple.IsSameAs(data.m_stipple);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)
|
void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)
|
||||||
|
@@ -42,7 +42,7 @@ public:
|
|||||||
bool operator == (const wxBrushRefData& data) const
|
bool operator == (const wxBrushRefData& data) const
|
||||||
{
|
{
|
||||||
return (m_style == data.m_style &&
|
return (m_style == data.m_style &&
|
||||||
m_stipple.IsRefTo(&data.m_stipple) &&
|
m_stipple.IsSameAs(&data.m_stipple) &&
|
||||||
m_colour == data.m_colour);
|
m_colour == data.m_colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user