Q_GLOBAL_STATIC - deal with static code analysers
At least some of them don't like the fact we have classes with non-trivial destructors but trivial move/copy constructors - disable them explicitly, hopefully those analysers are smart enough to stop complaining. Change-Id: I285711a2d21bff89661af928ba326ecd5b69823f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
bf7b1a2aa8
commit
dcbca2975f
|
|
@ -79,9 +79,11 @@ enum GuardValues {
|
|||
Q_GLOBAL_STATIC_INTERNAL_DECORATION Type *innerFunction() \
|
||||
{ \
|
||||
struct HolderBase { \
|
||||
HolderBase() = default; \
|
||||
~HolderBase() noexcept \
|
||||
{ if (guard.loadRelaxed() == QtGlobalStatic::Initialized) \
|
||||
guard.storeRelaxed(QtGlobalStatic::Destroyed); } \
|
||||
Q_DISABLE_COPY_MOVE(HolderBase) \
|
||||
}; \
|
||||
static struct Holder : public HolderBase { \
|
||||
Type value; \
|
||||
|
|
@ -112,10 +114,12 @@ QT_BEGIN_NAMESPACE
|
|||
if (guard.loadRelaxed() == QtGlobalStatic::Uninitialized) { \
|
||||
d = new Type ARGS; \
|
||||
static struct Cleanup { \
|
||||
Cleanup() = default; \
|
||||
~Cleanup() { \
|
||||
delete d; \
|
||||
guard.storeRelaxed(QtGlobalStatic::Destroyed); \
|
||||
} \
|
||||
Q_DISABLE_COPY_MOVE(Cleanup) \
|
||||
} cleanup; \
|
||||
guard.storeRelease(QtGlobalStatic::Initialized); \
|
||||
} \
|
||||
|
|
|
|||
Loading…
Reference in New Issue