use big resource variant, else we OOM on 32 bit machines
this has issues with LTO, we have a unit test that tells if stuff got lost in the DLL fix the resource loading for static library building, uncovered by the new unit test BUG: 487452 BUG: 499674
This commit is contained in:
parent
3cda523b6a
commit
75fd5c16d1
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@
|
||||
dist
|
||||
node_modules
|
||||
/.vscode/
|
||||
/.kateproject.*
|
||||
CMakeLists.txt.user*
|
||||
.cmake/
|
||||
/.clang-format
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
include(ECMAddTests)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Test)
|
||||
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui Test)
|
||||
|
||||
configure_file(testdata.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/testdata.h)
|
||||
ecm_add_test(scalabletest.cpp
|
||||
TEST_NAME "scalable"
|
||||
LINK_LIBRARIES Qt6::Test
|
||||
)
|
||||
ecm_add_test(resourcetest.cpp
|
||||
TEST_NAME "resource"
|
||||
LINK_LIBRARIES KF6BreezeIcons Qt6::Gui Qt6::Test
|
||||
)
|
||||
if(WITH_ICON_GENERATION)
|
||||
add_test(NAME "test24x24icons" COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/autotests/test24x24icons.py
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
||||
68
autotests/resourcetest.cpp
Normal file
68
autotests/resourcetest.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
This file is part of the KDE libraries
|
||||
|
||||
SPDX-FileCopyrightText: 2025 Christoph Cullmann <cullmann@kde.org>
|
||||
|
||||
SPDX-License-Identifier: LGPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include <QFile>
|
||||
#include <QObject>
|
||||
#include <QTest>
|
||||
|
||||
#include "breezeicons.h"
|
||||
#include "testhelpers.h"
|
||||
|
||||
class ResourceTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
void compareFileResourceWithFilesystem(const QString &name)
|
||||
{
|
||||
// resource location
|
||||
const QString qrcLocation(QStringLiteral(":/icons/breeze/%1").arg(name));
|
||||
|
||||
// file system location
|
||||
const QString fsLocation(PROJECT_SOURCE_DIR + QStringLiteral("/icons/%1").arg(name));
|
||||
|
||||
// read full data of both, must work
|
||||
QFile qrcFile(qrcLocation);
|
||||
QVERIFY(qrcFile.open(QFile::ReadOnly));
|
||||
QFile fsFile(fsLocation);
|
||||
QVERIFY(fsFile.open(QFile::ReadOnly));
|
||||
const auto qrcData = qrcFile.readAll();
|
||||
QVERIFY(!qrcData.isEmpty());
|
||||
const auto fsData = fsFile.readAll();
|
||||
QVERIFY(!fsData.isEmpty());
|
||||
|
||||
// fully equal?
|
||||
QCOMPARE(qrcData, fsData);
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
// check that not stuff got lost in the DLL
|
||||
// did happen for compiling with LTO or buggy preprocessing the DLL
|
||||
void test_resourceContainsTheme()
|
||||
{
|
||||
// ensure the DLL is linked
|
||||
BreezeIcons::initIcons();
|
||||
|
||||
// we want to have the proper theme file
|
||||
compareFileResourceWithFilesystem(QStringLiteral("index.theme"));
|
||||
|
||||
// check some icons we know shall be there
|
||||
// check no stuff that might not be generated in some config or that is a symlink
|
||||
compareFileResourceWithFilesystem(QStringLiteral("actions/16/go-previous.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("actions/16/table.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("actions/22/edit-paste.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("actions/22/tab-new.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("actions/32/document-edit.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("actions/32/zoom.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("mimetypes/64/application-json.svg"));
|
||||
compareFileResourceWithFilesystem(QStringLiteral("places/64/folder-favorites.svg"));
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_GUILESS_MAIN(ResourceTest)
|
||||
|
||||
#include "resourcetest.moc"
|
||||
@ -24,8 +24,9 @@ if(BINARY_ICONS_RESOURCE)
|
||||
install(FILES ${RESOURCE_FILE_BINARY} DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/breeze)
|
||||
endif()
|
||||
|
||||
# use normal resource adding, big resource variant has issue with LTO
|
||||
qt_add_resources(kbreezeicons_resource_SRCS
|
||||
# use big resource variant, else we OOM on 32 bit machines
|
||||
# this has issues with LTO, we have a unit test that tells if stuff got lost in the DLL
|
||||
qt_add_big_resources(kbreezeicons_resource_SRCS
|
||||
${RESOURCE_FILE}
|
||||
OPTIONS --root /icons/breeze
|
||||
)
|
||||
|
||||
@ -10,11 +10,20 @@
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
static void resourceInit()
|
||||
{
|
||||
// needs to be called outside of namespace
|
||||
Q_INIT_RESOURCE(breeze_icons);
|
||||
}
|
||||
|
||||
namespace BreezeIcons
|
||||
{
|
||||
|
||||
void initIcons()
|
||||
{
|
||||
// ensure the resource is there and loaded for static libs
|
||||
resourceInit();
|
||||
|
||||
// ensure we fallback to breeze, if no user fallback is set
|
||||
const QString fallbackTheme = QIcon::fallbackThemeName();
|
||||
if (fallbackTheme.isEmpty() || fallbackTheme == QLatin1String("hicolor")) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user