diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-04-27 08:58:05 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-05-02 11:05:54 +0000 |
commit | 365bddbe0e8cb53a30e818c0ebd54e2a6c8560b1 (patch) | |
tree | 5a251439ba5d0c818da73e083ceb58d68bf18b4c | |
parent | a21c3b7e26a28ed27a57793b58b662a7bf506930 (diff) | |
download | qttools-365bddbe0e8cb53a30e818c0ebd54e2a6c8560b1.tar.gz |
Qt Designer: Fix a crash when deleting an automatically promoted class.
Classes that are no longer present (missing plugins) are automatically
promoted by Qt Designer. Deleting such a class currently causes
a crash when further promoted classes using them as a base class exist.
Extend QDesignerPromotion::removePromotedClass() to change the base class
of such classes to the base class of the automatically promoted class.
Task-number: QTBUG-52963
Change-Id: I39591dc198ee3a4a4a0a5d86bbc8e08bbfb03059
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
-rw-r--r-- | src/designer/src/lib/shared/qdesigner_promotion.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/designer/src/lib/shared/qdesigner_promotion.cpp b/src/designer/src/lib/shared/qdesigner_promotion.cpp index 63d54b45c..dba920565 100644 --- a/src/designer/src/lib/shared/qdesigner_promotion.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotion.cpp @@ -290,6 +290,23 @@ namespace qdesigner_internal { *errorMessage = QCoreApplication::tr("The class %1 cannot be removed because it is still referenced.").arg(className); return false; } + // QTBUG-52963: Check for classes that specify the to-be-removed class as + // base class of a promoted class. This should not happen in the normal case + // as promoted classes cannot serve as base for further promotion. It is possible + // though if a class provided by a plugin (say Qt WebKit's QWebView) is used as + // a base class for a promoted widget B and the plugin is removed in the next + // launch. QWebView will then appear as promoted class itself and the promoted + // class B will depend on it. When removing QWebView, the base class of B will + // be changed to that of QWebView by the below code. + const PromotedClasses promotedList = promotedClasses(); + for (PromotedClasses::const_iterator it = promotedList.constBegin(), end = promotedList.constEnd(); it != end; ++it) { + if (it->baseItem->name() == className) { + const QString extends = widgetDataBase->item(index)->extends(); + qWarning().nospace() << "Warning: Promoted class " << it->promotedItem->name() + << " extends " << className << ", changing its base class to " << extends << '.'; + it->promotedItem->setExtends(extends); + } + } widgetDataBase->remove(index); return true; } |