From 6c984d6c15a0b0a210aac12513217fc08437c690 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 15 Jul 2011 17:51:07 +0200 Subject: "Fix" the crash at startup on MSVC The problem is that for some reasons, QByteArray::shared_null (and probably shared_empty, and the ones for QString) are not in the .rodata anymore, and they are initialized by code. programs like QMake, which has others global objects (like global QFiles) that uses QByteArray crashes, because they reference and dereference shared_null (and try to destroy shared_null) That happens before shared_null's refcount is initialized to -1 The solution here is not to ref() the objects that have a refcount of 0 (that is what the refcount is before it is initialized to -1) The real fix to this problem would be to understand why it is not in the proper section, and make sure it is. Change-Id: I5b7e966ed4c460b90dba70855f4dc50685dff97f Reviewed-on: http://codereview.qt.nokia.com/1712 Reviewed-by: Qt Sanity Bot Reviewed-by: Friedemann Kleint --- src/corelib/tools/qrefcount.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index 9223cfe352..e72ddf66b6 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -57,12 +57,12 @@ class RefCount { public: inline void ref() { - if (atomic >= 0) + if (atomic > 0) atomic.ref(); } inline bool deref() { - if (atomic < 0) + if (atomic <= 0) return true; return atomic.deref(); } -- cgit v1.2.3