summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobalstatic.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global/qglobalstatic.h')
-rw-r--r--src/corelib/global/qglobalstatic.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h
index a6268e057e..5d0b1e8514 100644
--- a/src/corelib/global/qglobalstatic.h
+++ b/src/corelib/global/qglobalstatic.h
@@ -121,8 +121,16 @@ struct QGlobalStatic
bool exists() const { return guard.load() == QtGlobalStatic::Initialized; }
operator Type *() { if (isDestroyed()) return 0; return innerFunction(); }
Type *operator()() { if (isDestroyed()) return 0; return innerFunction(); }
- Type *operator->() { return innerFunction(); }
- Type &operator*() { return *innerFunction(); }
+ Type *operator->()
+ {
+ Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
+ return innerFunction();
+ }
+ Type &operator*()
+ {
+ Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
+ return *innerFunction();
+ }
};
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \