forked from qt-creator/qt-creator
CppEditor: Fix InsertVirtualMethods quickfix
... for base classes pulled in via using declarations. This is probably just a hack, like everything connected to the weird ClassOrNamespace class. Fixes: QTCREATORBUG-32162 Change-Id: Id7fbcf569fca231284ad0026cc040b16ac04960c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -559,9 +559,17 @@ public:
|
|||||||
while (!baseClassQueue.isEmpty()) {
|
while (!baseClassQueue.isEmpty()) {
|
||||||
ClassOrNamespace *clazz = baseClassQueue.dequeue();
|
ClassOrNamespace *clazz = baseClassQueue.dequeue();
|
||||||
visitedBaseClasses.insert(clazz);
|
visitedBaseClasses.insert(clazz);
|
||||||
const QList<ClassOrNamespace *> bases = clazz->usings();
|
QList<ClassOrNamespace *> bases = clazz->usings();
|
||||||
for (const ClassOrNamespace *baseClass : bases) {
|
while (!bases.isEmpty()) {
|
||||||
|
const ClassOrNamespace *baseClass = bases.takeFirst();
|
||||||
const QList<Symbol *> symbols = baseClass->symbols();
|
const QList<Symbol *> symbols = baseClass->symbols();
|
||||||
|
|
||||||
|
// See QTCREATORBUG-32162.
|
||||||
|
if (symbols.isEmpty() && baseClass->usings().size() == 1) {
|
||||||
|
bases.prepend(baseClass->usings().first());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (Symbol *symbol : symbols) {
|
for (Symbol *symbol : symbols) {
|
||||||
Class *base = symbol->asClass();
|
Class *base = symbol->asClass();
|
||||||
if (base
|
if (base
|
||||||
@@ -1852,6 +1860,21 @@ void InsertVirtualMethodsTest::test_data()
|
|||||||
"};\n\n"
|
"};\n\n"
|
||||||
"struct Derived2 : Derived1\n"
|
"struct Derived2 : Derived1\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
|
|
||||||
|
QTest::newRow("base class via using")
|
||||||
|
<< InsertVirtualMethodsDialog::ModeOnlyDeclarations << false << true
|
||||||
|
<< _(R"cpp(
|
||||||
|
namespace A { struct Base { virtual void foo() = 0; }; } // namespace A
|
||||||
|
using A::Base;
|
||||||
|
struct @Derived : Base {};)cpp")
|
||||||
|
<< _(R"cpp(
|
||||||
|
namespace A { struct Base { virtual void foo() = 0; }; } // namespace A
|
||||||
|
using A::Base;
|
||||||
|
struct @Derived : Base {
|
||||||
|
// Base interface
|
||||||
|
public:
|
||||||
|
void foo() override;
|
||||||
|
};)cpp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertVirtualMethodsTest::test()
|
void InsertVirtualMethodsTest::test()
|
||||||
|
Reference in New Issue
Block a user