summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/Roster/QtFilterWidget.cpp12
-rw-r--r--Swift/QtUI/Roster/QtFilterWidget.h5
2 files changed, 15 insertions, 2 deletions
diff --git a/Swift/QtUI/Roster/QtFilterWidget.cpp b/Swift/QtUI/Roster/QtFilterWidget.cpp
index 4df4a39..a52dfff 100644
--- a/Swift/QtUI/Roster/QtFilterWidget.cpp
+++ b/Swift/QtUI/Roster/QtFilterWidget.cpp
@@ -53,6 +53,10 @@ QtFilterWidget::~QtFilterWidget() {
}
bool QtFilterWidget::eventFilter(QObject*, QEvent* event) {
+ if (!treeView_) {
+ return false;
+ }
+
if (event->type() == QEvent::KeyPress ||
event->type() == QEvent::KeyRelease ||
// InputMethodQuery got introduced in Qt 5.
@@ -119,6 +123,10 @@ void QtFilterWidget::pushAllFilters() {
}
void QtFilterWidget::updateRosterFilters() {
+ if (!treeView_) {
+ return;
+ }
+
if (fuzzyRosterFilter_) {
if (filterLineEdit_->text().isEmpty()) {
// remove currently installed search filter and put old filters back
@@ -141,6 +149,10 @@ void QtFilterWidget::updateRosterFilters() {
}
void QtFilterWidget::updateSearchFilter() {
+ if (!treeView_) {
+ return;
+ }
+
if (fuzzyRosterFilter_) {
treeView_->getRoster()->removeFilter(fuzzyRosterFilter_);
delete fuzzyRosterFilter_;
diff --git a/Swift/QtUI/Roster/QtFilterWidget.h b/Swift/QtUI/Roster/QtFilterWidget.h
index ea3c325..85f607e 100644
--- a/Swift/QtUI/Roster/QtFilterWidget.h
+++ b/Swift/QtUI/Roster/QtFilterWidget.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (c) 2016 Isode Limited.
+ * Copyright (c) 2016-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -15,6 +15,7 @@
#include <vector>
#include <QBoxLayout>
+#include <QPointer>
#include <QWidget>
#include <Swift/Controllers/Roster/FuzzyRosterFilter.h>
@@ -46,7 +47,7 @@ class QtFilterWidget : public QWidget {
private:
QtClosableLineEdit* filterLineEdit_;
- QtTreeWidget* treeView_;
+ QPointer<QtTreeWidget> treeView_;
UIEventStream* eventStream_;
std::vector<RosterFilter*> filters_;
QAbstractItemModel* sourceModel_;