[gnote] Use raw/unique pointers for SyncServer
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Use raw/unique pointers for SyncServer
- Date: Thu, 26 Dec 2019 19:43:32 +0000 (UTC)
commit 8a8a3fd132fc5953f28fb83a248b289166d15a7b
Author: Aurimas Černius <aurisc4 gmail com>
Date: Thu Dec 26 21:37:23 2019 +0200
Use raw/unique pointers for SyncServer
src/synchronization/filesystemsyncserver.cpp | 5 ++---
src/synchronization/filesystemsyncserver.hpp | 2 +-
src/synchronization/fusesyncserviceaddin.cpp | 4 ++--
src/synchronization/fusesyncserviceaddin.hpp | 2 +-
src/synchronization/isyncmanager.hpp | 2 --
src/synchronization/syncmanager.cpp | 18 +++++++++---------
src/synchronization/syncmanager.hpp | 4 ++--
src/synchronization/syncserviceaddin.hpp | 2 +-
8 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/src/synchronization/filesystemsyncserver.cpp b/src/synchronization/filesystemsyncserver.cpp
index b60ee1b7..cf67e7ba 100644
--- a/src/synchronization/filesystemsyncserver.cpp
+++ b/src/synchronization/filesystemsyncserver.cpp
@@ -53,10 +53,9 @@ int str_to_int(const Glib::ustring & s)
namespace gnote {
namespace sync {
-SyncServer::Ptr FileSystemSyncServer::create(const Glib::RefPtr<Gio::File> & path, Preferences & prefs)
+SyncServer *FileSystemSyncServer::create(const Glib::RefPtr<Gio::File> & path, Preferences & prefs)
{
- return std::make_shared<FileSystemSyncServer>(path,
- prefs.get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_CLIENT_ID));
+ return new FileSystemSyncServer(path,
prefs.get_schema_settings(Preferences::SCHEMA_SYNC)->get_string(Preferences::SYNC_CLIENT_ID));
}
diff --git a/src/synchronization/filesystemsyncserver.hpp b/src/synchronization/filesystemsyncserver.hpp
index 752d39ca..ca33b6fa 100644
--- a/src/synchronization/filesystemsyncserver.hpp
+++ b/src/synchronization/filesystemsyncserver.hpp
@@ -34,7 +34,7 @@ class FileSystemSyncServer
: public SyncServer
{
public:
- static SyncServer::Ptr create(const Glib::RefPtr<Gio::File> & path, Preferences & prefs);
+ static SyncServer *create(const Glib::RefPtr<Gio::File> & path, Preferences & prefs);
FileSystemSyncServer(const Glib::RefPtr<Gio::File> & path, const Glib::ustring & client_id);
virtual bool begin_sync_transaction() override;
virtual bool commit_sync_transaction() override;
diff --git a/src/synchronization/fusesyncserviceaddin.cpp b/src/synchronization/fusesyncserviceaddin.cpp
index 57d07a22..3940f176 100644
--- a/src/synchronization/fusesyncserviceaddin.cpp
+++ b/src/synchronization/fusesyncserviceaddin.cpp
@@ -69,9 +69,9 @@ void FuseSyncServiceAddin::initialize()
m_enabled = true;
}
-SyncServer::Ptr FuseSyncServiceAddin::create_sync_server()
+SyncServer *FuseSyncServiceAddin::create_sync_server()
{
- SyncServer::Ptr server;
+ SyncServer *server;
// Cancel timer
m_unmount_timeout.cancel();
diff --git a/src/synchronization/fusesyncserviceaddin.hpp b/src/synchronization/fusesyncserviceaddin.hpp
index 47589cdf..84251f70 100644
--- a/src/synchronization/fusesyncserviceaddin.hpp
+++ b/src/synchronization/fusesyncserviceaddin.hpp
@@ -40,7 +40,7 @@ public:
virtual void shutdown() override;
virtual bool initialized() override;
virtual void initialize() override;
- virtual SyncServer::Ptr create_sync_server() override;
+ virtual SyncServer *create_sync_server() override;
virtual void post_sync_cleanup() override;
virtual bool is_supported() override;
virtual bool save_configuration(const sigc::slot<void, bool, Glib::ustring> & on_saved) override;
diff --git a/src/synchronization/isyncmanager.hpp b/src/synchronization/isyncmanager.hpp
index 31072393..09d8fd2a 100644
--- a/src/synchronization/isyncmanager.hpp
+++ b/src/synchronization/isyncmanager.hpp
@@ -74,8 +74,6 @@ public:
class SyncServer
{
public:
- typedef std::shared_ptr<SyncServer> Ptr;
-
virtual ~SyncServer();
virtual bool begin_sync_transaction() = 0;
diff --git a/src/synchronization/syncmanager.cpp b/src/synchronization/syncmanager.cpp
index 31255465..37e60353 100644
--- a/src/synchronization/syncmanager.cpp
+++ b/src/synchronization/syncmanager.cpp
@@ -143,7 +143,7 @@ namespace sync {
}
}
} f(*this);
- SyncServer::Ptr server;
+ std::unique_ptr<SyncServer> server;
try {
f.addin = get_configured_sync_service();
if(f.addin == NULL) {
@@ -158,7 +158,7 @@ namespace sync {
set_state(CONNECTING);
try {
- server = f.addin->create_sync_server();
+ server.reset(f.addin->create_sync_server());
if(server == NULL)
throw std::logic_error("addin.CreateSyncServer () returned null");
}
@@ -280,7 +280,7 @@ namespace sync {
// delegate to run in the main gtk thread.
// To be consistent, any exceptions in the delgate will be caught
// and then rethrown in the synchronization thread.
- delete_notes_in_main_thread(server);
+ delete_notes_in_main_thread(*server);
// TODO: Add following updates to syncDialog treeview
@@ -465,9 +465,9 @@ namespace sync {
SyncServiceAddin *addin = get_configured_sync_service();
if(addin) {
// TODO: block sync while checking
- SyncServer::Ptr server;
+ std::unique_ptr<SyncServer> server;
try {
- server = SyncServer::Ptr(addin->create_sync_server());
+ server.reset(addin->create_sync_server());
if(server == 0) {
throw std::logic_error("addin->create_sync_server() returned null");
}
@@ -671,20 +671,20 @@ namespace sync {
}
- void SyncManager::delete_notes_in_main_thread(const SyncServer::Ptr & server)
+ void SyncManager::delete_notes_in_main_thread(SyncServer & server)
{
- utils::main_context_call([this, server]() { delete_notes(server); });
+ utils::main_context_call([this, &server]() { delete_notes(server); });
}
- void SyncManager::delete_notes(const SyncServer::Ptr & server)
+ void SyncManager::delete_notes(SyncServer & server)
{
try {
// Make list of all local notes
auto localNotes = note_mgr().get_notes();
// Get all notes currently on server
- auto serverNotes = server->get_all_note_uuids();
+ auto serverNotes = server.get_all_note_uuids();
// Delete notes locally that have been deleted on the server
for(const NoteBase::Ptr & iter : localNotes) {
diff --git a/src/synchronization/syncmanager.hpp b/src/synchronization/syncmanager.hpp
index 90f2b6e9..b1a5c12f 100644
--- a/src/synchronization/syncmanager.hpp
+++ b/src/synchronization/syncmanager.hpp
@@ -62,8 +62,8 @@ namespace sync {
virtual void connect_system_signals();
virtual SyncServiceAddin *get_sync_service_addin(const Glib::ustring & sync_service_id);
virtual SyncServiceAddin *get_configured_sync_service();
- virtual void delete_notes_in_main_thread(const SyncServer::Ptr & server);
- void delete_notes(const SyncServer::Ptr & server);
+ virtual void delete_notes_in_main_thread(SyncServer & server);
+ void delete_notes(SyncServer & server);
virtual void note_save(const Note::Ptr & note);
virtual void create_note_in_main_thread(const NoteUpdate & noteUpdate);
virtual void update_note_in_main_thread(const Note::Ptr & existingNote, const NoteUpdate & noteUpdate);
diff --git a/src/synchronization/syncserviceaddin.hpp b/src/synchronization/syncserviceaddin.hpp
index 2e7e0bbd..e0202e55 100644
--- a/src/synchronization/syncserviceaddin.hpp
+++ b/src/synchronization/syncserviceaddin.hpp
@@ -54,7 +54,7 @@ namespace sync {
{
return *m_sync_manager;
}
- virtual SyncServer::Ptr create_sync_server() = 0;
+ virtual SyncServer *create_sync_server() = 0;
virtual void post_sync_cleanup() = 0;
virtual Gtk::Widget *create_preferences_control(EventHandler requiredPrefChanged) = 0;
virtual bool save_configuration(const sigc::slot<void, bool, Glib::ustring> & on_saved) = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]