[prev in list] [next in list] [prev in thread] [next in thread]
List: kdevelop-devel
Subject: Change initialization of typeRepository [Was: [Bug 201455]
From: Andreas Pakulat <apaku () gmx ! de>
Date: 2009-08-07 4:47:54
Message-ID: 20090807044754.GA24511 () trinity ! apaku ! dnsalias ! org
[Download RAW message or body]
On 07.08.09 04:09:24, Yaron wrote:
> https://bugs.kde.org/show_bug.cgi?id=201455
>
>
>
>
>
> --- Comment #6 from Yaron <yhirsch netvision net il> 2009-08-07 04:09:21 ---
> One reason seems to be the order of initialization of global variables:
>
> instantiationInformationRepository (line 116 in
> kdevplatform/language/duchain/instantiationinformation.cpp) calls
> typeRepositoryManager() which in turn returns a pointer to typeRepository (line
> 85 in kdevplatform/language/duchain/repositories/typrepository.cpp) which
> hasn't been initialized. Immediately after this pointer is being used in
> RepositoryManager::createRepository() but as noted, it hasn't been initialized.
Thanks Yaron for the analysis. The attached patch should fix the
initialization, however I'd like to have a comment from David wether
this could potentially break something. David?
I couldn't test wether this helps on windows, but at least it doesn't
seem to break anything on linux.
Andreas
--
Long life is in store for you.
["fix_initialization_typeRepository.diff" (text/x-diff)]
diff --git a/language/duchain/repositories/typerepository.cpp \
b/language/duchain/repositories/typerepository.cpp index 8c57498..edc33cb 100644
--- a/language/duchain/repositories/typerepository.cpp
+++ b/language/duchain/repositories/typerepository.cpp
@@ -82,17 +82,20 @@ class AbstractTypeDataRequest {
const AbstractType& m_item;
};
-RepositoryManager< ItemRepository<AbstractTypeData, AbstractTypeDataRequest>, false> \
typeRepository("Type Repository"); +RepositoryManager< \
ItemRepository<AbstractTypeData, AbstractTypeDataRequest>, false> typeRepository() { \
+ static RepositoryManager< ItemRepository<AbstractTypeData, \
AbstractTypeDataRequest>, false> _typeRepository("Type Repository"); + return \
_typeRepository; +}
AbstractRepositoryManager* typeRepositoryManager() {
- return &typeRepository;
+ return &typeRepository();
}
uint TypeRepository::indexForType(AbstractType::Ptr input) {
if(!input)
return 0;
- uint i = typeRepository->index(AbstractTypeDataRequest(*input));
+ uint i = typeRepository()->index(AbstractTypeDataRequest(*input));
#ifdef DEBUG_TYPE_REPOSITORY
AbstractType::Ptr t = typeForIndex(i);
if(!t->equals(input.unsafeData())) {
@@ -111,14 +114,14 @@ AbstractType::Ptr TypeRepository::typeForIndex(uint index) {
if(index == 0)
return AbstractType::Ptr();
- return AbstractType::Ptr( \
TypeSystem::self().create(const_cast<AbstractTypeData*>(typeRepository->itemFromIndex(index))) \
); + return AbstractType::Ptr( \
TypeSystem::self().create(const_cast<AbstractTypeData*>(typeRepository()->itemFromIndex(index))) \
); }
void TypeRepository::increaseReferenceCount(uint index, ReferenceCountManager* \
manager) { if(!index)
return;
- QMutexLocker lock(typeRepository->mutex());
- AbstractTypeData* data = typeRepository->dynamicItemFromIndexSimple(index);
+ QMutexLocker lock(typeRepository()->mutex());
+ AbstractTypeData* data = typeRepository()->dynamicItemFromIndexSimple(index);
Q_ASSERT(data);
if(manager)
manager->increase(data->refCount, index);
@@ -129,8 +132,8 @@ void TypeRepository::increaseReferenceCount(uint index, \
ReferenceCountManager* m void TypeRepository::decreaseReferenceCount(uint index, \
ReferenceCountManager* manager) { if(!index)
return;
- QMutexLocker lock(typeRepository->mutex());
- AbstractTypeData* data = typeRepository->dynamicItemFromIndexSimple(index);
+ QMutexLocker lock(typeRepository()->mutex());
+ AbstractTypeData* data = typeRepository()->dynamicItemFromIndexSimple(index);
Q_ASSERT(data);
Q_ASSERT(data->refCount > 0);
if(manager)
_______________________________________________
KDevelop-devel mailing list
KDevelop-devel@kdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic