diff options
author | Tobias Markmann <tm@ayena.de> | 2016-10-05 14:29:42 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2016-10-05 15:07:17 (GMT) |
commit | 51a21158cef39a384c5869c0a0d0b476977bc7a7 (patch) | |
tree | c2606ae173865af50c6f330a74911071fc1e28a8 /Swift/QtUI | |
parent | d29c0ee50a606bf1f4510ea427aef257870c17c0 (diff) | |
download | swift-51a21158cef39a384c5869c0a0d0b476977bc7a7.zip swift-51a21158cef39a384c5869c0a0d0b476977bc7a7.tar.bz2 |
Add missing sensible asserts to testing and QtMainWindow
Test-Information:
Unit tests pass in ASAN-enabled build on macOS 10.12.
Change-Id: I7a8dae7d06e5e1d3dc9391f9c9a342df384d90fc
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 611fc80..0c1dd97 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -1,41 +1,42 @@ /* * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtMainWindow.h> +#include <memory> + #include <boost/bind.hpp> #include <boost/optional.hpp> -#include <memory> #include <QAction> #include <QBoxLayout> #include <QComboBox> #include <QLineEdit> #include <QListWidget> #include <QListWidgetItem> #include <QMenuBar> #include <QPushButton> #include <QTabWidget> #include <QToolBar> #include <Swiften/Base/Platform.h> #include <Swift/Controllers/SettingConstants.h> #include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h> #include <Swift/Controllers/UIEvents/RequestAdHocUIEvent.h> #include <Swift/Controllers/UIEvents/RequestAddUserDialogUIEvent.h> #include <Swift/Controllers/UIEvents/RequestBlockListDialogUIEvent.h> #include <Swift/Controllers/UIEvents/RequestChatWithUserDialogUIEvent.h> #include <Swift/Controllers/UIEvents/RequestHistoryUIEvent.h> #include <Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h> #include <Swift/Controllers/UIEvents/RequestProfileEditorUIEvent.h> #include <Swift/QtUI/QtAdHocCommandWithJIDWindow.h> #include <Swift/QtUI/QtLoginWindow.h> #include <Swift/QtUI/QtSettingsProvider.h> #include <Swift/QtUI/QtSwiftUtil.h> #include <Swift/QtUI/QtTabWidget.h> #include <Swift/QtUI/QtUISettingConstants.h> @@ -330,96 +331,97 @@ void QtMainWindow::handleShowOfflineToggled(bool state) { settings_->storeSetting(SettingConstants::SHOW_OFFLINE, state); showOfflineAction_->setChecked(settings_->getSetting(SettingConstants::SHOW_OFFLINE)); } void QtMainWindow::handleShowEmoticonsToggled(bool state) { settings_->storeSetting(QtUISettingConstants::SHOW_EMOTICONS, state); showEmoticonsAction_->setChecked(settings_->getSetting(QtUISettingConstants::SHOW_EMOTICONS)); } void QtMainWindow::setMyNick(const std::string& nick) { meView_->setNick(P2QSTRING(nick)); } void QtMainWindow::setMyJID(const JID& jid) { meView_->setJID(P2QSTRING(jid.toBare().toString())); } void QtMainWindow::setMyAvatarPath(const std::string& path) { meView_->setAvatar(P2QSTRING(path)); } void QtMainWindow::setMyStatusText(const std::string& status) { meView_->setStatusText(P2QSTRING(status)); } void QtMainWindow::setMyStatusType(StatusShow::Type type) { meView_->setStatusType(type); const bool online = (type != StatusShow::None); treeWidget_->setOnline(online); chatListWindow_->setOnline(online); - foreach (QAction *action, onlineOnlyActions_) { + for (auto action : onlineOnlyActions_) { action->setEnabled(online); } serverAdHocMenu_->setEnabled(online); } void QtMainWindow::setMyContactRosterItem(std::shared_ptr<ContactRosterItem> contact) { meView_->setContactRosterItem(contact); } void QtMainWindow::setConnecting() { meView_->setConnecting(); } void QtMainWindow::setStreamEncryptionStatus(bool tlsInPlaceAndValid) { meView_->setStreamEncryptionStatus(tlsInPlaceAndValid); } void QtMainWindow::openCertificateDialog(const std::vector<Certificate::ref>& chain) { openCertificateDialog(chain, this); } void QtMainWindow::openCertificateDialog(const std::vector<Certificate::ref>& chain, QWidget* parent) { #if defined(SWIFTEN_PLATFORM_MACOSX) CocoaUIHelpers::displayCertificateChainAsSheet(parent, chain); #elif defined(SWIFTEN_PLATFORM_WINDOWS) WinUIHelpers::displayCertificateChainAsSheet(parent, chain); #else QtCertificateViewerDialog::displayCertificateChainAsSheet(parent, chain); #endif } void QtMainWindow::handleAdHocActionTriggered(bool /*checked*/) { QAction* action = qobject_cast<QAction*>(sender()); assert(action); + assert(serverAdHocCommandActions_.indexOf(action) >= 0); DiscoItems::Item command = serverAdHocCommands_[serverAdHocCommandActions_.indexOf(action)]; uiEventStream_->send(std::make_shared<RequestAdHocUIEvent>(command)); } void QtMainWindow::setAvailableAdHocCommands(const std::vector<DiscoItems::Item>& commands) { serverAdHocCommands_ = commands; - foreach (QAction* action, serverAdHocCommandActions_) { + for (auto action : serverAdHocCommandActions_) { delete action; } serverAdHocMenu_->clear(); serverAdHocCommandActions_.clear(); - foreach (DiscoItems::Item command, commands) { + for (const auto& command : commands) { QAction* action = new QAction(P2QSTRING(command.getName()), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(handleAdHocActionTriggered(bool))); serverAdHocMenu_->addAction(action); serverAdHocCommandActions_.append(action); } if (serverAdHocCommandActions_.isEmpty()) { QAction* action = new QAction(tr("No Available Commands"), this); action->setEnabled(false); serverAdHocMenu_->addAction(action); serverAdHocCommandActions_.append(action); } } void QtMainWindow::setBlockingCommandAvailable(bool isAvailable) { openBlockingListEditor_->setVisible(isAvailable); } } |