From be8f464bf8f7e709a482c5f774f411b330aa4952 Mon Sep 17 00:00:00 2001
From: tamasmeszaros <meszaros.q@gmail.com>
Date: Mon, 27 Jan 2020 14:31:41 +0100
Subject: [PATCH] Remove some gtk warnings on application start.

---
 src/slic3r/GUI/GUI_ObjectList.cpp | 6 +++---
 src/slic3r/GUI/GUI_ObjectList.hpp | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp
index b4f20524e..5ae2f6a79 100644
--- a/src/slic3r/GUI/GUI_ObjectList.cpp
+++ b/src/slic3r/GUI/GUI_ObjectList.cpp
@@ -230,9 +230,9 @@ ObjectList::ObjectList(wxWindow* parent) :
 	// So the postponed EnsureVisible() call is planned for an item, which may not exist at the Idle processing time, if this wxEVT_SIZE
 	// event is succeeded by a delete of the currently active item. We are trying our luck by postponing the wxEVT_SIZE triggered EnsureVisible(),
 	// which seems to be working as of now.
-	this->CallAfter([this](){ this->EnsureVisible(this->GetCurrentItem()); });
+    this->CallAfter([this](){ ensure_current_item_visible(); });
 #else
-	this->EnsureVisible(this->GetCurrentItem());
+    ensure_current_item_visible();
 #endif
 	e.Skip();
 	}));
@@ -3162,7 +3162,7 @@ void ObjectList::update_selections()
     select_items(sels);
 
     // Scroll selected Item in the middle of an object list
-    this->EnsureVisible(this->GetCurrentItem());
+    ensure_current_item_visible();
 }
 
 void ObjectList::update_selections_on_canvas()
diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp
index a5a72ad8c..dc0953d3b 100644
--- a/src/slic3r/GUI/GUI_ObjectList.hpp
+++ b/src/slic3r/GUI/GUI_ObjectList.hpp
@@ -171,6 +171,12 @@ private:
     SettingsBundle m_freq_settings_sla;
 #endif
 
+    inline void ensure_current_item_visible()
+    {
+        if (const auto &item = this->GetCurrentItem())
+            this->EnsureVisible(item);
+    }
+
 public:
     ObjectList(wxWindow* parent);
     ~ObjectList();