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;
|
return icon.name() == name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr QLatin1StringView themeIconName(QIcon::ThemeIcon icon)
|
static constexpr auto themeIconMapping = qOffsetStringArray(
|
||||||
{
|
|
||||||
constexpr auto mapping = qOffsetStringArray(
|
|
||||||
"address-book-new",
|
"address-book-new",
|
||||||
"application-exit",
|
"application-exit",
|
||||||
"appointment-new",
|
"appointment-new",
|
||||||
@ -1556,12 +1554,14 @@ static constexpr QLatin1StringView themeIconName(QIcon::ThemeIcon icon)
|
|||||||
"weather-snow",
|
"weather-snow",
|
||||||
"weather-storm"
|
"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>;
|
using ThemeIconIndex = std::underlying_type_t<QIcon::ThemeIcon>;
|
||||||
const auto index = static_cast<ThemeIconIndex>(icon);
|
const auto index = static_cast<ThemeIconIndex>(icon);
|
||||||
Q_ASSERT(index < mapping.count());
|
Q_ASSERT(index < themeIconMapping.count());
|
||||||
return QLatin1StringView(mapping.viewAt(index));
|
return QLatin1StringView(themeIconMapping.viewAt(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user