Frame: stop using "virtual" signals

They don't work as expected across DLL boundaries on MSVC: connecting
to Frame::isFocusedChanged using the PMF syntax fails.

The reason has to do with how MSVC implements pointers to virtual
function members: they are "regular" function pointers to a DLL-local
stub that implements the virtual call. For that reason, a connect()
happening in client code would generate a pointer for the signal that
doesn't compare equal to the same pointer generated from inside KDDW;
and moc-generated code relies on this comparison to find the index of
the signal.

Just avoid the whole thing: rename the non-signal virtual call into a
"callback", and reimplement it in the first QObject subclass to turn it
into a proper signal.
This commit is contained in:
Giuseppe D'Angelo
2020-12-22 11:03:20 +01:00
committed by Sergio Martins
parent e53b9c71da
commit 17539e5b88
4 changed files with 20 additions and 6 deletions

View File

@@ -109,7 +109,7 @@ void FocusScope::Private::setIsFocused(bool is)
emitDockWidgetFocusChanged();
if (!m_inCtor) // Hack so we don't call pure-virtual
Q_EMIT q->isFocusedChanged();
/* Q_EMIT */ q->isFocusedChangedCallback();
}
}
@@ -125,7 +125,7 @@ void FocusScope::Private::onFocusObjectChanged(QObject *obj)
if (is && m_lastFocusedInScope != widget && !qobject_cast<TitleBar*>(obj)) {
m_lastFocusedInScope = widget;
setIsFocused(is);
Q_EMIT q->focusedWidgetChanged();
/* Q_EMIT */ q->focusedWidgetChangedCallback();
} else {
setIsFocused(is);
}