verification of save path
This commit is contained in:
parent
bfc9dda1f6
commit
a029e689d8
@ -3597,12 +3597,18 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
else if (wxGetApp().get_mode() == comSimple)
|
else if (wxGetApp().get_mode() == comSimple)
|
||||||
show_action_buttons(false);
|
show_action_buttons(false);
|
||||||
else if(RemovableDriveManager::get_instance().get_is_writing())
|
if(RemovableDriveManager::get_instance().get_is_writing())
|
||||||
{
|
{
|
||||||
RemovableDriveManager::get_instance().set_is_writing(false);
|
RemovableDriveManager::get_instance().set_is_writing(false);
|
||||||
//RemovableDriveManager::get_instance().erase_callbacks();
|
RemovableDriveManager::get_instance().verify_last_save_path();
|
||||||
//RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, q));
|
if (!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||||
show_action_buttons(false);
|
{
|
||||||
|
|
||||||
|
RemovableDriveManager::get_instance().erase_callbacks();
|
||||||
|
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, q));
|
||||||
|
show_action_buttons(false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4734,13 +4740,15 @@ void Plater::export_gcode()
|
|||||||
std::string path = output_path.string();
|
std::string path = output_path.string();
|
||||||
RemovableDriveManager::get_instance().set_is_writing(true);
|
RemovableDriveManager::get_instance().set_is_writing(true);
|
||||||
RemovableDriveManager::get_instance().update(0, true);
|
RemovableDriveManager::get_instance().update(0, true);
|
||||||
RemovableDriveManager::get_instance().set_last_save_path(path);
|
|
||||||
p->export_gcode(std::move(output_path), PrintHostJob());
|
p->export_gcode(std::move(output_path), PrintHostJob());
|
||||||
|
RemovableDriveManager::get_instance().set_last_save_path(path);
|
||||||
|
/*
|
||||||
if(!RemovableDriveManager::get_instance().is_last_drive_removed())
|
if(!RemovableDriveManager::get_instance().is_last_drive_removed())
|
||||||
{
|
{
|
||||||
RemovableDriveManager::get_instance().erase_callbacks();
|
RemovableDriveManager::get_instance().erase_callbacks();
|
||||||
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, this));
|
RemovableDriveManager::get_instance().add_callback(std::bind(&Plater::drive_ejected_callback, this));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -402,6 +402,7 @@ RemovableDriveManager::RemovableDriveManager():
|
|||||||
m_last_update(0),
|
m_last_update(0),
|
||||||
m_last_save_path(""),
|
m_last_save_path(""),
|
||||||
m_last_save_name(""),
|
m_last_save_name(""),
|
||||||
|
m_last_save_path_verified(false),
|
||||||
m_is_writing(false),
|
m_is_writing(false),
|
||||||
m_did_eject(false)
|
m_did_eject(false)
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
@ -442,7 +443,6 @@ bool RemovableDriveManager::update(const long time,const bool check)
|
|||||||
return !m_current_drives.empty();
|
return !m_current_drives.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
bool RemovableDriveManager::is_drive_mounted(const std::string &path)
|
||||||
{
|
{
|
||||||
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
|
||||||
@ -461,12 +461,14 @@ std::string RemovableDriveManager::get_drive_path()
|
|||||||
reset_last_save_path();
|
reset_last_save_path();
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (m_last_save_path != "")
|
if (m_last_save_path_verified)
|
||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
return m_current_drives.back().path;
|
return m_current_drives.back().path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_last_save_path()
|
std::string RemovableDriveManager::get_last_save_path()
|
||||||
{
|
{
|
||||||
|
if (!m_last_save_path_verified)
|
||||||
|
return "";
|
||||||
return m_last_save_path;
|
return m_last_save_path;
|
||||||
}
|
}
|
||||||
std::string RemovableDriveManager::get_last_save_name()
|
std::string RemovableDriveManager::get_last_save_name()
|
||||||
@ -481,7 +483,7 @@ void RemovableDriveManager::check_and_notify()
|
|||||||
{
|
{
|
||||||
if(m_drives_count != m_current_drives.size())
|
if(m_drives_count != m_current_drives.size())
|
||||||
{
|
{
|
||||||
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && m_last_save_path != "" && !is_drive_mounted(m_last_save_path))
|
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && m_last_save_path_verified && !is_drive_mounted(m_last_save_path))
|
||||||
{
|
{
|
||||||
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -501,9 +503,14 @@ void RemovableDriveManager::erase_callbacks()
|
|||||||
}
|
}
|
||||||
void RemovableDriveManager::set_last_save_path(const std::string& path)
|
void RemovableDriveManager::set_last_save_path(const std::string& path)
|
||||||
{
|
{
|
||||||
std::string last_drive = get_drive_from_path(path);
|
m_last_save_path = path;
|
||||||
if(last_drive != "")
|
}
|
||||||
|
void RemovableDriveManager::verify_last_save_path()
|
||||||
|
{
|
||||||
|
std::string last_drive = get_drive_from_path(m_last_save_path);
|
||||||
|
if (last_drive != "")
|
||||||
{
|
{
|
||||||
|
m_last_save_path_verified = true;
|
||||||
m_last_save_path = last_drive;
|
m_last_save_path = last_drive;
|
||||||
m_last_save_name = get_drive_name(last_drive);
|
m_last_save_name = get_drive_name(last_drive);
|
||||||
}
|
}
|
||||||
@ -525,7 +532,7 @@ bool RemovableDriveManager::is_last_drive_removed()
|
|||||||
{
|
{
|
||||||
//std::cout<<"is last: "<<m_last_save_path;
|
//std::cout<<"is last: "<<m_last_save_path;
|
||||||
//m_drives_count = m_current_drives.size();
|
//m_drives_count = m_current_drives.size();
|
||||||
if(m_last_save_path == "")
|
if(!m_last_save_path_verified)
|
||||||
{
|
{
|
||||||
//std::cout<<"\n";
|
//std::cout<<"\n";
|
||||||
return true;
|
return true;
|
||||||
@ -542,6 +549,7 @@ bool RemovableDriveManager::is_last_drive_removed_with_update(const long time)
|
|||||||
}
|
}
|
||||||
void RemovableDriveManager::reset_last_save_path()
|
void RemovableDriveManager::reset_last_save_path()
|
||||||
{
|
{
|
||||||
|
m_last_save_path_verified = false;
|
||||||
m_last_save_path = "";
|
m_last_save_path = "";
|
||||||
m_last_save_name = "";
|
m_last_save_name = "";
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
void erase_callbacks();
|
void erase_callbacks();
|
||||||
// marks one of the eveices in vector as last used
|
// marks one of the eveices in vector as last used
|
||||||
void set_last_save_path(const std::string &path);
|
void set_last_save_path(const std::string &path);
|
||||||
|
void verify_last_save_path();
|
||||||
bool is_last_drive_removed();
|
bool is_last_drive_removed();
|
||||||
// param as update()
|
// param as update()
|
||||||
bool is_last_drive_removed_with_update(const long time = 0);
|
bool is_last_drive_removed_with_update(const long time = 0);
|
||||||
@ -70,10 +71,10 @@ private:
|
|||||||
size_t m_drives_count;
|
size_t m_drives_count;
|
||||||
long m_last_update;
|
long m_last_update;
|
||||||
std::string m_last_save_path;
|
std::string m_last_save_path;
|
||||||
|
bool m_last_save_path_verified;
|
||||||
std::string m_last_save_name;
|
std::string m_last_save_name;
|
||||||
bool m_is_writing;//on device
|
bool m_is_writing;//on device
|
||||||
bool m_did_eject;
|
bool m_did_eject;
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
//registers for notifications by creating invisible window
|
//registers for notifications by creating invisible window
|
||||||
void register_window();
|
void register_window();
|
||||||
|
Loading…
Reference in New Issue
Block a user