From 8cb29a1617e2be8d34530e6fb09f1bdff644623c Mon Sep 17 00:00:00 2001 From: cnjinhao Date: Mon, 11 Sep 2017 14:42:20 +0800 Subject: [PATCH] fix issue that filebox incorrectly loads folder tree on Linux --- source/gui/filebox.cpp | 14 +++++++------- source/gui/widgets/treebox.cpp | 17 ++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index c3fa7fb0..89382828 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -435,20 +435,20 @@ namespace nana nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem"); nodes_.filesystem.value(kind::filesystem); - std::vector paths; - paths.emplace_back(fs_ext::path_user().native()); - paths.emplace_back("/"); + std::vector> paths; + paths.emplace_back(fs_ext::path_user().native(), nodes_.home); + paths.emplace_back("/", nodes_.filesystem); fs::directory_iterator end; for (auto & p : paths) { - for (fs::directory_iterator i(p); i != end; ++i) + for (fs::directory_iterator i{p.first}; i != end; ++i) { auto name = i->path().filename().native(); if (!is_directory(i->status()) || (name.size() && name[0] == '.')) continue; - item_proxy node = tree_.insert(nodes_.filesystem, name, name); + item_proxy node = tree_.insert(p.second, name, name); if (false == node.empty()) { node.value(kind::filesystem); @@ -831,8 +831,8 @@ namespace nana { for(fs::directory_iterator u(i->path()); u != end; ++u) { - auto uname = i->path().filename().native(); - if ((!is_directory(*i)) || (uname.size() && uname[0] == '.')) + auto uname = u->path().filename().native(); + if ((!is_directory(*u)) || (uname.size() && uname[0] == '.')) continue; child.append(uname, uname, kind::filesystem); diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 906bd969..88468861 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -1825,7 +1825,6 @@ namespace nana item_locator nl(impl_, xpos, arg.pos.x, arg.pos.y); impl_->attr.tree_cont.for_each(shape.first, nl); - bool has_redraw = false; auto & node_state = impl_->node_state; node_state.pressed_node = nl.node(); @@ -1834,21 +1833,17 @@ namespace nana { if(impl_->set_expanded(node_state.pressed_node, !node_state.pressed_node->value.second.expanded)) impl_->make_adjust(node_state.pressed_node, 0); - - has_redraw = true; //btw, don't select the node } - - if ((!has_redraw) && (node_state.selected != node_state.pressed_node)) + else if (node_state.selected != node_state.pressed_node) { impl_->set_selected(node_state.pressed_node); - has_redraw = true; } + else + return; - if(has_redraw) - { - impl_->draw(true); - API::dev::lazy_refresh(); - } + + impl_->draw(true); + API::dev::lazy_refresh(); } void trigger::mouse_up(graph_reference, const arg_mouse& arg)