Fix to multiple loaders can receive the theme changed event 83/294483/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 7 Jun 2023 08:37:17 +0000 (17:37 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 20 Jun 2023 05:50:10 +0000 (05:50 +0000)
Use multimap instead of map. Multiple filters can be registered as same
command(key).

Change-Id: I08e280f3538489f376bea865722b135dd21f82e2
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
(cherry picked from commit 6d94a4a266405daa078a92a42f666a5675fe867f)

src/theme/dbus/request_broker.cc
src/theme/dbus/request_broker.h

index 6ff5ff2e78dcc4b3fd695086a4b1fd4575241ab6..ca43f7e1ebd8c0fa55035a282912fd23794d25ab 100644 (file)
@@ -53,6 +53,8 @@ void RequestBroker::OnReceiveDbusMethod(GDBusConnection* connection,
   Command cmd = static_cast<Command>(command);
   tizen_base::Bundle b(serialized);
 
+  // TODO: filters_ is changed to multimap from map.
+  // multiple filters can be found, but only the first one will be used for now.
   auto it = filters_.find(cmd);
   if (it == filters_.end()) {
     LOG(ERROR) << "UnKnown command";
@@ -193,11 +195,11 @@ bool RequestBroker::Subscribe() {
         Command cmd = static_cast<Command>(command);
         tizen_base::Bundle b(serialized);
 
-        auto it = broker->filters_.find(cmd);
-        if (it == broker->filters_.end())
-          return;
-
-        tizen_base::Bundle result = it->second->GetHandler()->OnRequest(cmd, b);
+        auto itlow = broker->filters_.lower_bound(cmd);
+        auto ithigh = broker->filters_.upper_bound(cmd);
+        for (auto it = itlow; it != ithigh; ++it)
+          tizen_base::Bundle result =
+              it->second->GetHandler()->OnRequest(cmd, b);
       },
       this, nullptr);
 
@@ -302,6 +304,9 @@ void RequestBroker::SendDataAsync(Command cmd, tizen_base::Bundle& data) {
         tizen_base::Bundle b(serialized);
         g_object_unref(reply);
 
+        // TODO: filters_ is changed to multimap from map.
+        // multiple filters can be found, but only the first one will be used
+        // for now.
         auto it = broker->filters_.find(param->first);
         if (it == broker->filters_.end())
           return;
index 5948861a95e7bc7414b8b0502b7bb44ff9853f7c..3d1d3e5a95c81986bbbfe71b4413fa4774a625ba 100644 (file)
@@ -57,7 +57,7 @@ class RequestBroker {
   int registration_id_;
   int subscribe_id_;
   GDBusConnection* connection_;
-  std::map<Command, std::shared_ptr<RequestFilter>> filters_;
+  std::multimap<Command, std::shared_ptr<RequestFilter>> filters_;
 };
 
 }  // namespace dbus