File indexing completed on 2025-01-05 05:23:45
0001 /* 0002 This file is part of the Okteta Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2013 Alex Richardson <alex.richardson@gmx.de> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "safereference.hpp" 0010 #include <structureslogging.hpp> 0011 // #include "../datatypes/datainformation.hpp" 0012 // Std 0013 #include <cstdio> 0014 0015 SafeReferenceHolder SafeReferenceHolder::instance; 0016 0017 SafeReferenceHolder::SafeReferenceHolder() = default; 0018 0019 SafeReferenceHolder::~SafeReferenceHolder() 0020 { 0021 if (!mRefs.isEmpty()) { 0022 qCWarning(LOG_KASTEN_OKTETA_CONTROLLERS_STRUCTURES) << mRefs.size() << "safe references were not removed"; 0023 } 0024 #ifndef NDEBUG 0025 printf("register count: %d, destroy count: %d\n", safeRefRegisterCnt, safeRefDestroyCnt); 0026 #endif 0027 } 0028 0029 void SafeReferenceHolder::invalidateAll(DataInformation* data) 0030 { 0031 // this is called from DataInformation destructor, don't do anything with data! 0032 Container::iterator i = mRefs.find(data); 0033 // qCDebug(LOG_KASTEN_OKTETA_CONTROLLERS_STRUCTURES) << "invalidating all references to" << data->name(); 0034 while (i != mRefs.end() && i.key() == data) { 0035 // qCDebug(LOG_KASTEN_OKTETA_CONTROLLERS_STRUCTURES) << "invalidating" << i.value(); 0036 i.value()->invalidate(); 0037 ++i; 0038 } 0039 // remove all this items from the list 0040 int removed = mRefs.remove(data); 0041 safeRefDestroyCnt += removed; 0042 // qCDebug(LOG_KASTEN_OKTETA_CONTROLLERS_STRUCTURES) << "removed" << removed << "items"; 0043 }