From 1ddfb443b686ef04cc0e28363308ce70d01f0d73 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 24 May 2018 20:50:32 +0200 Subject: qmake: fix file id mapping lifetime management, take 2 turns out that ref-counting the vfs class is insufficient, as now the ProFile cache (which expires after a timeout) could outlive all VFS instances and thus refer to ids which were discarded and later re-used. to avoid this, we let the cache instance hold a reference to the vfs class. amends d03fb3506. Task-number: QTCREATORBUG-20524 Change-Id: Idd4478ffc1c2405b3b83df32fba45b1f687f6a18 Reviewed-by: Robert Loehning Reviewed-by: Tobias Hunger --- src/shared/proparser/qmakevfs.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/shared/proparser/qmakevfs.cpp') diff --git a/src/shared/proparser/qmakevfs.cpp b/src/shared/proparser/qmakevfs.cpp index c5c5b75c74..f438978bad 100644 --- a/src/shared/proparser/qmakevfs.cpp +++ b/src/shared/proparser/qmakevfs.cpp @@ -49,13 +49,23 @@ QMakeVfs::QMakeVfs() #ifndef QT_NO_TEXTCODEC m_textCodec = 0; #endif + ref(); +} + +QMakeVfs::~QMakeVfs() +{ + deref(); +} + +void QMakeVfs::ref() +{ #ifdef PROEVALUATOR_THREAD_SAFE QMutexLocker locker(&s_mutex); #endif ++s_refCount; } -QMakeVfs::~QMakeVfs() +void QMakeVfs::deref() { #ifdef PROEVALUATOR_THREAD_SAFE QMutexLocker locker(&s_mutex); @@ -67,7 +77,6 @@ QMakeVfs::~QMakeVfs() } } - #ifdef PROPARSER_THREAD_SAFE QMutex QMakeVfs::s_mutex; #endif -- cgit v1.2.3