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

Two small crash/error fixes for Linux #1444

Merged
merged 2 commits into from
Mar 30, 2023
Merged

Two small crash/error fixes for Linux #1444

merged 2 commits into from
Mar 30, 2023

Conversation

joanbm
Copy link
Contributor

@joanbm joanbm commented Dec 18, 2022

Two small crash/error fixes for Linux (for the most part):

  1. A crash when opening a music file with an ID3v2 Copyright tag, due to a format string being invalid UTF-8.

  2. A GTK+ critical warning due to improper usage of wxMenuItem::SetBitmap().

When reading the copyright ID3v2 of a music file, in this piece of code:
    wxString::Format("Copyright \x00A9 %s\n", copyright);
The 1st argument is converted to a wxString using the current locale encoding.

If the encoding is UTF-8 (typically Linux), this string is invalidly encoded
and ends up causing a crash inside wxString::format.

Explicitly specify the encoding to avoid this.
According to the wxWidgets wxMenuItem::SetBitmap() documentation
(see: https://docs.wxwidgets.org/3.0/classwx_menu_item.html),
"SetBitmap() must be called before the item is appended to the menu"

On GTK+, not respecting this causes a warning to be printed to the console:
    (slade:25573): GLib-GObject-WARNING **: 20:16:13.634: invalid cast from 'GtkMenuItem' to 'GtkImageMenuItem'
    (slade:25573): Gtk-CRITICAL **: 20:16:13.634: gtk_image_menu_item_set_image: assertion 'GTK_IS_IMAGE_MENU_ITEM (image_menu_item)' failed

As far as I know this doesn't cause any effect, but fix it to avoid confusion.
@sirjuddington sirjuddington merged commit 2d36435 into sirjuddington:master Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants