c++ - QObject::connect crash at signalOffset(senderMetaObject) due to QMetaObject::superdata contains null data -
my connection code following:
qobject::connect(_scene, &vscene::activeobjectchanged, _scene->manipulatornode(), &vmanipulatornode::onactiveobjectchanged);
vscene
subclass of vnode
, subclass of qobject
. both of them contain q_object
macro.
vscene signal sender:
class vscene : public vnode { q_object public slots: void markactiveobject(vobject *obj); void unmarkactiveobject(vobject *obj); signals: void activeobjectchanged(vobject *obj); }
vnode:
class vnode : public qobject { q_object }
vmanipulator:
class vmanipulatornode : public vnode { public: void onactiveobjectchanged(vobject *obj); }
the program crashes while calling qobject::connect
, @ function
signal_index += qmetaobjectprivate::signaloffset(sendermetaobject);
whiling debugging, found out superdata
pointer of qmetaobject
of sender vscene
contains null data.
i see qmetaobject
of vscene
point qmetaobject
of vnode
, , then, qmetaobject
of vnode
point qmetaobject
of qobject
. here, @ crash position, qmetaobject
of vscene
contains null data
all moc files, including moc_vscene
, moc_vnode
, generated qt.
moc_vscene.cpp:
const qmetaobject vk::vscene::staticmetaobject = { { &vnode::staticmetaobject, qt_meta_stringdata_vk__vscene.data, qt_meta_data_vk__vscene, qt_static_metacall, q_nullptr, q_nullptr} };
moc_vnode.cpp:
struct qt_meta_stringdata_vk__vnode_t { qbytearraydata data[1]; char stringdata0[10]; }; #define qt_moc_literal(idx, ofs, len) \ q_static_byte_array_data_header_initializer_with_offset(len, \ qptrdiff(offsetof(qt_meta_stringdata_vk__vnode_t, stringdata0) + ofs \ - idx * sizeof(qbytearraydata)) \ ) static const qt_meta_stringdata_vk__vnode_t qt_meta_stringdata_vk__vnode = { { qt_moc_literal(0, 0, 9) // "vk::vnode" }, "vk::vnode" }; #undef qt_moc_literal static const uint qt_meta_data_vk__vnode[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalcount 0 // eod }; void vk::vnode::qt_static_metacall(qobject *_o, qmetaobject::call _c, int _id, void **_a) { q_unused(_o); q_unused(_id); q_unused(_c); q_unused(_a); } const qmetaobject vk::vnode::staticmetaobject = { { &qobject::staticmetaobject, qt_meta_stringdata_vk__vnode.data, qt_meta_data_vk__vnode, qt_static_metacall, q_nullptr, q_nullptr} };
note: while debugging in visual studio, it's shown vnode::staticmetaobject
contains null data, it's strange of static member including qt_meta_stringdata_vk__vnode
, qt_meta_data_vk__vnode
right (non-null). here evidence
the code emitting signal:
void vscene::markactiveobject(vobject *obj) { if (obj){ obj->markactive(); emit activeobjectchanged(obj); } }
the first thing notice should change:
public: void onactiveobjectchanged(vobject *obj);
to:
public slots: void onactiveobjectchanged(vobject *obj);
not sure info given if solve it, not right.
Comments
Post a Comment