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