From 35e5f345331d9c48cb1038b6f08f5be8fefeac4a Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Sun, 31 Mar 2019 19:24:22 +0200
Subject: [PATCH] fix: Warnings when using std::enable_shared_from_this()

---
 src/ui/display.hpp            | 4 ++--
 src/ui/progress_indicator.hpp | 3 ++-
 src/ui/ui_context.hpp         | 1 +
 src/ui/view.cpp               | 4 ++--
 src/ui/view.hpp               | 2 +-
 5 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/ui/display.hpp b/src/ui/display.hpp
index 3cf06dc..c47a80d 100644
--- a/src/ui/display.hpp
+++ b/src/ui/display.hpp
@@ -15,7 +15,7 @@ namespace rmrf::ui {
  * It implements some basic information handling and a registry for
  * views.
  */
-class display { // : public std::enable_shared_from_this<display> {
+class display : std::enable_shared_from_this<display> {
 public:
     typedef display self_type;
     typedef std::shared_ptr<self_type> ptr_type;
@@ -34,7 +34,7 @@ public:
     decltype(auto) sync(F &&f, Args &&... args) {
         lock_type lock(m);
 
-        return std::forward<F>(f)(nullptr /*shared_from_this()*/, std::forward<Args>(args)...);
+        return std::forward<F>(f)(shared_from_this(), std::forward<Args>(args)...);
     }
 };
 
diff --git a/src/ui/progress_indicator.hpp b/src/ui/progress_indicator.hpp
index 704b20e..62bec22 100644
--- a/src/ui/progress_indicator.hpp
+++ b/src/ui/progress_indicator.hpp
@@ -10,7 +10,8 @@ namespace rmrf::ui {
  */
 class progress_indicator {
 public:
-    virtual ~progress_indicator();
+    progress_indicator() {};
+    virtual ~progress_indicator() {};
     /**
      * Query the progress state
      * @return The current progress in percent
diff --git a/src/ui/ui_context.hpp b/src/ui/ui_context.hpp
index be79b97..4347bd9 100644
--- a/src/ui/ui_context.hpp
+++ b/src/ui/ui_context.hpp
@@ -11,6 +11,7 @@ namespace rmrf::ui {
  */
 class ui_context {
 public:
+    ui_context() {};
     virtual ~ui_context() {};
 
     /**
diff --git a/src/ui/view.cpp b/src/ui/view.cpp
index 8128a30..e4f1073 100644
--- a/src/ui/view.cpp
+++ b/src/ui/view.cpp
@@ -7,7 +7,7 @@ namespace rmrf::ui {
 
 view::view(const std::shared_ptr<view> &parent) : parent_view{parent}, child_views{} {
     if (this->parent_view) {
-//        this->parent_view->add_child(this->shared_from_this());
+        this->parent_view->add_child(this->shared_from_this());
     }
 }
 
@@ -17,7 +17,7 @@ view::~view() {
 
     // Notify our parent about us being destructed
     if (this->parent_view) {
-//        this->parent_view->remove_child(this->shared_from_this());
+        this->parent_view->remove_child(this->shared_from_this());
     }
 }
 
diff --git a/src/ui/view.hpp b/src/ui/view.hpp
index fff51eb..8a5be5a 100644
--- a/src/ui/view.hpp
+++ b/src/ui/view.hpp
@@ -14,7 +14,7 @@ namespace rmrf::ui {
 /**
  * This abstract class implements a view page.
  */
-class view : public ui_context { //, public std::enable_shared_from_this<view> {
+class view : public ui_context, std::enable_shared_from_this<view> {
 private:
     std::shared_ptr<view> parent_view;
     std::list<std::shared_ptr<view>> child_views;
-- 
GitLab