Fix using weak references to incomplete classes.

wxWeakRef can work with forward-declared classes provided dynamic_cast<> is
available but this wasn't detected as being the case due to the use of the
obsolete HAVE_DYNAMIC_CAST in its code.

Replace HAVE_DYNAMIC_CAST with !wxNO_RTTI to fix this.

Also add a unit test checking that this does work.

Closes #11916.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63986 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-04-15 22:47:37 +00:00
parent 52cda80e1c
commit 7f2468e96a
2 changed files with 23 additions and 4 deletions

View File

@@ -149,7 +149,7 @@ protected:
DoAssign( pobj, ptbase );
}
#ifdef HAVE_DYNAMIC_CAST
#ifndef wxNO_RTTI
void AssignHelper(T* pobj, wxInt2Type<false>)
{
// A last way to get a trackable pointer
@@ -165,7 +165,7 @@ protected:
Release();
}
}
#endif // HAVE_DYNAMIC_CAST
#endif // RTTI enabled
void AssignCopy(const wxWeakRefImpl& wr)
{
@@ -254,7 +254,7 @@ public:
};
#ifdef HAVE_DYNAMIC_CAST
#ifndef wxNO_RTTI
// Weak ref implementation assign objects are queried for wxTrackable
// using dynamic_cast<>
@@ -338,7 +338,7 @@ protected:
T *m_pobj;
};
#endif // #ifdef HAVE_DYNAMIC_CAST
#endif // RTTI enabled
// Provide some basic types of weak references