Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

qtcollider: be more verbose when QObject construction fails

  • Loading branch information...
commit 7b6c20e1390e995c183e7c8286c793194f4dccee 1 parent 46f904f
@jleben jleben authored
Showing with 24 additions and 4 deletions.
  1. +23 −2 QtCollider/QcObjectFactory.h
  2. +1 −2  QtCollider/QcWidgetFactory.h
View
25 QtCollider/QcObjectFactory.h
@@ -48,6 +48,28 @@ class QcAbstractFactory
virtual QObjectProxy *newInstance( PyrObject *, QtCollider::Variant arg[10] ) = 0;
};
+static void qcNoConstructorMsg( const QMetaObject *metaObject, int argc, QtCollider::Variant *argv )
+{
+ QString str = QString("No appropriate constructor found for %1 (")
+ .arg( metaObject->className() );
+
+ for (int i = 0; i < argc; ++i) {
+ int t_id = argv[i].type();
+
+ if (t_id != QMetaType::Void)
+ {
+ if (i > 0) str += ", ";
+ str += QMetaType::typeName(t_id);
+ }
+ else
+ break;
+ }
+
+ str += ")";
+
+ qcErrorMsg( str );
+}
+
template <class QOBJECT> class QcObjectFactory : public QcAbstractFactory
{
public:
@@ -78,8 +100,7 @@ template <class QOBJECT> class QcObjectFactory : public QcAbstractFactory
qObject = qobject_cast<QOBJECT*>(obj);
if( !qObject ) {
- qcErrorMsg( QString("No appropriate constructor found for '%1'.")
- .arg( QOBJECT::staticMetaObject.className() ) );
+ qcNoConstructorMsg( metaObject(), 10, arg );
return 0;
}
}
View
3  QtCollider/QcWidgetFactory.h
@@ -55,8 +55,7 @@ class QcWidgetFactory : public QcObjectFactory<QWIDGET>
w = qobject_cast<QWIDGET*>(obj);
if( !w ) {
- qcErrorMsg( QString("No appropriate constructor found for '%1'.")
- .arg( QWIDGET::staticMetaObject.className() ) );
+ qcNoConstructorMsg( QcObjectFactory<QWIDGET>::metaObject(), 8, &arg[2] );
return 0;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.