[niepce] ui: make sure TreeModel iterators are valid



commit ddec1a4394812fa176123fc237781038e4bdda2d
Author: Hubert Figuière <hub figuiere net>
Date:   Wed Oct 10 23:21:35 2018 -0400

    ui: make sure TreeModel iterators are valid

 src/niepce/ui/workspacecontroller.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index 6287737..8b9ec0c 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -245,7 +245,7 @@ eng::library_id_t WorkspaceController::get_selected_folder_id()
 {
     auto selection = m_librarytree.get_selection();
     auto selected = selection->get_selected();
-    if (selected == m_librarytree.get_model()->children().end()) {
+    if (!selected) {
         return 0;
     }
     int type = (*selected)[m_librarycolumns.m_type];
@@ -260,6 +260,10 @@ void WorkspaceController::on_libtree_selection()
 {
     Glib::RefPtr<Gtk::TreeSelection> selection = m_librarytree.get_selection();
     auto selected = selection->get_selected();
+    if (!selected) {
+        DBG_OUT("Invalid iterator");
+        return;
+    }
     int type = (*selected)[m_librarycolumns.m_type];
     eng::library_id_t id = (*selected)[m_librarycolumns.m_id];
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]