diff options
| author | Richard Maudsley <richard.maudsley@isode.com> | 2014-07-22 09:18:06 (GMT) |
|---|---|---|
| committer | Richard Maudsley <richard.maudsley@isode.com> | 2014-07-22 09:20:54 (GMT) |
| commit | 9353d3c692e1cd37bdd15b8dbe75b92be5eaa1c0 (patch) | |
| tree | efb9c5532989fa71443f3ad79f4cbfd20d2ea8d7 | |
| parent | e3ff5f241bf6e41829d36502e75f585d9620737e (diff) | |
| download | swift-contrib-9353d3c692e1cd37bdd15b8dbe75b92be5eaa1c0.zip swift-contrib-9353d3c692e1cd37bdd15b8dbe75b92be5eaa1c0.tar.bz2 | |
Fix crash when performing blocking operations after fresh login.
Test-Information:
Sign out and sign in again then try blocking a user and confirm that a crash occurs in the BlockListController. After the patch repeat sign out and sign in and confirm that crash nolonger occurs.
Change-Id: I9812097fd34f188b2ebf1d8675e47c31fdafdc06
| -rw-r--r-- | Swift/Controllers/BlockListController.cpp | 3 | ||||
| -rw-r--r-- | Swift/Controllers/BlockListController.h | 1 | ||||
| -rw-r--r-- | Swift/Controllers/MainController.cpp | 2 |
3 files changed, 5 insertions, 1 deletions
diff --git a/Swift/Controllers/BlockListController.cpp b/Swift/Controllers/BlockListController.cpp index 6bdb513..d778883 100644 --- a/Swift/Controllers/BlockListController.cpp +++ b/Swift/Controllers/BlockListController.cpp @@ -1,65 +1,66 @@ /* * Copyright (c) 2013 Tobias Markmann * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include <Swift/Controllers/BlockListController.h> #include <boost/bind.hpp> #include <Swiften/Client/ClientBlockListManager.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/format.h> #include <Swift/Controllers/Intl.h> #include <Swift/Controllers/UIEvents/RequestChangeBlockStateUIEvent.h> #include <Swift/Controllers/UIEvents/RequestBlockListDialogUIEvent.h> #include <Swift/Controllers/XMPPEvents/ErrorEvent.h> #include <Swift/Controllers/UIInterfaces/BlockListEditorWidget.h> #include <Swift/Controllers/XMPPEvents/EventController.h> namespace Swift { -BlockListController::BlockListController(ClientBlockListManager* blockListManager, UIEventStream* uiEventStream, BlockListEditorWidgetFactory* blockListEditorWidgetFactory, EventController* eventController) : blockListManager_(blockListManager), blockListEditorWidgetFactory_(blockListEditorWidgetFactory), blockListEditorWidget_(0), eventController_(eventController), remainingRequests_(0) { +BlockListController::BlockListController(ClientBlockListManager* blockListManager, UIEventStream* uiEventStream, BlockListEditorWidgetFactory* blockListEditorWidgetFactory, EventController* eventController) : blockListManager_(blockListManager), blockListEditorWidgetFactory_(blockListEditorWidgetFactory), blockListEditorWidget_(0), eventController_(eventController), remainingRequests_(0), uiEventStream_(uiEventStream) { uiEventStream->onUIEvent.connect(boost::bind(&BlockListController::handleUIEvent, this, _1)); blockListManager_->getBlockList()->onItemAdded.connect(boost::bind(&BlockListController::handleBlockListChanged, this)); blockListManager_->getBlockList()->onItemRemoved.connect(boost::bind(&BlockListController::handleBlockListChanged, this)); } BlockListController::~BlockListController() { + uiEventStream_->onUIEvent.disconnect(boost::bind(&BlockListController::handleUIEvent, this, _1)); blockListManager_->getBlockList()->onItemAdded.disconnect(boost::bind(&BlockListController::handleBlockListChanged, this)); blockListManager_->getBlockList()->onItemRemoved.disconnect(boost::bind(&BlockListController::handleBlockListChanged, this)); } void BlockListController::blockListDifferences(const std::vector<JID> &newBlockList, std::vector<JID> &jidsToUnblock, std::vector<JID> &jidsToBlock) const { foreach (const JID& jid, blockListBeforeEdit) { if (std::find(newBlockList.begin(), newBlockList.end(), jid) == newBlockList.end()) { jidsToUnblock.push_back(jid); } } foreach (const JID& jid, newBlockList) { if (std::find(blockListBeforeEdit.begin(), blockListBeforeEdit.end(), jid) == blockListBeforeEdit.end()) { jidsToBlock.push_back(jid); } } } void BlockListController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { // handle UI dialog boost::shared_ptr<RequestBlockListDialogUIEvent> requestDialogEvent = boost::dynamic_pointer_cast<RequestBlockListDialogUIEvent>(rawEvent); if (requestDialogEvent != NULL) { if (blockListEditorWidget_ == NULL) { blockListEditorWidget_ = blockListEditorWidgetFactory_->createBlockListEditorWidget(); blockListEditorWidget_->onSetNewBlockList.connect(boost::bind(&BlockListController::handleSetNewBlockList, this, _1)); } blockListBeforeEdit = blockListManager_->getBlockList()->getItems(); blockListEditorWidget_->setCurrentBlockList(blockListBeforeEdit); blockListEditorWidget_->show(); return; } // handle block state change boost::shared_ptr<RequestChangeBlockStateUIEvent> changeStateEvent = boost::dynamic_pointer_cast<RequestChangeBlockStateUIEvent>(rawEvent); if (changeStateEvent != NULL) { diff --git a/Swift/Controllers/BlockListController.h b/Swift/Controllers/BlockListController.h index 4c9caad..99c143c 100644 --- a/Swift/Controllers/BlockListController.h +++ b/Swift/Controllers/BlockListController.h @@ -11,38 +11,39 @@ #include <Swiften/Queries/GenericRequest.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/BlockListEditorWidgetFactory.h> namespace Swift { class BlockPayload; class UnblockPayload; class ClientBlockListManager; class EventController; class BlockListController { public: BlockListController(ClientBlockListManager* blockListManager, UIEventStream* uiEventStream, BlockListEditorWidgetFactory* blockListEditorWidgetFactory, EventController* eventController); ~BlockListController(); private: void blockListDifferences(const std::vector<JID> &newBlockList, std::vector<JID>& jidsToUnblock, std::vector<JID>& jidsToBlock) const; void handleUIEvent(boost::shared_ptr<UIEvent> event); void handleBlockResponse(GenericRequest<BlockPayload>::ref, boost::shared_ptr<BlockPayload>, ErrorPayload::ref error, const std::vector<JID>& jids, bool originEditor); void handleUnblockResponse(GenericRequest<UnblockPayload>::ref, boost::shared_ptr<UnblockPayload>, ErrorPayload::ref error, const std::vector<JID>& jids, bool originEditor); void handleSetNewBlockList(const std::vector<JID>& newBlockList); void handleBlockListChanged(); private: ClientBlockListManager* blockListManager_; BlockListEditorWidgetFactory* blockListEditorWidgetFactory_; BlockListEditorWidget* blockListEditorWidget_; EventController* eventController_; std::vector<JID> blockListBeforeEdit; int remainingRequests_; + UIEventStream* uiEventStream_; }; } diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index a16cbe7..95d8134 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -230,70 +230,72 @@ MainController::~MainController() { delete xmppURIController_; delete soundEventController_; delete systemTrayController_; delete eventController_; delete notifier_; delete uiEventStream_; } void MainController::purgeCachedCredentials() { safeClear(password_); } void MainController::resetClient() { purgeCachedCredentials(); resetCurrentError(); resetPendingReconnects(); vCardPhotoHash_.clear(); delete contactEditController_; contactEditController_ = NULL; delete profileController_; profileController_ = NULL; delete showProfileController_; showProfileController_ = NULL; delete eventWindowController_; eventWindowController_ = NULL; delete chatsManager_; chatsManager_ = NULL; #ifdef SWIFT_EXPERIMENTAL_HISTORY delete historyViewController_; historyViewController_ = NULL; delete historyController_; historyController_ = NULL; #endif delete ftOverview_; ftOverview_ = NULL; + delete blockListController_; + blockListController_ = NULL; delete rosterController_; rosterController_ = NULL; delete eventNotifier_; eventNotifier_ = NULL; delete presenceNotifier_; presenceNotifier_ = NULL; delete certificateStorage_; certificateStorage_ = NULL; delete storages_; storages_ = NULL; delete statusTracker_; statusTracker_ = NULL; delete profileSettings_; profileSettings_ = NULL; delete userSearchControllerChat_; userSearchControllerChat_ = NULL; delete userSearchControllerAdd_; userSearchControllerAdd_ = NULL; delete userSearchControllerInvite_; userSearchControllerInvite_ = NULL; delete contactSuggesterWithoutRoster_; contactSuggesterWithoutRoster_ = NULL; delete contactSuggesterWithRoster_; contactSuggesterWithRoster_ = NULL; delete contactsFromRosterProvider_; contactsFromRosterProvider_ = NULL; delete adHocManager_; adHocManager_ = NULL; delete whiteboardManager_; whiteboardManager_ = NULL; clientInitialized_ = false; } void MainController::handleSettingChanged(const std::string& settingPath) { if (settingPath == SettingConstants::SHOW_NOTIFICATIONS.getKey()) { |
Swift