Hi
I'm really struggling with a signal which has a default parameter. Here is the way I declare the signal and slot:
// Signal declaration:
signals:
void layoutChanged
(QObject* added_object
= 0);
// Slot declaration:
public slots:
void rebuildTreeStructure
(QObject* new_focus
= 0);
// Signal declaration:
signals:
void layoutChanged(QObject* added_object = 0);
// Slot declaration:
public slots:
void rebuildTreeStructure(QObject* new_focus = 0);
To copy to clipboard, switch view to plain text mode
And I connect it to a slot as follows:
connect(d_observer,
SIGNAL(layoutChanged
(QObject*)),
SLOT(rebuildTreeStructure
(QObject*)));
connect(d_observer,SIGNAL(layoutChanged(QObject*)),SLOT(rebuildTreeStructure(QObject*)));
To copy to clipboard, switch view to plain text mode
Then for whatever reason I emit the signal with a valid QObject reference and I always get a null in the slot. I've been trying to debug this for ages and found the following:
- Looking at the _moc file of the class emitting the signal I see that it calls it correctly and the _t1 parameter is valid during debugging:
// SIGNAL 7
void Qtilities
::Core::Observer::layoutChanged(QObject * _t1
) {
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
}
// SIGNAL 7
void Qtilities::Core::Observer::layoutChanged(QObject * _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 7, _a);
}
To copy to clipboard, switch view to plain text mode
Going through the stack I see that qt_metalcall is called with the wrong argument (or it looks like it). This function is called with _id = 8, which is the signal with its default parameter.
int Qtilities
::Core::Observer::qt_metacall(QMetaObject::Call _c,
int _id,
void **_a
) {
_id
= QObject::qt_metacall(_c, _id, _a
);
if (_id < 0)
return _id;
switch (_id) {
case 0: modificationStateChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 1: monitoredPropertyChanged((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< QList<QObject*>(*)>(_a[2]))); break;
case 2: monitoredPropertyChanged((*reinterpret_cast< const char*(*)>(_a[1]))); break;
case 3: propertyChangeFiltered((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< QList<QObject*>(*)>(_a[2]))); break;
case 4: propertyChangeFiltered((*reinterpret_cast< const char*(*)>(_a[1]))); break;
case 5: numberOfSubjectsChanged((*reinterpret_cast< Observer::SubjectChangeIndication(*)>(_a[1])),(*reinterpret_cast< QList<QObject*>(*)>(_a[2]))); break;
case 6: numberOfSubjectsChanged((*reinterpret_cast< Observer::SubjectChangeIndication(*)>(_a[1]))); break;
case 7: layoutChanged
((*reinterpret_cast<
QObject*(*)>
(_a
[1])));
break;
case 8: layoutChanged(); break;
default: ;
}
int Qtilities::Core::Observer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QObject::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: modificationStateChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 1: monitoredPropertyChanged((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< QList<QObject*>(*)>(_a[2]))); break;
case 2: monitoredPropertyChanged((*reinterpret_cast< const char*(*)>(_a[1]))); break;
case 3: propertyChangeFiltered((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< QList<QObject*>(*)>(_a[2]))); break;
case 4: propertyChangeFiltered((*reinterpret_cast< const char*(*)>(_a[1]))); break;
case 5: numberOfSubjectsChanged((*reinterpret_cast< Observer::SubjectChangeIndication(*)>(_a[1])),(*reinterpret_cast< QList<QObject*>(*)>(_a[2]))); break;
case 6: numberOfSubjectsChanged((*reinterpret_cast< Observer::SubjectChangeIndication(*)>(_a[1]))); break;
case 7: layoutChanged((*reinterpret_cast< QObject*(*)>(_a[1]))); break;
case 8: layoutChanged(); break;
default: ;
}
To copy to clipboard, switch view to plain text mode
Maybe I'm missing something simple. Any inputs will be appreciated.
Thanks,
Jaco
Bookmarks