summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-12-23 18:04:37 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-28 09:49:13 +0000
commit6b297b7adf6dc2f66e066f06d412e5477fda443e (patch)
tree4720127527c38dbaaceb0a226bcbbc8a2c3abdb0
parentf7414a47b00a0caed9a145e817abcf7543a7b13c (diff)
Qt Designer: Fix crash when changing names in Object inspector
Use QSortFilterProxyModel's sorting capabilities instead of sorting the children when building the model. This avoids rebuilding the entire model after changing a name and fixes a crash after changing the name in the object inspector and then clicking on another item instead of pressing Enter. Fixes: QTBUG-99404 Change-Id: I5c13ccfef446ed8491327fcf2ff5c19531e6c102 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit f764dc21cb298724a5d460d552a6cff96c995f36) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/designer/src/components/objectinspector/objectinspector.cpp2
-rw-r--r--src/designer/src/components/objectinspector/objectinspectormodel.cpp9
2 files changed, 3 insertions, 8 deletions
diff --git a/src/designer/src/components/objectinspector/objectinspector.cpp b/src/designer/src/components/objectinspector/objectinspector.cpp
index c34df34f9..77d31e0ff 100644
--- a/src/designer/src/components/objectinspector/objectinspector.cpp
+++ b/src/designer/src/components/objectinspector/objectinspector.cpp
@@ -255,6 +255,8 @@ ObjectInspector::ObjectInspectorPrivate::ObjectInspectorPrivate(QDesignerFormEdi
m_filterModel->setSourceModel(m_model);
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_treeView->setModel(m_filterModel);
+ m_treeView->setSortingEnabled(true);
+ m_treeView->sortByColumn(0, Qt::AscendingOrder);
m_treeView->setItemDelegate(new ObjectInspectorDelegate);
m_treeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_treeView->header()->setSectionResizeMode(1, QHeaderView::Stretch);
diff --git a/src/designer/src/components/objectinspector/objectinspectormodel.cpp b/src/designer/src/components/objectinspector/objectinspectormodel.cpp
index 3f8c6a665..74d7793c0 100644
--- a/src/designer/src/components/objectinspector/objectinspectormodel.cpp
+++ b/src/designer/src/components/objectinspector/objectinspectormodel.cpp
@@ -63,11 +63,6 @@ static inline QObject *objectOfItem(const QStandardItem *item) {
return qvariant_cast<QObject *>(item->data(DataRole));
}
-static bool sortEntry(const QObject *a, const QObject *b)
-{
- return a->objectName() < b->objectName();
-}
-
static bool sameIcon(const QIcon &i1, const QIcon &i2)
{
if (i1.isNull() && i2.isNull())
@@ -289,9 +284,7 @@ namespace qdesigner_internal {
if (!object->children().isEmpty()) {
ButtonGroupList buttonGroups;
- QObjectList children = object->children();
- std::sort(children.begin(), children.end(), sortEntry);
- for (QObject *childObject : qAsConst(children)) {
+ for (QObject *childObject : object->children()) {
// Managed child widgets unless we had a container extension
if (childObject->isWidgetType()) {
if (!containerExtension) {