From b4a0814af2854de0646317964b8dfcd35d045f90 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Pawe=C5=82=20Stawicki?=
Date: Tue, 13 Jun 2017 14:52:44 +0200
Subject: [PATCH] Unregister ecore event handler in ~AccessoriesSwitchProvider
Change-Id: I5dcd1e8a1c0c97b59555dfa998cc00bb54ebf01e
---
src/AccessoriesSwitchProvider.cpp | 10 +++++++---
src/AccessoriesSwitchProvider.hpp | 3 +++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/AccessoriesSwitchProvider.cpp b/src/AccessoriesSwitchProvider.cpp
index a17784c..045fbee 100644
--- a/src/AccessoriesSwitchProvider.cpp
+++ b/src/AccessoriesSwitchProvider.cpp
@@ -1,7 +1,5 @@
#include "AccessoriesSwitchProvider.hpp"
-#include
-
AccessoriesSwitchProvider::AccessoriesSwitchProvider()
: SwitchProvider("AccessoriesSwitchProvider"), keys(
{"XF86AddFavorite",
@@ -680,9 +678,15 @@ AccessoriesSwitchProvider::AccessoriesSwitchProvider()
for (auto &key : keys)
switches.emplace_back(std::make_shared(key, switchProviderId));
- ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, onEcoreEventKeyDownCb, this);
+ ecoreHandler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, onEcoreEventKeyDownCb, this);
}
+AccessoriesSwitchProvider::~AccessoriesSwitchProvider()
+{
+ ecore_event_handler_del(ecoreHandler);
+}
+
+
SwitchProvider::SwitchCollection AccessoriesSwitchProvider::findAllSwitches() const
{
return switches;
diff --git a/src/AccessoriesSwitchProvider.hpp b/src/AccessoriesSwitchProvider.hpp
index 2dd0011..23cd8a7 100644
--- a/src/AccessoriesSwitchProvider.hpp
+++ b/src/AccessoriesSwitchProvider.hpp
@@ -4,6 +4,7 @@
#include "SwitchProvider.hpp"
#include
+#include
#include
#include
@@ -13,6 +14,7 @@ class AccessoriesSwitchProvider : public SwitchProvider
{
public:
AccessoriesSwitchProvider();
+ ~AccessoriesSwitchProvider() override;
SwitchCollection findAllSwitches() const override;
std::shared_ptr findSwitchById(const std::string &switchId) const override;
@@ -22,6 +24,7 @@ private:
const std::vector keys;
SwitchCollection switches;
+ Ecore_Event_Handler *ecoreHandler;
};
#endif
--
2.7.4