diff --git a/src/directories.cc b/src/directories.cc index 24d2323..79ec8b8 100644 --- a/src/directories.cc +++ b/src/directories.cc @@ -178,30 +178,24 @@ Directories::Directories() : Gtk::TreeView(), stop_update_thread(false) { while(!stop_update_thread) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); update_mutex.lock(); - if(update_paths.size()==0) { - for(auto it=last_write_times.begin();it!=last_write_times.end();) { - boost::system::error_code ec; - auto last_write_time=boost::filesystem::last_write_time(it->first, ec); - if(!ec) { - if(it->second.secondfirst); - } - it++; + for(auto it=last_write_times.begin();it!=last_write_times.end();) { + boost::system::error_code ec; + auto last_write_time=boost::filesystem::last_write_time(it->first, ec); + if(!ec) { + if(it->second.second(it->first); + dispatcher.post([this, path] { + update_mutex.lock(); + auto it=last_write_times.find(*path); + if(it!=last_write_times.end()) + add_path(*path, it->second.first); + update_mutex.unlock(); + }); } - else - it=last_write_times.erase(it); - } - if(update_paths.size()>0) { - dispatcher.post([this] { - update_mutex.lock(); - for(auto &path: update_paths) { - if(last_write_times.count(path)>0) - add_path(path, last_write_times.at(path).first); - } - update_paths.clear(); - update_mutex.unlock(); - }); + it++; } + else + it=last_write_times.erase(it); } update_mutex.unlock(); } @@ -320,7 +314,6 @@ void Directories::open(const boost::filesystem::path &dir_path) { tree_store->clear(); update_mutex.lock(); last_write_times.clear(); - update_paths.clear(); update_mutex.unlock(); diff --git a/src/directories.h b/src/directories.h index fda3a9f..f0b9202 100644 --- a/src/directories.h +++ b/src/directories.h @@ -67,7 +67,6 @@ private: std::thread update_thread; std::atomic stop_update_thread; Dispatcher dispatcher; - std::vector update_paths; Gtk::Menu menu; Gtk::MenuItem menu_item_rename;