[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kcachegrind/frameworks] /: Followup to c1bb693: Use better method names
From: Josef Weidendorfer <Josef.Weidendorfer () gmx ! de>
Date: 2016-03-21 16:37:40
Message-ID: E1ai2po-0002WR-77 () scm ! kde ! org
[Download RAW message or body]
Git commit c0f11c04f533fec364fdd2ae90dda003485b2ac6 by Josef Weidendorfer.
Committed on 21/03/2016 at 11:28.
Pushed by weidendo into branch 'frameworks'.
Followup to c1bb693: Use better method names
This partly reverts changes in c1bb693 ("fix memleak...") by
introducing new methods and call these to fix the same bug.
M +29 -7 libcore/eventtype.cpp
M +5 -3 libcore/eventtype.h
M +2 -2 libviews/eventtypeview.cpp
http://commits.kde.org/kcachegrind/c0f11c04f533fec364fdd2ae90dda003485b2ac6
diff --git a/libcore/eventtype.cpp b/libcore/eventtype.cpp
index 7ccc4e8..053688b 100644
--- a/libcore/eventtype.cpp
+++ b/libcore/eventtype.cpp
@@ -231,27 +231,50 @@ int EventType::histCost(ProfileCostArray* c, double total, double* hist)
}
+bool EventType::hasKnownRealType(const QString& n)
+{
+ if (!_knownTypes) return false;
+ foreach (EventType* t, *_knownTypes)
+ if (t->isReal() && (t->name() == n))
+ return true;
-EventType* EventType::knownRealType(const QString& n)
+ return false;
+}
+
+bool EventType::hasKnownDerivedType(const QString& n)
+{
+ if (!_knownTypes) return false;
+
+ foreach (EventType* t, *_knownTypes)
+ if (!t->isReal() && (t->name() == n))
+ return true;
+
+ return false;
+}
+
+EventType* EventType::cloneKnownRealType(const QString& n)
{
if (!_knownTypes) return 0;
foreach (EventType* t, *_knownTypes)
if (t->isReal() && (t->name() == n)) {
- return t;
+ EventType* type = new EventType(*t);
+ return type;
}
return 0;
}
-EventType* EventType::knownDerivedType(const QString& n)
+
+EventType* EventType::cloneKnownDerivedType(const QString& n)
{
if (!_knownTypes) return 0;
foreach (EventType* t, *_knownTypes)
if (!t->isReal() && (t->name() == n)) {
- return t;
+ EventType* type = new EventType(*t);
+ return type;
}
return 0;
@@ -387,9 +410,8 @@ int EventTypeSet::addReal(const QString& t)
int index = realIndex(t);
if (index>=0) return index;
- EventType* ct = EventType::knownRealType(t);
- if (ct) ct = new EventType(*ct); //clone it
- else ct = new EventType(t, t);
+ EventType* ct = EventType::cloneKnownRealType(t);
+ if (!ct) ct = new EventType(t, t);
// make it real
ct->setRealIndex();
diff --git a/libcore/eventtype.h b/libcore/eventtype.h
index cb44b18..29ecc7d 100644
--- a/libcore/eventtype.h
+++ b/libcore/eventtype.h
@@ -86,9 +86,11 @@ public:
int histCost(ProfileCostArray* c, double total, double* hist);
// application wide known types, referenced by short name
- // next 2 functions return a new type object instance
- static EventType* knownRealType(const QString&);
- static EventType* knownDerivedType(const QString&);
+ // next 2 functions return a new event type instance
+ static EventType* cloneKnownRealType(const QString&);
+ static EventType* cloneKnownDerivedType(const QString&);
+ static bool hasKnownRealType(const QString&);
+ static bool hasKnownDerivedType(const QString&);
static void add(EventType*, bool overwriteExisting = true);
static bool remove(const QString&);
static int knownTypeCount();
diff --git a/libviews/eventtypeview.cpp b/libviews/eventtypeview.cpp
index 0a29084..2d26554 100644
--- a/libviews/eventtypeview.cpp
+++ b/libviews/eventtypeview.cpp
@@ -161,8 +161,8 @@ void EventTypeView::context(const QPoint & p)
else if (a == newTypeAction) {
int i = 1;
while(1) {
- if (!EventType::knownDerivedType(tr("New%1").arg(i)))
- break;
+ if (!EventType::hasKnownDerivedType(tr("New%1").arg(i)))
+ break;
i++;
}
// add same new cost type to this set and to known types
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic