summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-22 19:58:45 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-22 19:58:45 (GMT)
commitfd7d3f4f994159a4990f3a0029597d4c14f727a9 (patch)
tree56286c8258cae942ae641235167b6dfdb512483a /Swift
parent7cac59f3ec12e3440341bb561ab3c8e6c3fe80e0 (diff)
downloadswift-contrib-fd7d3f4f994159a4990f3a0029597d4c14f727a9.zip
swift-contrib-fd7d3f4f994159a4990f3a0029597d4c14f727a9.tar.bz2
Fixed memory leaks and segfault on signout.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/EventWindowController.cpp5
-rw-r--r--Swift/Controllers/MainController.cpp2
-rw-r--r--Swift/Controllers/RosterController.cpp4
-rw-r--r--Swift/Controllers/UIInterfaces/EventWindow.h9
-rw-r--r--Swift/Controllers/UIInterfaces/MainWindow.h14
-rw-r--r--Swift/QtUI/EventViewer/QtEventWindow.cpp2
-rw-r--r--Swift/QtUI/QtMainWindow.cpp2
7 files changed, 27 insertions, 11 deletions
diff --git a/Swift/Controllers/EventWindowController.cpp b/Swift/Controllers/EventWindowController.cpp
index a8c8f11..18c37f4 100644
--- a/Swift/Controllers/EventWindowController.cpp
+++ b/Swift/Controllers/EventWindowController.cpp
@@ -18,8 +18,9 @@ EventWindowController::EventWindowController(EventController* eventController, E
}
EventWindowController::~EventWindowController() {
- // Don't delete this, since Qt owns it
- //delete window_;
+ if (window_->canDelete()) {
+ delete window_;
+ }
}
void EventWindowController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) {
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index 837e576..7cf68a1 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -494,8 +494,6 @@ void MainController::handleCancelLoginRequest() {
void MainController::signOut() {
logout();
loginWindow_->loggedOut();
- delete rosterController_;
- rosterController_ = NULL;
resetClient();
}
diff --git a/Swift/Controllers/RosterController.cpp b/Swift/Controllers/RosterController.cpp
index defd1c6..580e12b 100644
--- a/Swift/Controllers/RosterController.cpp
+++ b/Swift/Controllers/RosterController.cpp
@@ -67,7 +67,9 @@ RosterController::RosterController(const JID& jid, XMPPRoster* xmppRoster, Avata
RosterController::~RosterController() {
delete offlineFilter_;
delete expandiness_;
- delete mainWindow_;
+ if (mainWindow_->canDelete()) {
+ delete mainWindow_;
+ }
delete roster_;
}
diff --git a/Swift/Controllers/UIInterfaces/EventWindow.h b/Swift/Controllers/UIInterfaces/EventWindow.h
index 0999e0e..e756655 100644
--- a/Swift/Controllers/UIInterfaces/EventWindow.h
+++ b/Swift/Controllers/UIInterfaces/EventWindow.h
@@ -12,8 +12,17 @@
namespace Swift {
class EventWindow {
public:
+ EventWindow(bool candelete = true) : canDelete_(candelete) {}
+
+ bool canDelete() const {
+ return canDelete_;
+ }
+
virtual ~EventWindow() {};
virtual void addEvent(boost::shared_ptr<StanzaEvent> event, bool active) = 0;
virtual void removeEvent(boost::shared_ptr<StanzaEvent> event) = 0;
+
+ private:
+ bool canDelete_;
};
}
diff --git a/Swift/Controllers/UIInterfaces/MainWindow.h b/Swift/Controllers/UIInterfaces/MainWindow.h
index 5d0c14e..570c919 100644
--- a/Swift/Controllers/UIInterfaces/MainWindow.h
+++ b/Swift/Controllers/UIInterfaces/MainWindow.h
@@ -4,8 +4,7 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#ifndef SWIFTEN_MainWindow_H
-#define SWIFTEN_MainWindow_H
+#pragma once
#include "Swiften/Base/String.h"
#include "Swiften/JID/JID.h"
@@ -19,7 +18,13 @@ namespace Swift {
class MainWindow {
public:
+ MainWindow(bool candelete = true) : canDelete_(candelete) {}
virtual ~MainWindow() {};
+
+ bool canDelete() const {
+ return canDelete_;
+ }
+
virtual void setMyName(const String& name) = 0;
virtual void setMyAvatarPath(const String& path) = 0;
virtual void setMyStatusText(const String& status) = 0;
@@ -29,7 +34,8 @@ namespace Swift {
boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest;
boost::signal<void (bool)> onShowOfflineToggled;
boost::signal<void ()> onSignOutRequest;
+
+ private:
+ bool canDelete_;
};
}
-#endif
-
diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp
index 5200740..6540d5f 100644
--- a/Swift/QtUI/EventViewer/QtEventWindow.cpp
+++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp
@@ -23,7 +23,7 @@
namespace Swift {
-QtEventWindow::QtEventWindow(UIEventStream* eventStream) {
+QtEventWindow::QtEventWindow(UIEventStream* eventStream) : EventWindow(false) {
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index f669e95..4b3fa9e 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -29,7 +29,7 @@
namespace Swift {
-QtMainWindow::QtMainWindow(UIEventStream* uiEventStream) : QWidget() {
+QtMainWindow::QtMainWindow(UIEventStream* uiEventStream) : QWidget(), MainWindow(false) {
uiEventStream_ = uiEventStream;
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);