summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-09-29 15:22:52 (GMT)
committerTobias Markmann <tm@ayena.de>2016-09-29 15:22:52 (GMT)
commit9abfaaa771f91010dbe01a1b9b5b9e2801956718 (patch)
tree618a5f66ea97d3d8552f72aad6a8e1313c56ec6e /Swift
parent2bf44a1d641c3bc35546cb49d3766f2962f9a984 (diff)
downloadswift-9abfaaa771f91010dbe01a1b9b5b9e2801956718.zip
swift-9abfaaa771f91010dbe01a1b9b5b9e2801956718.tar.bz2
Fix uninitialised class members
Initialised previously uninitialised class members. Changed some raw pointers to std::unique_ptr for clearer and automatically initialised code. Test-Information: Builds on macOS 10.12 and unit tests pass in ASAN-enabled build. Change-Id: I7900fe6131119c228ca92c79c0ee8125137f2e48
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/Chat/ChatController.h2
-rw-r--r--Swift/Controllers/HistoryViewController.h2
-rw-r--r--Swift/Controllers/MainController.h2
-rw-r--r--Swift/Controllers/Roster/UnitTest/RosterTest.cpp8
-rw-r--r--Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp18
-rw-r--r--Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp24
-rw-r--r--Swift/Controllers/UnitTest/MockChatWindow.h14
-rw-r--r--Swift/QtUI/QtHighlightEditor.h2
-rw-r--r--Swift/QtUI/QtLoginWindow.h2
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.cpp4
-rw-r--r--Swift/QtUI/Roster/QtTreeWidget.h8
-rw-r--r--Swift/QtUI/Trellis/QtDNDTabBar.h4
-rw-r--r--Swift/QtUI/Whiteboard/QtWhiteboardWindow.h1
13 files changed, 38 insertions, 53 deletions
diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h
index 99f8e23..7bd6107 100644
--- a/Swift/Controllers/Chat/ChatController.h
+++ b/Swift/Controllers/Chat/ChatController.h
@@ -98,7 +98,7 @@ namespace Swift {
UIEventStream* eventStream_;
Tristate contactSupportsReceipts_;
- bool receivingPresenceFromUs_;
+ bool receivingPresenceFromUs_ = false;
bool userWantsReceipts_;
std::map<std::string, FileTransferController*> ftControllers;
SettingsProvider* settings_;
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index 4c4d9f9..75fc460 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -69,7 +69,7 @@ namespace Swift {
std::map<HistoryMessage::Type, ContactsMap> contacts_;
ContactRosterItem* selectedItem_;
- HistoryMessage::Type selectedItemType_;
+ HistoryMessage::Type selectedItemType_ = HistoryMessage::Chat;
boost::gregorian::date currentResultDate_;
};
}
diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h
index 4f691ee..cc3d45f 100644
--- a/Swift/Controllers/MainController.h
+++ b/Swift/Controllers/MainController.h
@@ -187,7 +187,7 @@ namespace Swift {
int timeBeforeNextReconnect_;
Timer::ref reconnectTimer_;
StatusTracker* statusTracker_;
- bool myStatusLooksOnline_;
+ bool myStatusLooksOnline_ = false;
bool quitRequested_;
bool offlineRequested_;
static const int SecondsToWaitBeforeForceQuitting;
diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
index 4687176..5f500d4 100644
--- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp
@@ -30,11 +30,7 @@ class RosterTest : public CppUnit::TestFixture {
jid1_ = JID("a@b.c");
jid2_ = JID("b@c.d");
jid3_ = JID("c@d.e");
- roster_ = new Roster();
- }
-
- void tearDown() {
- delete roster_;
+ roster_ = std::unique_ptr<Roster>(new Roster());
}
void testGetGroup() {
@@ -136,7 +132,7 @@ class RosterTest : public CppUnit::TestFixture {
}
private:
- Roster *roster_;
+ std::unique_ptr<Roster> roster_;
JID jid1_;
JID jid2_;
JID jid3_;
diff --git a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp
index e4e8bdb..ddc8785 100644
--- a/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp
+++ b/Swift/Controllers/Roster/UnitTest/TableRosterTest.cpp
@@ -13,10 +13,11 @@ std::ostream& operator<<(std::ostream& os, const Swift::TableRoster::Index& i) {
return os;
}
+#include <memory>
+
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <memory>
#include <boost/variant.hpp>
#include <Swiften/Network/DummyTimerFactory.h>
@@ -33,17 +34,12 @@ class TableRosterTest : public CppUnit::TestFixture {
public:
void setUp() {
- timerFactory = new DummyTimerFactory();
- roster = new Roster();
+ timerFactory = std::unique_ptr<DummyTimerFactory>(new DummyTimerFactory());
+ roster = std::unique_ptr<Roster>(new Roster());
jid1 = JID("jid1@example.com");
jid2 = JID("jid2@example.com");
}
- void tearDown() {
- delete roster;
- delete timerFactory;
- }
-
void testAddContact_EmptyRoster() {
/*
std::shared_ptr<TableRoster> tableRoster(createTestling());
@@ -73,7 +69,7 @@ class TableRosterTest : public CppUnit::TestFixture {
}
TableRoster* createTestling() {
- TableRoster* result = new TableRoster(roster, timerFactory, 10);
+ TableRoster* result = new TableRoster(roster.get(), timerFactory.get(), 10);
result->onUpdate.connect(boost::bind(&TableRosterTest::handleUpdate, this, _1));
return result;
}
@@ -83,8 +79,8 @@ class TableRosterTest : public CppUnit::TestFixture {
}
private:
- DummyTimerFactory* timerFactory;
- Roster* roster;
+ std::unique_ptr<DummyTimerFactory> timerFactory;
+ std::unique_ptr<Roster> roster;
JID jid1;
JID jid2;
std::vector<TableRoster::Update> updates;
diff --git a/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp b/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp
index 5822add..3cfebc7 100644
--- a/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp
+++ b/Swift/Controllers/Settings/UnitTest/SettingsProviderHierachyTest.cpp
@@ -4,6 +4,8 @@
* See the COPYING file for more information.
*/
+#include <memory>
+
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
@@ -29,17 +31,11 @@ public:
SettingsProviderHierachyTest() : setting1("somekey", 42) {}
void setUp() {
- bottom = new DummySettingsProvider();
- top = new DummySettingsProvider();
- testling = new SettingsProviderHierachy();
- testling->addProviderToTopOfStack(bottom);
- testling->addProviderToTopOfStack(top);
- }
-
- void tearDown() {
- delete testling;
- delete top;
- delete bottom;
+ bottom = std::unique_ptr<DummySettingsProvider>(new DummySettingsProvider());
+ top = std::unique_ptr<DummySettingsProvider>(new DummySettingsProvider());
+ testling = std::unique_ptr<SettingsProviderHierachy>(new SettingsProviderHierachy());
+ testling->addProviderToTopOfStack(bottom.get());
+ testling->addProviderToTopOfStack(top.get());
}
void testEmpty() {
@@ -82,9 +78,9 @@ public:
CPPUNIT_ASSERT_EQUAL(17, testling->getSetting(setting1));
}
private:
- SettingsProviderHierachy* testling;
- DummySettingsProvider* bottom;
- DummySettingsProvider* top;
+ std::unique_ptr<SettingsProviderHierachy> testling;
+ std::unique_ptr<DummySettingsProvider> bottom;
+ std::unique_ptr<DummySettingsProvider> top;
SettingsProvider::Setting<int> setting1;
};
diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h
index 054cd31..9b943f0 100644
--- a/Swift/Controllers/UnitTest/MockChatWindow.h
+++ b/Swift/Controllers/UnitTest/MockChatWindow.h
@@ -14,7 +14,7 @@
namespace Swift {
class MockChatWindow : public ChatWindow {
public:
- MockChatWindow() : labelsEnabled_(false), impromptuMUCSupported_(false) {}
+ MockChatWindow() {}
virtual ~MockChatWindow();
virtual std::string addMessage(const ChatMessage& message, const std::string& senderName, bool senderIsSelf, std::shared_ptr<SecurityLabel> /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime& /*time*/) {
@@ -128,21 +128,21 @@ namespace Swift {
std::string name_;
ChatMessage lastAddedMessage_;
std::string lastAddedMessageSenderName_;
- bool lastAddedMessageSenderIsSelf_;
+ bool lastAddedMessageSenderIsSelf_ = false;
ChatMessage lastAddedAction_;
std::string lastAddedActionSenderName_;
- bool lastAddedActionSenderIsSelf_;
+ bool lastAddedActionSenderIsSelf_ = false;
ChatMessage lastAddedPresence_;
ChatMessage lastReplacedMessage_;
ChatMessage lastAddedSystemMessage_;
ChatMessage lastReplacedSystemMessage_;
- ChatMessage lastAddedErrorMessage_;
+ ChatMessage lastAddedErrorMessage_;
JID lastMUCInvitationJID_;
std::vector<SecurityLabelsCatalog::Item> labels_;
- bool labelsEnabled_;
- bool impromptuMUCSupported_;
+ bool labelsEnabled_ = false;
+ bool impromptuMUCSupported_ = false;
SecurityLabelsCatalog::Item label_;
- Roster* roster_;
+ Roster* roster_ = nullptr;
std::vector<std::pair<std::string, ReceiptState>> receiptChanges_;
};
}
diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h
index dbcef4b..c4a12e2 100644
--- a/Swift/QtUI/QtHighlightEditor.h
+++ b/Swift/QtUI/QtHighlightEditor.h
@@ -68,7 +68,7 @@ namespace Swift {
private:
Ui::QtHighlightEditor ui_;
QtSettingsProvider* settings_;
- HighlightManager* highlightManager_;
+ HighlightManager* highlightManager_ = nullptr;
QtSuggestingJIDInput* jid_;
int previousRow_;
};
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 91b21f6..c42d65d 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -98,7 +98,7 @@ namespace Swift {
QMenuBar* menuBar_;
QMenu* swiftMenu_;
QMenu* generalMenu_;
- QMenu* viewMenu_;
+ QMenu* viewMenu_ = nullptr;
QAction* toggleSoundsAction_;
QAction* toggleNotificationsAction_;
UIEventStream* uiEventStream_;
diff --git a/Swift/QtUI/Roster/QtTreeWidget.cpp b/Swift/QtUI/Roster/QtTreeWidget.cpp
index f04575d..1264a09 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.cpp
+++ b/Swift/QtUI/Roster/QtTreeWidget.cpp
@@ -33,9 +33,7 @@
namespace Swift {
-QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), tooltipShown_(false), messageTarget_(messageTarget) {
- eventStream_ = eventStream;
- settings_ = settings;
+QtTreeWidget::QtTreeWidget(UIEventStream* eventStream, SettingsProvider* settings, MessageTarget messageTarget, QWidget* parent) : QTreeView(parent), eventStream_(eventStream), settings_(settings), messageTarget_(messageTarget) {
model_ = new RosterModel(this, settings_->getSetting(QtUISettingConstants::USE_SCREENREADER));
setModel(model_);
delegate_ = new RosterDelegate(this, settings_->getSetting(QtUISettingConstants::COMPACT_ROSTER));
diff --git a/Swift/QtUI/Roster/QtTreeWidget.h b/Swift/QtUI/Roster/QtTreeWidget.h
index b22f6bb..331458a 100644
--- a/Swift/QtUI/Roster/QtTreeWidget.h
+++ b/Swift/QtUI/Roster/QtTreeWidget.h
@@ -68,13 +68,13 @@ class QtTreeWidget : public QTreeView {
private:
RosterModel* model_;
- Roster* roster_;
+ Roster* roster_ = nullptr;
RosterDelegate* delegate_;
- QtTreeWidgetItem* treeRoot_;
+ QtTreeWidgetItem* treeRoot_ = nullptr;
SettingsProvider* settings_;
- bool tooltipShown_;
+ bool tooltipShown_ = false;
MessageTarget messageTarget_;
- bool isOnline_;
+ bool isOnline_ = false;
};
}
diff --git a/Swift/QtUI/Trellis/QtDNDTabBar.h b/Swift/QtUI/Trellis/QtDNDTabBar.h
index e9b6771..6de04d5 100644
--- a/Swift/QtUI/Trellis/QtDNDTabBar.h
+++ b/Swift/QtUI/Trellis/QtDNDTabBar.h
@@ -36,9 +36,9 @@ class QtDNDTabBar : public QTabBar {
private:
int defaultTabHeight;
- int dragIndex;
+ int dragIndex = -1;
QString dragText;
- QWidget* dragWidget;
+ QWidget* dragWidget = nullptr;
};
}
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
index 3b3f74e..21aa7ca 100644
--- a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
+++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.h
@@ -76,7 +76,6 @@ namespace Swift {
QHBoxLayout* fillLayout;
ColorWidget* strokeColor;
ColorWidget* fillColor;
- QWidget* widget;
QPushButton* moveUpButton;
QPushButton* moveDownButton;
QSpinBox* widthBox;