Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dicon proxy engine read #215

Merged
merged 2 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/util/private/diconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ QIconEngine *DIconProxyEngine::clone() const

bool DIconProxyEngine::read(QDataStream &in)
{
// ensureEngine, will changed themeName if not the same
in >> m_iconName >> m_iconThemeName;

ensureEngine();
return m_iconEngine ? m_iconEngine->read(in) : false;
}

Expand Down
Binary file modified tests/dcis/selected_indicator.dci
Binary file not shown.
20 changes: 12 additions & 8 deletions tests/src/ut_diconproxyengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <QPainter>
#include <QIODevice>
#include <private/qicon_p.h>

#include <DGuiApplicationHelper>
#include <DPlatformTheme>
Expand Down Expand Up @@ -115,18 +116,21 @@ TEST_F(ut_DIconProxyEngine, read_write)
ASSERT_EQ(iconName, mIconEngine->iconName());
}

iconName = "test_icon_name";
themeName = "test_theme_name";
{
auto engine = new DIconProxyEngine("selected_indicator" ,DIconTheme::DontFallbackToQIconFromTheme);
QIcon icon_write(engine);
QDataStream out(&data, QIODevice::WriteOnly);
out << iconName << themeName;
}
{
out << icon_write;

QIcon icon_read;
QDataStream in(&data, QIODevice::ReadOnly);
mIconEngine->read(in);
in >> icon_read;

ASSERT_EQ(themeName, mIconEngine->themeName());
ASSERT_EQ(iconName, mIconEngine->iconName());
ASSERT_TRUE(icon_read.data_ptr()->engine);
EXPECT_EQ(icon_read.data_ptr()->engine->key(),
engine->key());
EXPECT_EQ(icon_read.data_ptr()->engine->iconName(),
engine->iconName());
}
}

Expand Down
Loading