moc: Fix type for gadget's CreateInstance metacall

An error similar to the one below would be emitted
by the compiler on the moc generated file:

error: assigning to 'QObject *' from incompatible type 'Gadget *'
       if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break;

Change-Id: I75ae7bd6c46d20db2d47a80eaa08aae302d7d6c8
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Gabriel de Dietrich 2015-05-11 12:52:34 +02:00
parent a4d66348d6
commit d6efc6b543
2 changed files with 12 additions and 1 deletions

View File

@ -1125,7 +1125,8 @@ void Generator::generateStaticMetacall()
fprintf(out, "%s", QByteArray("QPrivateSignal()").constData());
}
fprintf(out, ");\n");
fprintf(out, " if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break;\n");
fprintf(out, " if (_a[0]) *reinterpret_cast<%s**>(_a[0]) = _r; } break;\n",
cdef->hasQGadget ? "void" : "QObject");
}
fprintf(out, " default: break;\n");
fprintf(out, " }\n");

View File

@ -87,6 +87,16 @@ struct QTBUG_31218_Derived : QTBUG_31218<-1<0> {};
class QTBUG_45790 : Bug() { };
#endif
class CreatableGadget
{
Q_GADGET
Q_PROPERTY(int a MEMBER a)
public:
Q_INVOKABLE CreatableGadget() : a(0xdeadbeef) { }
int a;
};
struct MyStruct {};
struct MyStruct2 {};