Skip to content

Commit

Permalink
3100: use deferred deletion for flags editor checkboxes (TrenchBroom#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwa authored Apr 20, 2020
1 parent b257087 commit 67941e2
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/src/View/FlagsEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace TrenchBroom {
m_checkBoxes.resize(count, nullptr);
m_values.resize(count, 0);

deleteChildWidgetsAndLayout(this);
deleteChildWidgetsLaterAndDeleteLayout(this);

auto* layout = new QGridLayout();
layout->setHorizontalSpacing(LayoutConstants::WideHMargin);
Expand Down
7 changes: 5 additions & 2 deletions common/src/View/QtUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,11 @@ namespace TrenchBroom {
tableView->resizeRowsToContents();
}

void deleteChildWidgetsAndLayout(QWidget* widget) {
qDeleteAll(widget->findChildren<QWidget*>("", Qt::FindDirectChildrenOnly));
void deleteChildWidgetsLaterAndDeleteLayout(QWidget* widget) {
const QList<QWidget*> children = widget->findChildren<QWidget*>("", Qt::FindDirectChildrenOnly);
for (QWidget* childWidget : children) {
childWidget->deleteLater();
}

delete widget->layout();
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/View/QtUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace TrenchBroom {
};

void autoResizeRows(QTableView* tableView);
void deleteChildWidgetsAndLayout(QWidget* widget);
void deleteChildWidgetsLaterAndDeleteLayout(QWidget* widget);

void showModelessDialog(QDialog* dialog);
}
Expand Down
2 changes: 1 addition & 1 deletion common/src/View/TextureCollectionEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace TrenchBroom {
}

void TextureCollectionEditor::createGui() {
deleteChildWidgetsAndLayout(this);
deleteChildWidgetsLaterAndDeleteLayout(this);

QWidget* collectionEditor = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion common/src/View/ViewEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace TrenchBroom {
}

void ViewEditor::createGui() {
deleteChildWidgetsAndLayout(this);
deleteChildWidgetsLaterAndDeleteLayout(this);

auto* sizer = new QGridLayout();
sizer->setContentsMargins(
Expand Down

0 comments on commit 67941e2

Please sign in to comment.