CppEditor: Mark generated setter as slot only for QObject-derived class

Fixes: QTCREATORBUG-25789
Change-Id: I79174bcd617eb54540009491031cfae380383c41
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-10-21 10:54:48 +02:00
parent 86061fb44a
commit 404cf0f632
2 changed files with 32 additions and 12 deletions

View File

@@ -3971,9 +3971,20 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
}
// setter declaration
const InsertionPointLocator::AccessSpec setterAccessSpec = m_settings->setterAsSlot
? InsertionPointLocator::PublicSlot
: InsertionPointLocator::Public;
InsertionPointLocator::AccessSpec setterAccessSpec = InsertionPointLocator::Public;
if (m_settings->setterAsSlot) {
const QByteArray connectName = "connect";
const Identifier connectId(connectName.data(), connectName.size());
const QList<LookupItem> items = m_operation->context().lookup(&connectId, data.clazz);
for (const LookupItem &item : items) {
if (item.declaration() && item.declaration()->enclosingClass()
&& overview.prettyName(item.declaration()->enclosingClass()->name())
== "QObject") {
setterAccessSpec = InsertionPointLocator::PublicSlot;
break;
}
}
}
const auto createSetterBodyWithSignal = [this, &getSetTemplate, &data] {
QString body;
QTextStream setter(&body);