diff options
-rw-r--r-- | Swift/QtUI/QtMainWindow.cpp | 10 | ||||
-rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp | 3 |
2 files changed, 9 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 @@ -6,9 +6,10 @@ #include <Swift/QtUI/QtMainWindow.h> +#include <memory> + #include <boost/bind.hpp> #include <boost/optional.hpp> -#include <memory> #include <QAction> #include <QBoxLayout> @@ -357,7 +358,7 @@ void QtMainWindow::setMyStatusType(StatusShow::Type 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); @@ -392,18 +393,19 @@ void QtMainWindow::openCertificateDialog(const std::vector<Certificate::ref>& ch 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); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp index ace6bcb..610c4f3 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp @@ -33,6 +33,7 @@ class FormParserTest : public CppUnit::TestFixture { )); Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); + CPPUNIT_ASSERT(payload); CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getTitle()); CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), payload->getInstructions()); CPPUNIT_ASSERT_EQUAL(Form::SubmitType, payload->getType()); @@ -65,6 +66,7 @@ class FormParserTest : public CppUnit::TestFixture { "</x>")); Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); + CPPUNIT_ASSERT(payload); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(payload->getFields().size())); // PAGE ONE - parsing of element types CPPUNIT_ASSERT_EQUAL(std::string("P1"), payload->getPages()[0]->getLabel()); @@ -126,6 +128,7 @@ class FormParserTest : public CppUnit::TestFixture { "</x>")); Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); + CPPUNIT_ASSERT(payload); CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size())); CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), payload->getFields()[0]->getValues()[0]); |