From ba67437900cfabb1ce9e115c0ec5029c76696b8b Mon Sep 17 00:00:00 2001
From: Thanos Doukoudakis <thanos.doukoudakis@isode.com>
Date: Wed, 28 Jun 2017 16:29:56 +0100
Subject: Fix a crash that occurs when resizing chat layout

This patch fixes a client crash that was caused when the chat layout was
resized to a size that would make some of the chat window out of range.

Test-Information:
Tested on Ubuntu 16.04 LTS (Qt5.5.1) and Windows 10 (Qt5.7.1)

Change-Id: I900c1efcf3c9ae3c416fb4e2d19bd47bf27bbaee

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
@@ -290,7 +290,12 @@ void QtDynamicGridLayout::setDimensions(const QSize& dim) {
                     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;
                 }
-- 
cgit v0.10.2-6-g49f6