aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-09 14:43:39 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-09 14:43:39 +0900
commit3002c73eebb9a7bb6eb03b9c6ac31bc232ff595b (patch)
treebd2112d096cbc8eed6bc0f4522c5e90191e9f489
parent4120f7f3e071b9682817f4acbd33904ae938be71 (diff)
downloadlibquotient-3002c73eebb9a7bb6eb03b9c6ac31bc232ff595b.tar.gz
libquotient-3002c73eebb9a7bb6eb03b9c6ac31bc232ff595b.zip
Fix legacy EventType values being incorrectly initialised
Static storage initialisation fiasco, as it is...
-rw-r--r--lib/events/event.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/events/event.h b/lib/events/event.h
index 06cad5d1..735e38ae 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -115,15 +115,18 @@ namespace QMatrixClient
template <typename EventT>
struct EventTypeTraits
{
- static const event_type_t id;
+ static event_type_t id()
+ {
+ static const auto id = EventTypeRegistry::initializeTypeId<EventT>();
+ return id;
+ }
};
template <typename EventT>
- const event_type_t EventTypeTraits<EventT>::id =
- EventTypeRegistry::initializeTypeId<EventT>();
-
- template <typename EventT>
- inline event_type_t typeId() { return EventTypeTraits<std::decay_t<EventT>>::id; }
+ inline event_type_t typeId()
+ {
+ return EventTypeTraits<std::decay_t<EventT>>::id();
+ }
inline event_type_t unknownEventTypeId() { return typeId<void>(); }
@@ -268,13 +271,22 @@ namespace QMatrixClient
} \
// End of macro
+ namespace EventType
+ {
+ inline event_type_t logEventType(event_type_t id, const char* idName)
+ {
+ qDebug(EVENTS) << "Using id" << id << "for" << idName;
+ return id;
+ }
+ }
+
// This macro provides constants in EventType:: namespace for
// back-compatibility with libQMatrixClient 0.3 event type system.
#define DEFINE_EVENTTYPE_ALIAS(_Id, _Type) \
namespace EventType \
{ \
[[deprecated("Use is<>(), eventCast<>() or visit<>()")]] \
- static const auto _Id = typeId<_Type>(); \
+ static const auto _Id = logEventType(typeId<_Type>(), #_Id); \
} \
// End of macro