summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-12-09 08:07:40 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2016-12-09 08:43:04 (GMT)
commit52b10e51563939db8a19bb9336e3280f198b771e (patch)
treec5841e71ce5221329204c26b2f9c16ca879c3cba /Swift
parent7b34ce22fd646c252791a3eda5005178ab3f19bf (diff)
downloadswift-52b10e51563939db8a19bb9336e3280f198b771e.zip
swift-52b10e51563939db8a19bb9336e3280f198b771e.tar.bz2
Do not emit windowClosing signal in QtTabbable dtor
Instead, handle the QCloseEvent and emit the windowClosing signal there. This is an attempt to fix a crash I am unable to reproduce but which crash stack includes the signal emit in ~QtTabbable. Test-Information: Builds on macOS 10.12.1 with clang master. All unit and integration tests pass. Manual login and close of Swift worked without a crash. Change-Id: I470f3c5362fd0f502c542560854424e87fc0727e
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtTabbable.cpp7
-rw-r--r--Swift/QtUI/QtTabbable.h4
2 files changed, 9 insertions, 2 deletions
diff --git a/Swift/QtUI/QtTabbable.cpp b/Swift/QtUI/QtTabbable.cpp
index ed0963b..df2cbfe 100644
--- a/Swift/QtUI/QtTabbable.cpp
+++ b/Swift/QtUI/QtTabbable.cpp
@@ -1,68 +1,73 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtTabbable.h>
#include <QApplication>
#include <QKeyEvent>
#include <QShortcut>
#include <Swiften/Base/Platform.h>
#include <Swift/QtUI/QtChatTabs.h>
#include <Swift/QtUI/QtUtilities.h>
namespace Swift {
QtTabbable::QtTabbable() : QWidget() {
}
QtTabbable::~QtTabbable() {
- emit windowClosing();
+
}
bool QtTabbable::isWidgetSelected() {
/*isActiveWindow() shouldn't be necessary, but I don't trust it as far as I can throw it*/
if (!isActiveWindow()) {
return false;
}
QtChatTabs* parent = qobject_cast<QtChatTabs*>(window());
return parent ? parent->getCurrentTab() == this : isAncestorOf(QApplication::focusWidget());
}
bool QtTabbable::event(QEvent* event) {
QKeyEvent* keyEvent = dynamic_cast<QKeyEvent*>(event);
if (keyEvent) {
// According to Qt's focus documentation, one can only override CTRL+TAB via reimplementing QWidget::event().
if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Tab) {
// Only handle KeyRelease event as Linux also generate KeyPress event in case of CTRL+TAB being pressed
// in the roster of a MUC.
if (keyEvent->type() == QEvent::KeyRelease) {
emit requestNextTab();
}
return true;
}
#ifdef SWIFTEN_PLATFORM_LINUX
else if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Backtab && keyEvent->type() != QEvent::KeyRelease) {
#else
else if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Backtab) {
#endif
#ifdef SWIFTEN_PLATFORM_WINDOWS
// Windows emits both the KeyPress and KeyRelease events.
if (keyEvent->type() == QEvent::KeyPress) {
#else
if (keyEvent->type() != QEvent::ShortcutOverride) {
#endif
emit requestPreviousTab();
}
return true;
}
}
return QWidget::event(event);
}
+void QtTabbable::closeEvent(QCloseEvent* event) {
+ emit windowClosing();
+ event->accept();
+}
+
}
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index 4073ab4..5837702 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -1,40 +1,42 @@
/*
* Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <string>
#include <QWidget>
namespace Swift {
class QtTabbable : public QWidget {
Q_OBJECT
public:
enum AlertType {NoActivity, WaitingActivity, ImpendingActivity};
virtual ~QtTabbable();
+
bool isWidgetSelected();
virtual AlertType getWidgetAlertState() {return NoActivity;}
virtual int getCount() {return 0;}
virtual std::string getID() const = 0;
virtual void setEmphasiseFocus(bool /*emphasise*/) {}
protected:
QtTabbable();
- bool event(QEvent* event);
+ virtual bool event(QEvent* event);
+ virtual void closeEvent(QCloseEvent* event);
signals:
void titleUpdated();
void countUpdated();
void windowClosing();
void windowOpening();
void wantsToActivate();
void requestPreviousTab();
void requestNextTab();
void requestActiveTab();
void requestFlash();
};
}