From ae9a504def982f32111bbcc28788d7ad1cadaa10 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 2 Apr 2011 19:28:09 +0200 Subject: moc: qobject_cast cannot be used if the class privately iherit from QObject because the qobject_cast function do not have the right to access the staticMetaObject. --- src/tools/moc/generator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 67aba8f..aea156d 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -920,7 +920,9 @@ void Generator::generateStaticMetacall() else fprintf(out, " "); fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n"); - fprintf(out, " Q_ASSERT(qobject_cast<%s *>(_o));\n", cdef->classname.constData()); +#ifndef QT_NO_DEBUG + fprintf(out, " Q_ASSERT(staticMetaObject.cast(_o));\n"); +#endif fprintf(out, " %s *_t = static_cast<%s *>(_o);\n", cdef->classname.constData(), cdef->classname.constData()); fprintf(out, " switch (_id) {\n"); for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) { -- cgit v0.12