From bcfc333fb108f87e62f961f403ede08cebc124a5 Mon Sep 17 00:00:00 2001
From: Slic3rPE <slic3r@Slic3rPEs-MacBook-Pro.local>
Date: Wed, 11 Dec 2019 11:00:47 +0100
Subject: [PATCH] macos better wrapper

---
 src/slic3r/GUI/RemovableDriveManager.cpp  | 12 ++++++-
 src/slic3r/GUI/RemovableDriveManager.hpp  | 40 ++++++++++++-----------
 src/slic3r/GUI/RemovableDriveManagerMM.mm |  4 ---
 3 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp
index c5dca1bd5..164b6e38a 100644
--- a/src/slic3r/GUI/RemovableDriveManager.cpp
+++ b/src/slic3r/GUI/RemovableDriveManager.cpp
@@ -391,13 +391,23 @@ std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
 	return "";
 }
 #endif
+
+RemovableDriveManager::RemovableDriveManager():
+    m_drives_count(0),
+    m_last_update(0),
+    m_last_save_path(""),
+#if __APPLE__
+    m_rdmmm(new RDMMMWrapper())
+#endif
+{}
+
 void RemovableDriveManager::init()
 {
 	add_callback([](void) { RemovableDriveManager::get_instance().print(); });
 #if _WIN32
 	register_window();
 #elif __APPLE__
-    register_window();
+    m_rdmmm->register_window();
 #endif
 	update();
 }
diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp
index cbf6f53aa..a5027a5ad 100644
--- a/src/slic3r/GUI/RemovableDriveManager.hpp
+++ b/src/slic3r/GUI/RemovableDriveManager.hpp
@@ -6,9 +6,9 @@
 
 namespace Slic3r {
 namespace GUI {
-class RDMMMWrapper;
 #if __APPLE__
-
+class RDMMMWrapper;
+#endif
     
 struct DriveData
 {
@@ -18,6 +18,9 @@ struct DriveData
 };
 class RemovableDriveManager
 {
+#if __APPLE__
+friend class RDMMMWrapper;
+#endif
 public:
 	static RemovableDriveManager& get_instance()
 	{
@@ -42,12 +45,9 @@ public:
 	bool is_last_drive_removed_with_update(const long time = 0); // param as update()
 	void reset_last_save_path();
 	void print();
+
 private:
-#if __APPLE__
-	RemovableDriveManager():m_drives_count(0),m_last_update(0),m_last_save_path(""),m_rdmmm(new RemovableDriveManagerMM()){}
-#else
-	RemovableDriveManager() : m_drives_count(0), m_last_update(0), m_last_save_path(""){}
-#endif
+    RemovableDriveManager();
 	void search_for_drives();
 	void check_and_notify();
 	std::string get_drive_from_path(const std::string& path);//returns drive path (same as path in DriveData) if exists otherwise empty string ""
@@ -64,21 +64,23 @@ private:
 	RDMMMWrapper * m_rdmmm;
  #endif
     void search_path(const std::string &path, const std::string &parent_path);
-    void inspect_file(const std::string &path, const std::string &parent_path);
     bool compare_filesystem_id(const std::string &path_a, const std::string &path_b);
+    void inspect_file(const std::string &path, const std::string &parent_path);
 #endif
 };
-    class RDMMMWrapper
-    {
-    public:
-        RDMMMWrapper();
-        ~RDMMMWrapper();
-        void register_window();
-        void list_devices();
-    private:
-        void *m_imp;
-        friend void RemovableDriveManager::inspect_file(const std::string &path, const std::string &parent_path);
-    };
+    
+#if __APPLE__
+class RDMMMWrapper
+{
+public:
+    RDMMMWrapper();
+    ~RDMMMWrapper();
+    void register_window();
+    void list_devices();
+protected:
+    void *m_imp;
+    //friend void RemovableDriveManager::inspect_file(const std::string &path, const std::string &parent_path);
+};
 #endif
 }}
 #endif
diff --git a/src/slic3r/GUI/RemovableDriveManagerMM.mm b/src/slic3r/GUI/RemovableDriveManagerMM.mm
index 269a2255b..d32b7b278 100644
--- a/src/slic3r/GUI/RemovableDriveManagerMM.mm
+++ b/src/slic3r/GUI/RemovableDriveManagerMM.mm
@@ -27,10 +27,6 @@
 -(NSArray*) list_dev
 {
     NSArray* devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
-    for (NSString* volumePath in devices)
-    {
-        NSLog(@"%@", volumePath);
-	}
 	return devices;
     
 }