Permalink
Browse files

Fix anonymous activity finding

Trying to find an anonymously created activity resulted in failure.
It happened because the activity comparison compared both the activity
name and the creator's name.

Fixed by comparing only the activity names in the anonymous creator case.

Fixes GF-6610.

Open-webOS-DCO-1.0-Signed-off-by: Teppo Pennanen <teppo.pennanen@lge.com>

Change-Id: Ic5ba6174b4cea944234cefd9acedb1dc6d0e39c4
  • Loading branch information...
1 parent 99e1887 commit 40eecf5dbd8c9299bca2ae6d9f941482841804fb Teppo Pennanen committed Jun 12, 2013
Showing with 26 additions and 2 deletions.
  1. +6 −0 include/internal/ActivityManager.h
  2. +20 −2 src/ActivityManager.cpp
@@ -1,6 +1,7 @@
/* @@@LICENSE
*
* Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
+* Copyright (c) 2013 LG Electronics, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -173,6 +174,11 @@ class ActivityManager : public boost::enable_shared_from_this<ActivityManager>
bool operator()(const Activity& act, const ActivityKey& key) const;
};
+ struct ActivityNameOnlyComp {
+ bool operator()(const ActivityKey& key, const Activity& act) const;
+ bool operator()(const Activity& act, const ActivityKey& key) const;
+ };
+
typedef boost::intrusive::member_hook<Activity, Activity::ActivityTableItem,
&Activity::m_nameTableItem> ActivityNameTableOption;
typedef boost::intrusive::set<Activity, ActivityNameTableOption,
View
@@ -1,6 +1,7 @@
// @@@LICENSE
//
// Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
+// Copyright (c) 2013 LG Electronics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -100,8 +101,13 @@ void ActivityManager::UnregisterActivityName(boost::shared_ptr<Activity> act)
boost::shared_ptr<Activity> ActivityManager::GetActivity(
const std::string& name, const BusId& creator)
{
- ActivityNameTable::iterator iter =
- m_nameTable.find(ActivityKey(name, creator), ActivityNameComp());
+ ActivityNameTable::iterator iter;
+
+ if (creator.GetType() == BusAnon) {
+ iter = m_nameTable.find(ActivityKey(name, creator), ActivityNameOnlyComp());
+ } else {
+ iter = m_nameTable.find(ActivityKey(name, creator), ActivityNameComp());
+ }
if (iter == m_nameTable.end()) {
throw std::runtime_error("Activity name/creator pair not found");
@@ -853,6 +859,18 @@ bool ActivityManager::ActivityNameComp::operator()(
return ActivityKey(act.GetName(), act.GetCreator()) < key;
}
+bool ActivityManager::ActivityNameOnlyComp::operator()(
+ const ActivityKey& key, const Activity& act) const
+{
+ return key.first < act.GetName();
+}
+
+bool ActivityManager::ActivityNameOnlyComp::operator()(
+ const Activity& act, const ActivityKey& key) const
+{
+ return act.GetName() < key.first;
+}
+
bool ActivityManager::ActivityIdComp::operator()(
const Activity& act1, const Activity& act2) const
{

0 comments on commit 40eecf5

Please sign in to comment.