diff --git a/lib/core/include/qx/core/qx-abstracterror.h b/lib/core/include/qx/core/qx-abstracterror.h index 74430652..7a586bed 100644 --- a/lib/core/include/qx/core/qx-abstracterror.h +++ b/lib/core/include/qx/core/qx-abstracterror.h @@ -91,7 +91,7 @@ friend class Error; static constexpr QLatin1StringView TYPE_NAME{EName.value}; private: - static inline const bool REGISTER = registerType(TYPE_CODE, TYPE_NAME); + static const bool REGISTER; //-Constructor------------------------------------------------------------------------------------------------------------- protected: @@ -126,6 +126,15 @@ friend class Error; // [](AbstractError&){}(type); //}; +/* Define error type registrar variable. This must be done out of line to ensure that only + * one instance of the variable exists per-error-type across an entire program. If the variable + * is defined inline, multiple versiosn of it can exist in parallel when linking via shared-libraries, + * if those libraries are used by multiple targets in the same project. This would cause an error type + * to call registerType() multiple times. + */ +template +const bool AbstractError::REGISTER = registerType(TYPE_CODE, TYPE_NAME); + namespace AbstractErrorPrivate { template