mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
use the custom container for global static lists
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d75c96ca69
commit
ce0d2a58d9
6 changed files with 36 additions and 37 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "qstring.h"
|
||||
#include "qlist.h"
|
||||
#include "qcorecommon_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1633,7 +1634,7 @@ int qrand()
|
|||
with meaningful parameter names in their signatures.
|
||||
*/
|
||||
|
||||
Q_GLOBAL_STATIC(QList<qInternalCallback>, qGlobalCallbacks)
|
||||
Q_GLOBAL_STATIC(QStdVector<qInternalCallback>, qGlobalCallbacks)
|
||||
|
||||
void QInternal::registerCallback(qInternalCallback callback)
|
||||
{
|
||||
|
@ -1647,7 +1648,7 @@ void QInternal::unregisterCallback(qInternalCallback callback)
|
|||
|
||||
bool QInternal::activateCallbacks(void **parameters)
|
||||
{
|
||||
QList<qInternalCallback> *callbacks = qGlobalCallbacks();
|
||||
QStdVector<qInternalCallback> *callbacks = qGlobalCallbacks();
|
||||
bool ret = false;
|
||||
for (int i = 0; i < callbacks->size(); i++) {
|
||||
ret |= (callbacks->at(i))(parameters);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "qabstractfileengine_p.h"
|
||||
#include "qfilesystemmetadata_p.h"
|
||||
#include "qcore_unix_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
//#define DEBUG_RESOURCE_MATCH
|
||||
|
||||
|
@ -108,12 +109,10 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(QResourceRoot, Q_MOVABLE_TYPE);
|
||||
|
||||
static std::recursive_mutex qGlobalResourceMutex;
|
||||
|
||||
typedef QList<QResourceRoot*> ResourceList;
|
||||
Q_GLOBAL_STATIC(ResourceList, resourceList)
|
||||
typedef QStdVector<QResourceRoot*> ResourceList;
|
||||
Q_GLOBAL_STATIC(ResourceList, qGlobalResourceList)
|
||||
|
||||
/*!
|
||||
\class QResource
|
||||
|
@ -212,7 +211,7 @@ QResourcePrivate::load(const QString &file)
|
|||
{
|
||||
related.clear();
|
||||
std::lock_guard<std::recursive_mutex> lock(qGlobalResourceMutex);
|
||||
const ResourceList *list = resourceList();
|
||||
const ResourceList *list = qGlobalResourceList();
|
||||
QString cleaned = QDir::cleanPath(file);
|
||||
for(int i = 0; i < list->size(); ++i) {
|
||||
QResourceRoot *res = list->at(i);
|
||||
|
@ -698,11 +697,11 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
|
|||
const unsigned char *name, const unsigned char *data)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(qGlobalResourceMutex);
|
||||
if(version == Q_RCC_OUTPUT_REVISION && resourceList()) {
|
||||
if(version == Q_RCC_OUTPUT_REVISION && qGlobalResourceList()) {
|
||||
bool found = false;
|
||||
QResourceRoot res(tree, name, data);
|
||||
for(int i = 0; i < resourceList()->size(); ++i) {
|
||||
if(*resourceList()->at(i) == res) {
|
||||
for(int i = 0; i < qGlobalResourceList()->size(); ++i) {
|
||||
if(*qGlobalResourceList()->at(i) == res) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -710,7 +709,7 @@ Q_CORE_EXPORT bool qRegisterResourceData(int version, const unsigned char *tree,
|
|||
if(!found) {
|
||||
QResourceRoot *root = new QResourceRoot(tree, name, data);
|
||||
root->ref.ref();
|
||||
resourceList()->append(root);
|
||||
qGlobalResourceList()->append(root);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -721,11 +720,11 @@ Q_CORE_EXPORT bool qUnregisterResourceData(int version, const unsigned char *tre
|
|||
const unsigned char *name, const unsigned char *data)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(qGlobalResourceMutex);
|
||||
if(version == Q_RCC_OUTPUT_REVISION && resourceList()) {
|
||||
if(version == Q_RCC_OUTPUT_REVISION && qGlobalResourceList()) {
|
||||
QResourceRoot res(tree, name, data);
|
||||
for(int i = 0; i < resourceList()->size(); ) {
|
||||
if(*resourceList()->at(i) == res) {
|
||||
QResourceRoot *root = resourceList()->takeAt(i);
|
||||
for(int i = 0; i < qGlobalResourceList()->size(); ) {
|
||||
if(*qGlobalResourceList()->at(i) == res) {
|
||||
QResourceRoot *root = qGlobalResourceList()->takeAt(i);
|
||||
if(!root->ref.deref())
|
||||
delete root;
|
||||
} else {
|
||||
|
@ -810,7 +809,7 @@ QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
|
|||
if(root->registerSelf(rccData)) {
|
||||
root->ref.ref();
|
||||
std::lock_guard<std::recursive_mutex> lock(qGlobalResourceMutex);
|
||||
resourceList()->append(root);
|
||||
qGlobalResourceList()->append(root);
|
||||
return true;
|
||||
}
|
||||
delete root;
|
||||
|
@ -832,13 +831,13 @@ bool
|
|||
QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(qGlobalResourceMutex);
|
||||
ResourceList *list = resourceList();
|
||||
ResourceList *list = qGlobalResourceList();
|
||||
for(int i = 0; i < list->size(); ++i) {
|
||||
QResourceRoot *res = list->at(i);
|
||||
if(res->type() == QResourceRoot::Resource_Buffer) {
|
||||
QDynamicBufferResourceRoot *root = reinterpret_cast<QDynamicBufferResourceRoot*>(res);
|
||||
if(root->mappingBuffer() == rccData && root->mappingRoot() == resourceRoot) {
|
||||
resourceList()->removeAt(i);
|
||||
qGlobalResourceList()->removeAt(i);
|
||||
if(!root->ref.deref()) {
|
||||
delete root;
|
||||
return true;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "qsize.h"
|
||||
#include "qpoint.h"
|
||||
#include "qrect.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -48,7 +49,7 @@ struct QSettingsFormat
|
|||
QSettingsWriteFunc writeFunc;
|
||||
};
|
||||
|
||||
typedef QVector<QSettings*> QSettingsVector;
|
||||
typedef QStdVector<QSettings*> QSettingsVector;
|
||||
Q_GLOBAL_STATIC(QSettingsVector, qGlobalSettings)
|
||||
Q_GLOBAL_STATIC(QMutex, qSettingsMutex)
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "qlocale_p.h"
|
||||
#include "qeventdispatcher_unix_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -72,30 +73,24 @@ bool QCoreApplicationPrivate::checkInstance(const char *function)
|
|||
return true;
|
||||
}
|
||||
|
||||
typedef QList<QtCleanUpFunction> QVFuncList;
|
||||
Q_GLOBAL_STATIC(QVFuncList, postRList)
|
||||
typedef QStdVector<QtCleanUpFunction> QVFuncList;
|
||||
Q_GLOBAL_STATIC(QVFuncList, qGlobalCleanupList)
|
||||
|
||||
void qAddPostRoutine(QtCleanUpFunction p)
|
||||
{
|
||||
QVFuncList *list = postRList();
|
||||
if (!list)
|
||||
return;
|
||||
QVFuncList *list = qGlobalCleanupList();
|
||||
list->prepend(p);
|
||||
}
|
||||
|
||||
void qRemovePostRoutine(QtCleanUpFunction p)
|
||||
{
|
||||
QVFuncList *list = postRList();
|
||||
if (!list)
|
||||
return;
|
||||
QVFuncList *list = qGlobalCleanupList();
|
||||
list->removeAll(p);
|
||||
}
|
||||
|
||||
void Q_CORE_EXPORT qt_call_post_routines()
|
||||
{
|
||||
QVFuncList *list = postRList();
|
||||
if (!list)
|
||||
return;
|
||||
QVFuncList *list = qGlobalCleanupList();
|
||||
while (!list->isEmpty())
|
||||
(list->takeFirst())();
|
||||
}
|
||||
|
|
|
@ -30,11 +30,12 @@
|
|||
#include "qpluginloader.h"
|
||||
#include "qcoreapplication_p.h"
|
||||
#include "qlibrary_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_GLOBAL_STATIC(QMutex, qGlobalFactoryLoaderMutex);
|
||||
Q_GLOBAL_STATIC(QList<QFactoryLoader*>, qGlobalFactoryLoaders)
|
||||
Q_GLOBAL_STATIC(QStdVector<QFactoryLoader*>, qGlobalFactoryLoaders)
|
||||
|
||||
class QFactoryLoaderPrivate
|
||||
{
|
||||
|
@ -155,10 +156,11 @@ QObject *QFactoryLoader::instance(const QString &key)
|
|||
void QFactoryLoader::refreshAll()
|
||||
{
|
||||
QMutexLocker locker(qGlobalFactoryLoaderMutex());
|
||||
QList<QFactoryLoader *> *loaders = qGlobalFactoryLoaders();
|
||||
for (QList<QFactoryLoader *>::const_iterator it = loaders->constBegin();
|
||||
it != loaders->constEnd(); ++it) {
|
||||
QStdVector<QFactoryLoader*> *loaders = qGlobalFactoryLoaders();
|
||||
QStdVector<QFactoryLoader *>::const_iterator it = loaders->constBegin();
|
||||
while (it != loaders->constEnd()) {
|
||||
(*it)->update();
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "qcoreapplication_p.h"
|
||||
#include "qdebug.h"
|
||||
#include "qcore_unix_p.h"
|
||||
#include "qstdcontainers_p.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -234,7 +235,7 @@ static QString qt_find_library(const QString &fileName)
|
|||
}
|
||||
|
||||
|
||||
class QLibraryCleanup : public QList<QLibraryPrivate*>
|
||||
class QLibraryCleanup : public QStdVector<QLibraryPrivate*>
|
||||
{
|
||||
public:
|
||||
~QLibraryCleanup();
|
||||
|
@ -284,9 +285,9 @@ bool QLibraryPrivate::unload()
|
|||
if (qt_debug_component()) {
|
||||
qWarning() << "QLibraryPrivate::unload succeeded on" << fileName;
|
||||
}
|
||||
pHnd = 0;
|
||||
pHnd = nullptr;
|
||||
}
|
||||
return (pHnd == 0);
|
||||
return (pHnd == nullptr);
|
||||
}
|
||||
|
||||
void *QLibraryPrivate::resolve(const char *symbol)
|
||||
|
|
Loading…
Add table
Reference in a new issue