From 302823d73b8ca27e67e703de8316092d8b4d5715 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 4 Mar 2024 12:24:21 +0100 Subject: 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. Pick-to: 6.7 Change-Id: I69c8cfe4e2d6d7d4659edda621ba1afe9768035b Reviewed-by: Friedemann Kleint --- src/gui/image/qicon.cpp | 316 ++++++++++++++++++++++++------------------------ 1 file changed, 158 insertions(+), 158 deletions(-) (limited to 'src/gui/image/qicon.cpp') diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 6a2f7935ff..086ac37a07 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -1403,168 +1403,168 @@ bool QIcon::hasThemeIcon(const QString &name) return icon.name() == name; } +static constexpr auto themeIconMapping = qOffsetStringArray( + "address-book-new", + "application-exit", + "appointment-new", + "call-start", + "call-stop", + "contact-new", + "document-new", + "document-open", + "document-open-recent", + "document-page-setup", + "document-print", + "document-print-preview", + "document-properties", + "document-revert", + "document-save", + "document-save-as", + "document-send", + "edit-clear", + "edit-copy", + "edit-cut", + "edit-delete", + "edit-find", + "edit-paste", + "edit-redo", + "edit-select-all", + "edit-undo", + "folder-new", + "format-indent-less", + "format-indent-more", + "format-justify-center", + "format-justify-fill", + "format-justify-left", + "format-justify-right", + "format-text-direction-ltr", + "format-text-direction-rtl", + "format-text-bold", + "format-text-italic", + "format-text-underline", + "format-text-strikethrough", + "go-down", + "go-home", + "go-next", + "go-previous", + "go-up", + "help-about", + "help-faq", + "insert-image", + "insert-link", + "insert-text", + "list-add", + "list-remove", + "mail-forward", + "mail-mark-important", + "mail-mark-read", + "mail-mark-unread", + "mail-message-new", + "mail-reply-all", + "mail-reply-sender", + "mail-send", + "media-eject", + "media-playback-pause", + "media-playback-start", + "media-playback-stop", + "media-record", + "media-seek-backward", + "media-seek-forward", + "media-skip-backward", + "media-skip-forward", + "object-rotate-left", + "object-rotate-right", + "process-stop", + "system-lock-screen", + "system-log-out", + "system-search", + "system-reboot", + "system-shutdown", + "tools-check-spelling", + "view-fullscreen", + "view-refresh", + "view-restore", + "window-close", + "window-new", + "zoom-fit-best", + "zoom-in", + "zoom-out", + + "audio-card", + "audio-input-microphone", + "battery", + "camera-photo", + "camera-video", + "camera-web", + "computer", + "drive-harddisk", + "drive-optical", + "input-gaming", + "input-keyboard", + "input-mouse", + "input-tablet", + "media-flash", + "media-optical", + "media-tape", + "multimedia-player", + "network-wired", + "network-wireless", + "phone", + "printer", + "scanner", + "video-display", + + "appointment-missed", + "appointment-soon", + "audio-volume-high", + "audio-volume-low", + "audio-volume-medium", + "audio-volume-muted", + "battery-caution", + "battery-low", + "dialog-error", + "dialog-information", + "dialog-password", + "dialog-question", + "dialog-warning", + "folder-drag-accept", + "folder-open", + "folder-visiting", + "image-loading", + "image-missing", + "mail-attachment", + "mail-unread", + "mail-read", + "mail-replied", + "media-playlist-repeat", + "media-playlist-shuffle", + "network-offline", + "printer-printing", + "security-high", + "security-low", + "software-update-available", + "software-update-urgent", + "sync-error", + "sync-synchronizing", + "user-available", + "user-offline", + "weather-clear", + "weather-clear-night", + "weather-few-clouds", + "weather-few-clouds-night", + "weather-fog", + "weather-showers", + "weather-snow", + "weather-storm" +); +static_assert(QIcon::ThemeIcon::NThemeIcons == QIcon::ThemeIcon(themeIconMapping.count())); + static constexpr QLatin1StringView themeIconName(QIcon::ThemeIcon icon) { - constexpr auto mapping = qOffsetStringArray( - "address-book-new", - "application-exit", - "appointment-new", - "call-start", - "call-stop", - "contact-new", - "document-new", - "document-open", - "document-open-recent", - "document-page-setup", - "document-print", - "document-print-preview", - "document-properties", - "document-revert", - "document-save", - "document-save-as", - "document-send", - "edit-clear", - "edit-copy", - "edit-cut", - "edit-delete", - "edit-find", - "edit-paste", - "edit-redo", - "edit-select-all", - "edit-undo", - "folder-new", - "format-indent-less", - "format-indent-more", - "format-justify-center", - "format-justify-fill", - "format-justify-left", - "format-justify-right", - "format-text-direction-ltr", - "format-text-direction-rtl", - "format-text-bold", - "format-text-italic", - "format-text-underline", - "format-text-strikethrough", - "go-down", - "go-home", - "go-next", - "go-previous", - "go-up", - "help-about", - "help-faq", - "insert-image", - "insert-link", - "insert-text", - "list-add", - "list-remove", - "mail-forward", - "mail-mark-important", - "mail-mark-read", - "mail-mark-unread", - "mail-message-new", - "mail-reply-all", - "mail-reply-sender", - "mail-send", - "media-eject", - "media-playback-pause", - "media-playback-start", - "media-playback-stop", - "media-record", - "media-seek-backward", - "media-seek-forward", - "media-skip-backward", - "media-skip-forward", - "object-rotate-left", - "object-rotate-right", - "process-stop", - "system-lock-screen", - "system-log-out", - "system-search", - "system-reboot", - "system-shutdown", - "tools-check-spelling", - "view-fullscreen", - "view-refresh", - "view-restore", - "window-close", - "window-new", - "zoom-fit-best", - "zoom-in", - "zoom-out", - - "audio-card", - "audio-input-microphone", - "battery", - "camera-photo", - "camera-video", - "camera-web", - "computer", - "drive-harddisk", - "drive-optical", - "input-gaming", - "input-keyboard", - "input-mouse", - "input-tablet", - "media-flash", - "media-optical", - "media-tape", - "multimedia-player", - "network-wired", - "network-wireless", - "phone", - "printer", - "scanner", - "video-display", - - "appointment-missed", - "appointment-soon", - "audio-volume-high", - "audio-volume-low", - "audio-volume-medium", - "audio-volume-muted", - "battery-caution", - "battery-low", - "dialog-error", - "dialog-information", - "dialog-password", - "dialog-question", - "dialog-warning", - "folder-drag-accept", - "folder-open", - "folder-visiting", - "image-loading", - "image-missing", - "mail-attachment", - "mail-unread", - "mail-read", - "mail-replied", - "media-playlist-repeat", - "media-playlist-shuffle", - "network-offline", - "printer-printing", - "security-high", - "security-low", - "software-update-available", - "software-update-urgent", - "sync-error", - "sync-synchronizing", - "user-available", - "user-offline", - "weather-clear", - "weather-clear-night", - "weather-few-clouds", - "weather-few-clouds-night", - "weather-fog", - "weather-showers", - "weather-snow", - "weather-storm" - ); - static_assert(QIcon::ThemeIcon::NThemeIcons == QIcon::ThemeIcon(mapping.count())); - using ThemeIconIndex = std::underlying_type_t; const auto index = static_cast(icon); - Q_ASSERT(index < mapping.count()); - return QLatin1StringView(mapping.viewAt(index)); + Q_ASSERT(index < themeIconMapping.count()); + return QLatin1StringView(themeIconMapping.viewAt(index)); } /*! -- cgit v1.2.3