[gnote] Do not use shared_ptr for SyncClient
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Do not use shared_ptr for SyncClient
- Date: Thu, 26 Dec 2019 19:43:27 +0000 (UTC)
commit a4370e1acd5ff155e4fcc2d935c843e9d1cc67dd
Author: Aurimas Černius <aurisc4 gmail com>
Date: Thu Dec 26 21:16:31 2019 +0200
Do not use shared_ptr for SyncClient
src/synchronization/gnotesyncclient.cpp | 6 +++---
src/synchronization/gnotesyncclient.hpp | 4 ++--
src/synchronization/isyncmanager.hpp | 2 --
src/synchronization/syncmanager.cpp | 2 +-
src/synchronization/syncmanager.hpp | 2 +-
src/test/testsyncmanager.cpp | 10 +++++-----
src/test/testsyncmanager.hpp | 2 +-
src/test/unit/syncmanagerutests.cpp | 12 ++++++------
8 files changed, 19 insertions(+), 21 deletions(-)
---
diff --git a/src/synchronization/gnotesyncclient.cpp b/src/synchronization/gnotesyncclient.cpp
index e71a45dd..2b9318af 100644
--- a/src/synchronization/gnotesyncclient.cpp
+++ b/src/synchronization/gnotesyncclient.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012-2014,2017 Aurimas Cernius
+ * Copyright (C) 2012-2014,2017,2019 Aurimas Cernius
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,11 +39,11 @@ namespace sync {
const char * GnoteSyncClient::LOCAL_MANIFEST_FILE_NAME = "manifest.xml";
- SyncClient::Ptr GnoteSyncClient::create(NoteManagerBase & manager)
+ SyncClient *GnoteSyncClient::create(NoteManagerBase & manager)
{
GnoteSyncClient *ptr = new GnoteSyncClient;
ptr->init(manager);
- return SyncClient::Ptr(ptr);
+ return ptr;
}
GnoteSyncClient::GnoteSyncClient()
diff --git a/src/synchronization/gnotesyncclient.hpp b/src/synchronization/gnotesyncclient.hpp
index 6e1bddc4..26059340 100644
--- a/src/synchronization/gnotesyncclient.hpp
+++ b/src/synchronization/gnotesyncclient.hpp
@@ -31,7 +31,8 @@ namespace sync {
: public SyncClient
{
public:
- static SyncClient::Ptr create(NoteManagerBase &);
+ static SyncClient *create(NoteManagerBase &);
+ GnoteSyncClient();
virtual sharp::DateTime last_sync_date() override
{
@@ -56,7 +57,6 @@ namespace sync {
}
virtual void associated_server_id(const Glib::ustring &) override;
protected:
- GnoteSyncClient();
void init(NoteManagerBase &);
void parse(const Glib::ustring & manifest_path);
diff --git a/src/synchronization/isyncmanager.hpp b/src/synchronization/isyncmanager.hpp
index 1dc3e99b..31072393 100644
--- a/src/synchronization/isyncmanager.hpp
+++ b/src/synchronization/isyncmanager.hpp
@@ -44,8 +44,6 @@ public:
class SyncClient
{
public:
- typedef std::shared_ptr<SyncClient> Ptr;
-
virtual ~SyncClient();
virtual int last_synchronized_revision() = 0;
diff --git a/src/synchronization/syncmanager.cpp b/src/synchronization/syncmanager.cpp
index 79d17803..31255465 100644
--- a/src/synchronization/syncmanager.cpp
+++ b/src/synchronization/syncmanager.cpp
@@ -52,7 +52,7 @@ namespace sync {
void SyncManager::init()
{
- m_client = GnoteSyncClient::create(m_note_manager);
+ m_client.reset(GnoteSyncClient::create(m_note_manager));
// Add a "Synchronize Notes" to Gnote's Application Menu
IActionManager & am(m_gnote.action_manager());
am.add_app_action("sync-notes");
diff --git a/src/synchronization/syncmanager.hpp b/src/synchronization/syncmanager.hpp
index db00e9fe..90f2b6e9 100644
--- a/src/synchronization/syncmanager.hpp
+++ b/src/synchronization/syncmanager.hpp
@@ -72,7 +72,7 @@ namespace sync {
void update_note(const Note::Ptr & existingNote, const NoteUpdate & noteUpdate);
void delete_note(const Note::Ptr & existingNote);
- SyncClient::Ptr m_client;
+ std::unique_ptr<SyncClient> m_client;
SyncUI::Ptr m_sync_ui;
private:
void handle_note_saved_or_deleted(const NoteBase::Ptr & note);
diff --git a/src/test/testsyncmanager.cpp b/src/test/testsyncmanager.cpp
index 4e0c8f2f..5d34f53b 100644
--- a/src/test/testsyncmanager.cpp
+++ b/src/test/testsyncmanager.cpp
@@ -27,14 +27,14 @@ SyncManager::SyncManager(gnote::IGnote & g, gnote::NoteManagerBase & manager, co
: gnote::sync::SyncManager(g, manager)
, m_sync_path(sync_path)
{
- m_client = gnote::sync::SyncClient::Ptr(new test::SyncClient(manager));
+ m_client.reset(new test::SyncClient(manager));
}
-test::SyncClient::Ptr SyncManager::get_client(const Glib::ustring & manifest)
+test::SyncClient & SyncManager::get_client(const Glib::ustring & manifest)
{
- SyncClient::Ptr client = std::dynamic_pointer_cast<SyncClient>(m_client);
- client->set_manifest_path(manifest);
- client->reparse();
+ SyncClient & client = dynamic_cast<SyncClient&>(*m_client);
+ client.set_manifest_path(manifest);
+ client.reparse();
return client;
}
diff --git a/src/test/testsyncmanager.hpp b/src/test/testsyncmanager.hpp
index 88665941..6bfa622a 100644
--- a/src/test/testsyncmanager.hpp
+++ b/src/test/testsyncmanager.hpp
@@ -40,7 +40,7 @@ public:
virtual gnote::sync::SyncServiceAddin *get_configured_sync_service() override;
virtual void delete_notes_in_main_thread(const gnote::sync::SyncServer::Ptr & server) override;
virtual void note_save(const gnote::Note::Ptr & note) override;
- test::SyncClient::Ptr get_client(const Glib::ustring & manifest);
+ test::SyncClient & get_client(const Glib::ustring & manifest);
protected:
virtual void create_note_in_main_thread(const gnote::sync::NoteUpdate & noteUpdate) override;
virtual void update_note_in_main_thread(const gnote::Note::Ptr & existingNote, const
gnote::sync::NoteUpdate & noteUpdate) override;
diff --git a/src/test/unit/syncmanagerutests.cpp b/src/test/unit/syncmanagerutests.cpp
index 05f50397..4e3c420c 100644
--- a/src/test/unit/syncmanagerutests.cpp
+++ b/src/test/unit/syncmanagerutests.cpp
@@ -123,7 +123,7 @@ SUITE(SyncManagerTests)
};
#define FIRST_SYNC(ignote, sync_manager, note_manager, manifest, client, ui) \
- test::SyncClient::Ptr client =
std::dynamic_pointer_cast<test::SyncClient>(sync_manager->get_client(manifest)); \
+ test::SyncClient & client = dynamic_cast<test::SyncClient&>(sync_manager->get_client(manifest)); \
gnote::sync::SilentUI::Ptr ui = gnote::sync::SilentUI::create(ignote, *note_manager); \
sync_manager->perform_synchronization(ui);
@@ -204,7 +204,7 @@ SUITE(SyncManagerTests)
// update note and sync again
UPDATE_NOTE(manager1, "note2", "note4", "updated content");
- sync_client1->reparse();
+ sync_client1.reparse();
sync_manager1->perform_synchronization(sync_ui1);
// check sync dir contents
@@ -228,7 +228,7 @@ SUITE(SyncManagerTests)
// update note and sync again
UPDATE_NOTE(manager1, "note2", "note4", "updated content");
- sync_client1->reparse();
+ sync_client1.reparse();
sync_manager1->perform_synchronization(sync_ui1);
// download updates
@@ -265,12 +265,12 @@ SUITE(SyncManagerTests)
// update note and sync again
UPDATE_NOTE(manager1, "note2", "note4", "updated content");
- sync_client1->reparse();
+ sync_client1.reparse();
sync_manager1->perform_synchronization(sync_ui1);
// update other client and sync
UPDATE_NOTE(manager2, "note2", "note5", "content updated");
- sync_client2->reparse();
+ sync_client2.reparse();
sync_manager2->perform_synchronization(sync_ui1);
// sync client1 again
@@ -295,7 +295,7 @@ SUITE(SyncManagerTests)
// update note and sync again
UPDATE_NOTE(manager1, "note2", "note4", "updated content");
- sync_client1->reparse();
+ sync_client1.reparse();
sync_manager1->perform_synchronization(sync_ui1);
get_notes_in_dir(notesdir1);
REQUIRE CHECK_EQUAL(3, files.size()); // 2 downloaded notes + template
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]