From: Manuel Nickschas Date: Wed, 7 Mar 2018 00:38:53 +0000 (+0100) Subject: uistyle: Fix weird way of registering Qt types X-Git-Tag: travis-deploy-test~168 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ed7467b75e19dce6228f1cfb53d989a989e92203 uistyle: Fix weird way of registering Qt types Well, maybe it didn't seem so weird a decade ago, but these days we can do type registration in a nicer way. --- diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 714fe91f..d839aef5 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -72,13 +72,12 @@ UiStyle::UiStyle(QObject *parent) _opIconLimit(UserCategoryItem::categoryFromModes("o")), _voiceIconLimit(UserCategoryItem::categoryFromModes("v")) { - // register FormatList if that hasn't happened yet - // FIXME I don't think this actually avoids double registration... then again... does it hurt? - if (QVariant::nameToType("UiStyle::FormatList") == QVariant::Invalid) { - qRegisterMetaType("UiStyle::FormatList"); - qRegisterMetaTypeStreamOperators("UiStyle::FormatList"); - Q_ASSERT(QVariant::nameToType("UiStyle::FormatList") != QVariant::Invalid); - } + static bool registered = []() { + qRegisterMetaType(); + qRegisterMetaTypeStreamOperators(); + return true; + }(); + Q_UNUSED(registered) _uiStylePalette = QVector(static_cast(ColorRole::NumRoles), QBrush());