Icon: work around compile optimization bug
We are observing that the strings become sequences of zeros in release builds, possibly triggered by qOffsetStringArray being used in a static constexpr function to initialize a constexpr array. Pull the array out of the function as a static on translation unit level, which is a pattern we use regularly elsewhere in Qt. Change-Id: I69c8cfe4e2d6d7d4659edda621ba1afe9768035b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 302823d73b8ca27e67e703de8316092d8b4d5715) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
106442586e
commit
5997821ece
@ -1400,9 +1400,7 @@ bool QIcon::hasThemeIcon(const QString &name)
|
||||
return icon.name() == name;
|
||||
}
|
||||
|
||||
static constexpr QLatin1StringView themeIconName(QIcon::ThemeIcon icon)
|
||||
{
|
||||
constexpr auto mapping = qOffsetStringArray(
|
||||
static constexpr auto themeIconMapping = qOffsetStringArray(
|
||||
"address-book-new",
|
||||
"application-exit",
|
||||
"appointment-new",
|
||||
@ -1555,13 +1553,15 @@ static constexpr QLatin1StringView themeIconName(QIcon::ThemeIcon icon)
|
||||
"weather-showers",
|
||||
"weather-snow",
|
||||
"weather-storm"
|
||||
);
|
||||
static_assert(QIcon::ThemeIcon::NThemeIcons == QIcon::ThemeIcon(mapping.count()));
|
||||
);
|
||||
static_assert(QIcon::ThemeIcon::NThemeIcons == QIcon::ThemeIcon(themeIconMapping.count()));
|
||||
|
||||
static constexpr QLatin1StringView themeIconName(QIcon::ThemeIcon icon)
|
||||
{
|
||||
using ThemeIconIndex = std::underlying_type_t<QIcon::ThemeIcon>;
|
||||
const auto index = static_cast<ThemeIconIndex>(icon);
|
||||
Q_ASSERT(index < mapping.count());
|
||||
return QLatin1StringView(mapping.viewAt(index));
|
||||
Q_ASSERT(index < themeIconMapping.count());
|
||||
return QLatin1StringView(themeIconMapping.viewAt(index));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user