Menu

#331 Patch series for 1.9

open
nobody
patch (9)
5
6 days ago
2026-03-03
Mercury233
No

Hi,

I have rebased and rewritten the patches from #330 against the current 1.9 branch. I also added a few additional changes. Please note that those patches have not yet been thoroughly tested.

Below is an overview of the patches in order:

  1. Fix dangling pointer in getTextFromClipboard
    Resolves a dangling pointer issue in getTextFromClipboard by using a static string buffer on Windows and macOS to safely store clipboard data.

  2. Simplify logging in CZipReader
    Replacing swprintf_irr calls with os::Printer::log.

  3. Use snprintf_irr instead of sprintf
    Replaces sprintf calls with snprintf_irr across multiple files.

  4. Fix creating NSMenu with a null bundle name (macOS)
    Prevents a potential crash when creating NSMenu by falling back to "Irrlicht" if the bundle name is null.

  5. Avoid forced chdir in CIrrDeviceMacOSX
    Prevents creating device from changing the working directory unless the application is running from a valid .app bundle.

  6. Set activation policy to Regular on macOS
    Explicitly sets the macOS application activation policy to Regular, ensuring the application appears in the Dock and has a functional menu bar.

  7. Fix GetDC/ReleaseDC mismatch in CIrrDeviceWin32
    Ensures that GetDC is called with the window handle (HWnd) rather than the screen handle, matching the corresponding ReleaseDC call and preventing a resource mismatch.

  8. Fix keyboard selection in CGUIListBox
    Fixes an issue where typing a letter would trigger EGET_LISTBOX_CHANGED before the selected item was actually updated. The patch ensures that the selection state is updated first and the event is emitted afterwards. It also merges two loops used in the selection logic.

  9. Prevent changing selection while pressing a list item
    Improves touch interaction in CGUIListBox by preventing unintended selection changes during drag operations.

  10. Do not send EGET_EDITBOX_CHANGED when no character is input
    Updates CGUIEditBox to emit the change event and recalculate layout only when an actual character is entered, ignoring non-character key presses.

  11. Ignore additional non-text keys in CGUIEditBox
    Extends key filtering in CGUIEditBox to ignore modifier keys (Shift, Alt, Win) and function keys so they are not processed as text input.

  12. Fix UTF-8 parsing in utf8codepoint
    Corrects the parsing logic to properly skip invalid bytes, preventing potential infinite loops when encountering malformed UTF-8 sequences.

  13. Add toWideChar and toMultiByte helpers
    Introduces toWideChar and toMultiByte wrapper functions in irrString.h to provide more consistent, platform-independent UTF-8 string conversions.

  14. Refactor clipboard to support UTF-8 on Windows, macOS, and Linux
    Refactors clipboard handling to provide proper UTF-8 support across platforms, including correct string conversions and use of modern APIs (e.g., the UTF8_STRING atom on X11).
    This patch assumes that patch 1 has already been applied.

  15. Fix macOS special keys and Command shortcuts handling
    Corrects macOS key event handling to properly recognize special keys (e.g., arrow and function keys) and to correctly process standard shortcuts such as Command+C/V/X/A.

Please feel free to point out any issues or areas that need refinement.

15 Attachments

Discussion

  • Michael Zeilfelder

    Thanks. I've not given up on your original 1.8 patches yet, probably will apply some more there, just got ill last days.

     
    ❤️
    1
  • Mercury233

    Mercury233 - 2026-03-25

    it seems that [r6765] didn't change the code, just changed the changelog.

     

    Related

    Commit: [r6765]

    • Michael Zeilfelder

      Oh strange, thanks for checking! I'll fix it again in the evening.

       
  • Michael Zeilfelder

    About string conversion wrappers in 13: Was there some reason why you create a string for a null pointer instead of just return a null pointer again?

    I'm considering that one as I'm also using similar wrappers in my projects. Thought I'm going to change it a bit.

    • It should probably be IRRLICHT_API instead of static and implementation beside the other conversion functions.
    • Better to pass the strlen as a second parameter (that way you can pass for example std::wstring or core::stringw which both already know the size without having to go over the whole string again to find out it's length).
    • utf8 should be called utf8 like in the other functions, no need to add another name with multibyte which is less descriptive. Not sure yet about rest of the name - naming always hard ;-)
    • and well - the question above - my instinct would be to return nullptr for nullptr
     
  • Michael Zeilfelder

    Hm, I see now - you got influenced by the other multibyte functions at the end of the string header (I didn't remember those...). Thought those are really multibyte (as in - the format is not specified any futher unlike in this case).

     
  • Michael Zeilfelder

    I was wrong about using IRRLICHT_API . This would make likely cause memory allocation to cross dll borders. Actually risky functions - this would be the first functions in Irrlicht to return something not reference counted which is allocated with new.

     
  • Mercury233

    Mercury233 - 6 days ago

    I also think that, when retrieving clipboard content, it would be appropriate to introduce a new API or an overload that accepts a caller-provided pointer to a char[] buffer for output, instead of returning the output.

    BTW, the comments for IImage::lock() and IImage::unlock() should be updated to remove the “Be sure to call unlock()” note, as it has already been clarified in [r5168] that calling unlock() do nothing.

     

    Related

    Commit: [r5168]


Log in to post a comment.

MongoDB Logo MongoDB