Line 0
Link Here
|
|
|
1 |
--- src/plugins/projectexplorer/runconfiguration.h.orig 2016-06-21 13:37:35 UTC |
2 |
+++ src/plugins/projectexplorer/runconfiguration.h |
3 |
@@ -159,6 +159,7 @@ public: |
4 |
virtual ~ClonableConcept() = default; |
5 |
virtual ClonableConcept *clone() const = 0; |
6 |
virtual bool equals(const std::unique_ptr<ClonableConcept> &other) const = 0; |
7 |
+ virtual void *typeId() const = 0; |
8 |
}; |
9 |
|
10 |
template <class T> |
11 |
@@ -168,11 +169,14 @@ public: |
12 |
ClonableModel(const T &data) : m_data(data) { } |
13 |
~ClonableModel() Q_DECL_NOEXCEPT { } // gcc 4.7.3 |
14 |
ClonableConcept *clone() const override { return new ClonableModel(*this); } |
15 |
+ void *typeId() const { return T::staticTypeId; } |
16 |
|
17 |
bool equals(const std::unique_ptr<ClonableConcept> &other) const override |
18 |
{ |
19 |
- auto that = dynamic_cast<const ClonableModel<T> *>(other.get()); |
20 |
- return that && m_data == that->m_data; |
21 |
+ if (other->typeId() != typeId()) |
22 |
+ return false; |
23 |
+ auto that = static_cast<const ClonableModel<T> *>(other.get()); |
24 |
+ return m_data == that->m_data; |
25 |
} |
26 |
|
27 |
T m_data; |
28 |
@@ -189,7 +193,7 @@ public: |
29 |
void operator=(Runnable other) { d = std::move(other.d); } |
30 |
|
31 |
template <class T> bool is() const { |
32 |
- return dynamic_cast<ClonableModel<T> *>(d.get()) != 0; |
33 |
+ return d.get()->typeId() == T::staticTypeId; |
34 |
} |
35 |
|
36 |
template <class T> const T &as() const { |
37 |
@@ -213,7 +217,7 @@ public: |
38 |
void operator=(Connection other) { d = std::move(other.d); } |
39 |
|
40 |
template <class T> bool is() const { |
41 |
- return dynamic_cast<ClonableModel<T> *>(d.get()) != 0; |
42 |
+ return d.get()->typeId() == T::staticTypeId; |
43 |
} |
44 |
|
45 |
template <class T> const T &as() const { |
46 |
yes |
47 |
native |
48 |
text/plain |