summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2014-12-19 16:22:39 +0000
committerJosé Fonseca <jfonseca@vmware.com>2014-12-19 16:22:39 +0000
commit446ca50d78d519230060d60c7179347ffb23de0c (patch)
treece77aa91b9ef934e786ba5c9ba097b887122b395 /gui
parent8374a0d66ca9228269e860089c1535fcda9f9c5f (diff)
gui: Remove ApiTraceEnumSignature.
It was leaking all over the place, because it wasn't always attached to a TraceLoader. I tried to plumb TraceLoader pointer through to where it was needed, but I failed, as some of the callers where nowhere near to get hold of it. I also believe that instead of converting every trace_model.hpp object into a QVariant is it preferable for the GUI to hold on to the trace_model.hpp objects themselves, and only produce Qt objects for the derived state it needs for fast render/search.
Diffstat (limited to 'gui')
-rw-r--r--gui/apitracecall.cpp71
-rw-r--r--gui/apitracecall.h21
-rw-r--r--gui/traceloader.cpp18
-rw-r--r--gui/traceloader.h4
4 files changed, 19 insertions, 95 deletions
diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp
index a48b4782..533e412b 100644
--- a/gui/apitracecall.cpp
+++ b/gui/apitracecall.cpp
@@ -195,19 +195,7 @@ void VariantVisitor::visit(trace::WString *node)
void VariantVisitor::visit(trace::Enum *e)
{
- ApiTraceEnumSignature *sig = 0;
-
- if (m_loader) {
- sig = m_loader->enumSignature(e->sig->id);
- }
- if (!sig) {
- sig = new ApiTraceEnumSignature(e->sig);
- if (m_loader) {
- m_loader->addEnumSignature(e->sig->id, sig);
- }
- }
-
- m_variant = QVariant::fromValue(ApiEnum(sig, e->value));
+ m_variant = QVariant::fromValue(ApiEnum(e->sig, e->value));
}
void VariantVisitor::visit(trace::Bitmask *bitmask)
@@ -242,42 +230,24 @@ void VariantVisitor::visit(trace::Repr *repr)
repr->humanValue->visit(*this);
}
-ApiTraceEnumSignature::ApiTraceEnumSignature(const trace::EnumSig *sig)
-{
- for (const trace::EnumValue *it = sig->values;
- it != sig->values + sig->num_values; ++it) {
- QPair<QString, signed long long> pair;
-
- pair.first = QString::fromLatin1(it->name);
- pair.second = it->value;
-
- m_names.append(pair);
- }
-}
-
-QString ApiTraceEnumSignature::name(signed long long value) const
-{
- for (ValueList::const_iterator it = m_names.begin();
- it != m_names.end(); ++it) {
- if (value == it->second) {
- return it->first;
- }
- }
- return QString::fromLatin1("%1").arg(value);
-}
-
-ApiEnum::ApiEnum(ApiTraceEnumSignature *sig, signed long long value)
+ApiEnum::ApiEnum(const trace::EnumSig *sig, signed long long value)
: m_sig(sig), m_value(value)
{
+ Q_ASSERT(m_sig);
}
QString ApiEnum::toString() const
{
- if (m_sig) {
- return m_sig->name(m_value);
+ Q_ASSERT(m_sig);
+
+ for (const trace::EnumValue *it = m_sig->values;
+ it != m_sig->values + m_sig->num_values; ++it) {
+ if (m_value == it->value) {
+ return QString::fromLatin1(it->name);
+ }
}
- Q_ASSERT(!"should never happen");
- return QString();
+
+ return QString::fromLatin1("%1").arg(m_value);
}
QVariant ApiEnum::value() const
@@ -289,15 +259,6 @@ QVariant ApiEnum::value() const
return QVariant();
}
-QString ApiEnum::name() const
-{
- if (m_sig) {
- return m_sig->name(m_value);
- }
- Q_ASSERT(!"should never happen");
- return QString();
-}
-
unsigned long long ApiBitmask::value() const
{
return m_value;
@@ -418,7 +379,7 @@ void ApiStruct::init(const trace::Struct *s)
m_sig.name = QString::fromLatin1(s->sig->name);
for (unsigned i = 0; i < s->sig->num_members; ++i) {
- VariantVisitor vis(0);
+ VariantVisitor vis;
m_sig.memberNames.append(
QString::fromLatin1(s->sig->member_names[i]));
s->members[i]->visit(vis);
@@ -463,7 +424,7 @@ void ApiArray::init(const trace::Array *arr)
m_array.reserve(arr->values.size());
for (int i = 0; i < arr->values.size(); ++i) {
- VariantVisitor vis(0);
+ VariantVisitor vis;
arr->values[i]->visit(vis);
m_array.append(vis.variant());
@@ -705,14 +666,14 @@ ApiTraceCall::loadData(TraceLoader *loader,
loader->addSignature(call->sig->id, m_signature);
}
if (call->ret) {
- VariantVisitor retVisitor(loader);
+ VariantVisitor retVisitor;
call->ret->visit(retVisitor);
m_returnValue = retVisitor.variant();
}
m_argValues.reserve(call->args.size());
for (int i = 0; i < call->args.size(); ++i) {
if (call->args[i].value) {
- VariantVisitor argVisitor(loader);
+ VariantVisitor argVisitor;
call->args[i].value->visit(argVisitor);
m_argValues.append(argVisitor.variant());
if (m_argValues[i].type() == QVariant::ByteArray) {
diff --git a/gui/apitracecall.h b/gui/apitracecall.h
index 1534107c..3a7655fa 100644
--- a/gui/apitracecall.h
+++ b/gui/apitracecall.h
@@ -17,9 +17,6 @@ class TraceLoader;
class VariantVisitor : public trace::Visitor
{
public:
- VariantVisitor(TraceLoader *loader)
- : m_loader(loader)
- {}
virtual void visit(trace::Null *);
virtual void visit(trace::Bool *node);
virtual void visit(trace::SInt *node);
@@ -41,7 +38,6 @@ public:
return m_variant;
}
private:
- TraceLoader *m_loader;
QVariant m_variant;
};
@@ -53,29 +49,16 @@ struct ApiTraceError
QString message;
};
-class ApiTraceEnumSignature
-{
-public:
- ApiTraceEnumSignature(const trace::EnumSig *sig);
-
- QString name(signed long long value) const;
-
-private:
- typedef QList<QPair<QString, signed long long> > ValueList;
- ValueList m_names;
-};
-
class ApiEnum
{
public:
- ApiEnum(ApiTraceEnumSignature *sig=0, signed long long value = 0);
+ ApiEnum(const trace::EnumSig *sig=0, signed long long value = 0);
QString toString() const;
QVariant value() const;
- QString name() const;
private:
- ApiTraceEnumSignature *m_sig;
+ const trace::EnumSig *m_sig;
signed long long m_value;
};
Q_DECLARE_METATYPE(ApiEnum);
diff --git a/gui/traceloader.cpp b/gui/traceloader.cpp
index 59f8803e..e6e37e6c 100644
--- a/gui/traceloader.cpp
+++ b/gui/traceloader.cpp
@@ -34,7 +34,6 @@ TraceLoader::~TraceLoader()
{
m_parser.close();
qDeleteAll(m_signatures);
- qDeleteAll(m_enumSignatures);
}
void TraceLoader::loadTrace(const QString &filename)
@@ -45,9 +44,7 @@ void TraceLoader::loadTrace(const QString &filename)
if (!m_frameBookmarks.isEmpty()) {
qDeleteAll(m_signatures);
- qDeleteAll(m_enumSignatures);
m_signatures.clear();
- m_enumSignatures.clear();
m_frameBookmarks.clear();
m_createdFrames.clear();
m_parser.close();
@@ -242,21 +239,6 @@ void TraceLoader::addSignature(unsigned id, ApiTraceCallSignature *signature)
m_signatures[id] = signature;
}
-ApiTraceEnumSignature * TraceLoader::enumSignature(unsigned id)
-{
- if (id >= m_enumSignatures.count()) {
- m_enumSignatures.resize(id + 1);
- return NULL;
- } else {
- return m_enumSignatures[id];
- }
-}
-
-void TraceLoader::addEnumSignature(unsigned id, ApiTraceEnumSignature *signature)
-{
- m_enumSignatures[id] = signature;
-}
-
void TraceLoader::searchNext(const ApiTrace::SearchRequest &request)
{
Q_ASSERT(m_parser.supportsOffsets());
diff --git a/gui/traceloader.h b/gui/traceloader.h
index 3714f651..65a179d9 100644
--- a/gui/traceloader.h
+++ b/gui/traceloader.h
@@ -22,8 +22,7 @@ public:
ApiTraceCallSignature *signature(unsigned id);
void addSignature(unsigned id, ApiTraceCallSignature *signature);
- ApiTraceEnumSignature *enumSignature(unsigned id);
- void addEnumSignature(unsigned id, ApiTraceEnumSignature *signature);
+ trace::EnumSig *enumSignature(unsigned id);
private:
class FrameContents
@@ -118,7 +117,6 @@ private:
QHash<QString, QUrl> m_helpHash;
QVector<ApiTraceCallSignature*> m_signatures;
- QVector<ApiTraceEnumSignature*> m_enumSignatures;
};
#endif