diff options
author | Tobias Markmann <tm@ayena.de> | 2017-03-30 13:30:06 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2017-03-30 13:30:06 (GMT) |
commit | 3611f7cbdcc1a9c96a542d40a439712cf5c3818a (patch) | |
tree | a107b32c68fe1dab0117c216c664d86da5f0bfb9 | |
parent | 7c047cba09ecc963b66170b0abb2238aa895ccfb (diff) | |
download | swift-3611f7cbdcc1a9c96a542d40a439712cf5c3818a.zip swift-3611f7cbdcc1a9c96a542d40a439712cf5c3818a.tar.bz2 |
Fix access to potential unavailable page in QtUserSearchWindow
Adding searched JIDs to the list of JIDs only makes sense
for cases where there is a multi JID page in the first place.
Coverity raised this issue.
Test-Information:
All unit tests pass on macOS 10.12.4 and the “Add Contact”
and “Start Chat” dialogs using a user search still work.
Change-Id: Icde63f13a2f83690b3189a9c91237eadd6b5218b
-rw-r--r-- | Swift/QtUI/UserSearch/QtUserSearchWindow.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index cf62540..7575a13 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -1,32 +1,32 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2017 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/UserSearch/QtUserSearchWindow.h> #include <memory> #include <boost/bind.hpp> #include <QItemDelegate> #include <QModelIndex> #include <QMovie> #include <QWizardPage> #include <Swift/Controllers/UIEvents/AddContactUIEvent.h> #include <Swift/Controllers/UIEvents/CreateImpromptuMUCUIEvent.h> #include <Swift/Controllers/UIEvents/InviteToMUCUIEvent.h> #include <Swift/Controllers/UIEvents/RequestChatUIEvent.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/QtUI/QtFormResultItemModel.h> #include <Swift/QtUI/QtSwiftUtil.h> #include <Swift/QtUI/UserSearch/QtContactListWidget.h> #include <Swift/QtUI/UserSearch/QtUserSearchDetailsPage.h> #include <Swift/QtUI/UserSearch/QtUserSearchFieldsPage.h> #include <Swift/QtUI/UserSearch/QtUserSearchFirstMultiJIDPage.h> #include <Swift/QtUI/UserSearch/QtUserSearchFirstPage.h> #include <Swift/QtUI/UserSearch/QtUserSearchResultsPage.h> #include <Swift/QtUI/UserSearch/UserSearchDelegate.h> @@ -54,61 +54,61 @@ QtUserSearchWindow::QtUserSearchWindow(UIEventStream* eventStream, UserSearchWin case InviteToChat: title = tr("Add Users to Chat"); break; } setWindowTitle(title); delegate_ = new UserSearchDelegate(this); setFirstPage(title); setSecondPage(); setThirdPage(); detailsPage_ = new QtUserSearchDetailsPage(groups); setPage(4, detailsPage_); connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(handleCurrentChanged(int))); connect(this, SIGNAL(accepted()), this, SLOT(handleAccepted())); clear(); } QtUserSearchWindow::~QtUserSearchWindow() { delete model_; } void QtUserSearchWindow::handleCurrentChanged(int page) { searchNext_ = false; if (firstMultiJIDPage_) { firstMultiJIDPage_->reset(); } resultsPage_->emitCompletenessCheck(); - if (page == 1 && lastPage_ == 3) { + if (firstMultiJIDPage_ && page == 1 && lastPage_ == 3) { addSearchedJIDToList(getContact()); setSecondPage(); } else if (page == 2 && lastPage_ == 1) { setError(""); /* next won't be called if JID is selected */ JID server = getServerToSearch(); clearForm(); onFormRequested(server); setThirdPage(); } else if (page == 3 && lastPage_ == 2) { JID server = getServerToSearch(); handleSearch(); if (type_ == AddContact) { bool remote = firstPage_->byRemoteSearch_->isChecked(); firstPage_->byRemoteSearch_->setChecked(remote); firstPage_->service_->setEditText(P2QSTRING(server.toString())); } else { bool remote = firstMultiJIDPage_->byRemoteSearch_->isChecked(); setFirstPage(); firstMultiJIDPage_->byRemoteSearch_->setChecked(remote); if (remote) { firstMultiJIDPage_->service_->setEditText(P2QSTRING(server.toString())); } } } else if (page == 4) { detailsPage_->clear(); |