Skip to content

Commit

Permalink
Define AbstractError self-registration variable out-of-line to avoid
Browse files Browse the repository at this point in the history
multiple init

When compiling the library as a DLL, since the variable within each
derived error type was defined inline, multiple links to the Qx library
in a project would cause there to be multiple versions of said variable,
causing the class to register itself multiple times.
  • Loading branch information
oblivioncth committed Jul 23, 2023
1 parent 6812df5 commit 64754ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/core/include/qx/core/qx-abstracterror.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -126,6 +126,9 @@ friend class Error;
// []<StringLiteral Y, quint16 Z>(AbstractError<Y, Z>&){}(type);
//};

template<StringLiteral EName, quint16 ECode>
const bool AbstractError<EName, ECode>::REGISTER = registerType(TYPE_CODE, TYPE_NAME);

namespace AbstractErrorPrivate
{
template<Qx::StringLiteral Y, quint16 Z>
Expand Down

0 comments on commit 64754ea

Please sign in to comment.