From 2a208653fff7647bd3c03f7797d2ef43d5961784 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Wed, 18 Feb 2015 17:10:38 +0100
Subject: Fix crash when a tab drag is aborted in trellis mode

To prevent an infinite recurison during when a tab is returned (added
again) to the original QTabWidget.

The recursion was caused by a show event that is emmitted during insert
and our QtChatTabs::handleWidgetShown function trying to add the tab
again because it is not in the QTabWidget yet; it would be if the show
event would be emitted after the insert is done and not somewhere
during the insert.

Test-Information:

Dragging a tab in trellis mode and *not* dropping it on a tab bar.
Previously this would cause an infinite recursion. Now it just returns
the tab to its previous place.

Tested on OS X 10.9.5 with Qt 5.4.0.

Change-Id: Icd54b95b6f0542b6a9d3921fa1b0ab4df409950a

diff --git a/Swift/QtUI/Trellis/QtDNDTabBar.cpp b/Swift/QtUI/Trellis/QtDNDTabBar.cpp
index 5b042d8..a6806c6 100644
--- a/Swift/QtUI/Trellis/QtDNDTabBar.cpp
+++ b/Swift/QtUI/Trellis/QtDNDTabBar.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -140,7 +140,10 @@ bool QtDNDTabBar::event(QEvent* event) {
 			Qt::DropAction dropAction = drag->exec();
 			if (dropAction == Qt::IgnoreAction) {
 				// aborted drag, put tab back in place
+				// disable event handling during the insert for the tab to prevent infinite recursion (stack overflow)
+				dragWidget->blockSignals(true);
 				dynamic_cast<QTabWidget*>(parent())->insertTab(dragIndex, dragWidget, dragText);
+				dragWidget->blockSignals(false);
 			}
 			return true;
 		}
-- 
cgit v0.10.2-6-g49f6