DoAssign( pobj, ptbase );
}
-#ifdef HAVE_DYNAMIC_CAST
+#ifndef wxNO_RTTI
void AssignHelper(T* pobj, wxInt2Type<false>)
{
// A last way to get a trackable pointer
Release();
}
}
-#endif // HAVE_DYNAMIC_CAST
+#endif // RTTI enabled
void AssignCopy(const wxWeakRefImpl& wr)
{
};
-#ifdef HAVE_DYNAMIC_CAST
+#ifndef wxNO_RTTI
// Weak ref implementation assign objects are queried for wxTrackable
// using dynamic_cast<>
T *m_pobj;
};
-#endif // #ifdef HAVE_DYNAMIC_CAST
+#endif // RTTI enabled
// Provide some basic types of weak references
// also include in it's own registry so that these tests can be run alone
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( WeakRefTestCase, "WeakRefTestCase" );
+
+// Test weak reference to an incomplete type, this should work if the type is
+// fully defined before it is used (but currently doesn't, see #11916)
+struct ForwardDeclaredClass;
+wxWeakRef<ForwardDeclaredClass> g_incompleteWeakRef;
+
+struct ForwardDeclaredClass : wxEvtHandler { };
+
void WeakRefTestCase::DeclareTest()
{
{
CPPUNIT_ASSERT( wreh.get() == &eh );
CPPUNIT_ASSERT( wrot.get() == &ot );
}
+
+ // This test requires a working dynamic_cast<>
+#ifndef wxNO_RTTI
+ {
+ ForwardDeclaredClass fdc;
+ g_incompleteWeakRef = &fdc;
+ CPPUNIT_ASSERT( g_incompleteWeakRef );
+ }
+
+ CPPUNIT_ASSERT( !g_incompleteWeakRef );
+#endif // RTTI enabled
}
void WeakRefTestCase::AssignTest()