summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/Trellis/QtDynamicGridLayout.cpp')
-rw-r--r--Swift/QtUI/Trellis/QtDynamicGridLayout.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
index 5600cc8..b753ffa 100644
--- a/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
+++ b/Swift/QtUI/Trellis/QtDynamicGridLayout.cpp
@@ -263,61 +263,66 @@ void QtDynamicGridLayout::setDimensions(const QSize& dim) {
int oldHeight = oldLayout->rowCount();
int maxCol = qMax(oldWidth, dim.width());
int minCol = qMin(oldWidth, dim.width());
int maxRow = qMax(oldHeight, dim.height());
int minRow = qMin(oldHeight, dim.height());
for (int row = 0; row < maxRow; row++) {
for (int col = 0; col < maxCol; col++) {
QLayoutItem* oldItem = oldLayout->itemAtPosition(row, col);
QLayoutItem* newItem = newLayout->itemAtPosition(row, col);
bool removeRow = !(row < dim.height());
bool removeCol = !(col < dim.width());
if (removeCol || removeRow) {
if (oldItem) {
int squeezeRow = removeRow ? (minRow - 1) : row;
int squeezeCol = removeCol ? (minCol - 1) : col;
newItem = newLayout->itemAtPosition(squeezeRow, squeezeCol);
if (!newItem) {
newLayout->addWidget(createDNDTabWidget(this), squeezeRow, squeezeCol);
newItem = newLayout->itemAtPosition(squeezeRow, squeezeCol);
}
QtTabWidget* oldTabWidget = dynamic_cast<QtTabWidget*>(oldItem->widget());
QtTabWidget* newTabWidget = dynamic_cast<QtTabWidget*>(newItem->widget());
assert(oldTabWidget && newTabWidget);
oldTabWidget->hide();
while(oldTabWidget->count()) {
QIcon icon = oldTabWidget->tabIcon(0);
QString text = oldTabWidget->tabText(0);
- newTabWidget->addTab(oldTabWidget->widget(0), icon, text);
+ QWidget* movingTab = oldTabWidget->widget(0);
+ //If handling was allowed, QtChatTabs::handleWidgetShown() would be triggered when newTabWidget has no tabs.
+ //That would access indices of the gridLayout_ that are null because they have been migrated to the newLayout.
+ movingTab->blockSignals(true);
+ newTabWidget->addTab(movingTab, icon, text);
+ movingTab->blockSignals(false);
}
delete oldTabWidget;
}
} else {
if (oldItem) {
newLayout->addWidget(oldItem->widget(), row, col);
newItem = newLayout->itemAtPosition(row, col);
} else {
newLayout->addWidget(createDNDTabWidget(this), row, col);
}
}
}
}
for (int col = 0; col < dim.width(); col++) {
newLayout->setColumnStretch(col, 1);
}
for (int row = 0; row < dim.height(); row++) {
newLayout->setRowStretch(row, 1);
}
setUpdatesEnabled(true);
delete layout();
setLayout(newLayout);
gridLayout_ = newLayout;
resizing_ = false;
setCurrentWidget(restoredWidget);
updateEmphasiseFocusOnTabs();