diff options
-rw-r--r-- | src/corelib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 8 | ||||
-rw-r--r-- | src/corelib/global/qtresource.h | 21 | ||||
-rw-r--r-- | src/corelib/global/qtresource.qdoc | 54 | ||||
-rw-r--r-- | src/corelib/io/qdir.cpp | 53 |
5 files changed, 77 insertions, 60 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 663ceeda63..aed5fd973a 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -80,6 +80,7 @@ qt_internal_add_module(Core global/qtdeprecationmarkers.h global/qtrace_p.h global/qtranslation.h + global/qtresource.h global/qtversionchecks.h global/qtypeinfo.h global/qtypes.cpp global/qtypes.h diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index ca0f09ef5c..0ebbc34f49 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -48,13 +48,6 @@ inline void qt_noop(void) {} #ifndef __ASSEMBLER__ QT_BEGIN_NAMESPACE -#define Q_INIT_RESOURCE(name) \ - do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \ - QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (false) -#define Q_CLEANUP_RESOURCE(name) \ - do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \ - QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (false) - /* * If we're compiling C++ code: * - and this is a non-namespace build, declare qVersion as extern "C" @@ -228,6 +221,7 @@ QT_END_NAMESPACE #include <QtCore/qoverload.h> #include <QtCore/qtdeprecationmarkers.h> #include <QtCore/qtranslation.h> +#include <QtCore/qtresource.h> #include <QtCore/qversiontagging.h> #endif /* __cplusplus */ diff --git a/src/corelib/global/qtresource.h b/src/corelib/global/qtresource.h new file mode 100644 index 0000000000..535903aac0 --- /dev/null +++ b/src/corelib/global/qtresource.h @@ -0,0 +1,21 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QTRESOURCE_H +#define QTRESOURCE_H + +#include <QtCore/qtconfigmacros.h> + +#if 0 +#pragma qt_class(QtResource) +#pragma qt_sync_stop_processing +#endif + +#define Q_INIT_RESOURCE(name) \ + do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \ + QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (false) +#define Q_CLEANUP_RESOURCE(name) \ + do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \ + QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (false) + +#endif // QTRESOURCE_H diff --git a/src/corelib/global/qtresource.qdoc b/src/corelib/global/qtresource.qdoc new file mode 100644 index 0000000000..433391cee4 --- /dev/null +++ b/src/corelib/global/qtresource.qdoc @@ -0,0 +1,54 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \macro void Q_INIT_RESOURCE(name) + \relates QtResource + + Initializes the resources specified by the \c .qrc file with the + specified base \a name. Normally, when resources are built as part + of the application, the resources are loaded automatically at + startup. The Q_INIT_RESOURCE() macro is necessary on some platforms + for resources stored in a static library. + + For example, if your application's resources are listed in a file + called \c myapp.qrc, you can ensure that the resources are + initialized at startup by adding this line to your \c main() + function: + + \snippet code/src_corelib_io_qdir.cpp 13 + + If the file name contains characters that cannot be part of a valid C++ function name + (such as '-'), they have to be replaced by the underscore character ('_'). + + \note This macro cannot be used in a namespace. It should be called from + main(). If that is not possible, the following workaround can be used + to init the resource \c myapp from the function \c{MyNamespace::myFunction}: + + \snippet code/src_corelib_io_qdir.cpp 14 + + \sa Q_CLEANUP_RESOURCE(), {The Qt Resource System} +*/ + +/*! + \since 4.1 + \macro void Q_CLEANUP_RESOURCE(name) + \relates QtResource + + Unloads the resources specified by the \c .qrc file with the base + name \a name. + + Normally, Qt resources are unloaded automatically when the + application terminates, but if the resources are located in a + plugin that is being unloaded, call Q_CLEANUP_RESOURCE() to force + removal of your resources. + + \note This macro cannot be used in a namespace. Please see the + Q_INIT_RESOURCE documentation for a workaround. + + Example: + + \snippet code/src_corelib_io_qdir.cpp 15 + + \sa Q_INIT_RESOURCE(), {The Qt Resource System} +*/ diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index ee0871b57b..2af88cde5a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2370,59 +2370,6 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter) return QDirPrivate::splitFilters(nameFilter); } -/*! - \macro void Q_INIT_RESOURCE(name) - \relates QDir - - Initializes the resources specified by the \c .qrc file with the - specified base \a name. Normally, when resources are built as part - of the application, the resources are loaded automatically at - startup. The Q_INIT_RESOURCE() macro is necessary on some platforms - for resources stored in a static library. - - For example, if your application's resources are listed in a file - called \c myapp.qrc, you can ensure that the resources are - initialized at startup by adding this line to your \c main() - function: - - \snippet code/src_corelib_io_qdir.cpp 13 - - If the file name contains characters that cannot be part of a valid C++ function name - (such as '-'), they have to be replaced by the underscore character ('_'). - - \note This macro cannot be used in a namespace. It should be called from - main(). If that is not possible, the following workaround can be used - to init the resource \c myapp from the function \c{MyNamespace::myFunction}: - - \snippet code/src_corelib_io_qdir.cpp 14 - - \sa Q_CLEANUP_RESOURCE(), {The Qt Resource System} -*/ - -/*! - \since 4.1 - \macro void Q_CLEANUP_RESOURCE(name) - \relates QDir - - Unloads the resources specified by the \c .qrc file with the base - name \a name. - - Normally, Qt resources are unloaded automatically when the - application terminates, but if the resources are located in a - plugin that is being unloaded, call Q_CLEANUP_RESOURCE() to force - removal of your resources. - - \note This macro cannot be used in a namespace. Please see the - Q_INIT_RESOURCE documentation for a workaround. - - Example: - - \snippet code/src_corelib_io_qdir.cpp 15 - - \sa Q_INIT_RESOURCE(), {The Qt Resource System} -*/ - - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, QDir::Filters filters) { |