From 4337b65f52e3ed761481cfafbd5c0aeb2e034d42 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Wed, 27 Nov 2019 15:47:37 +0100 Subject: [PATCH] rdm update every 2 seconds --- src/slic3r/GUI/GUI_App.cpp | 2 ++ src/slic3r/GUI/RemovableDriveManager.cpp | 15 ++++++++++++++- src/slic3r/GUI/RemovableDriveManager.hpp | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a74c6b0c0..35c11f021 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -46,6 +46,7 @@ #include "SysInfoDialog.hpp" #include "KBShortcutsDialog.hpp" #include "UpdateDialogs.hpp" +#include "RemovableDriveManager.hpp" #ifdef __WXMSW__ #include @@ -269,6 +270,7 @@ bool GUI_App::on_init_inner() this->obj_manipul()->update_if_dirty(); + RemovableDriveManager::getInstance().update(wxGetLocalTime()); // Preset updating & Configwizard are done after the above initializations, // and after MainFrame is created & shown. // The extra CallAfter() is needed because of Mac, where this is the only way diff --git a/src/slic3r/GUI/RemovableDriveManager.cpp b/src/slic3r/GUI/RemovableDriveManager.cpp index 2d1f4ba6f..235e1ccbe 100644 --- a/src/slic3r/GUI/RemovableDriveManager.cpp +++ b/src/slic3r/GUI/RemovableDriveManager.cpp @@ -23,6 +23,7 @@ namespace Slic3r { namespace GUI { std::vector RemovableDriveManager::m_current_drives; +long RemovableDriveManager::m_last_update = 0; #if _WIN32 void RemovableDriveManager::search_for_drives() @@ -215,8 +216,20 @@ bool RemovableDriveManager::is_path_on_removable_drive(const std::string &path) return false; } #endif -bool RemovableDriveManager::update() +bool RemovableDriveManager::update(long time) { + if(time != 0) //time = 0 is forced update + { + long diff = m_last_update - time; + if(diff <= -2) + { + m_last_update = time; + }else + { + return false; // return value shouldnt matter if update didnt run + } + } + std::cout << "RDM update " << m_last_update <<"\n"; search_for_drives(); return !m_current_drives.empty(); } diff --git a/src/slic3r/GUI/RemovableDriveManager.hpp b/src/slic3r/GUI/RemovableDriveManager.hpp index 3de9d72ce..c83b8033c 100644 --- a/src/slic3r/GUI/RemovableDriveManager.hpp +++ b/src/slic3r/GUI/RemovableDriveManager.hpp @@ -24,7 +24,7 @@ public: void operator=(RemovableDriveManager const&) = delete; //update() searches for removable devices, returns false if empty. - static bool update(); + static bool update(long time = 0); //time = 0 is forced update static bool is_drive_mounted(const std::string &path); static void eject_drive(const std::string &path); static std::string get_last_drive_path(); @@ -34,6 +34,7 @@ private: RemovableDriveManager(){} static void search_for_drives(); static std::vector m_current_drives; + static long m_last_update; #if _WIN32 #else static void search_path(const std::string &path, const dev_t &parentDevID);