Skip to content

Commit

Permalink
moc: qobject_cast cannot be used if the class privately iherit from Q…
Browse files Browse the repository at this point in the history
…Object

because the qobject_cast function do not have the right to access the
staticMetaObject.
  • Loading branch information
ogoffart committed Apr 4, 2011
1 parent 0a330c0 commit ae9a504
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tools/moc/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ae9a504

Please sign in to comment.