Skip to content

Crash on macOS when creating window with disabled buttons due to unwrap on None value #1081

@gezihuzi

Description

@gezihuzi

Describe the bug
The application crashes during startup when using tao 0.32.5 on macOS. The crash occurs because the code in window.rs (line 288) unconditionally calls unwrap() on an Option value returned by standardWindowButton, which becomes None when certain window buttons are disabled in the configuration.

Steps To Reproduce

  1. Create a macOS application using tao 0.32.5
  2. Configure a window with some standard buttons disabled, such as:
{
  "fullscreen": false,
  "resizable": false,
  "minimizable": false,
  "maximizable": false,
  "closable": false
}
  1. Attempt to run the application
  2. The application crashes during initialization with an "unwrap on None" panic

Expected behavior
The application should properly handle cases where window buttons are disabled in the configuration, checking if the standardWindowButton returns a value before attempting to unwrap it.

Platform and Versions (please complete the following information):
OS: macOS 15.3.1 (24D70)
Rustc: rustc 1.85.0 (4d91de4e4 2025-02-17)

Additional context
The issue occurs specifically in the macOS platform implementation. When window buttons are disabled through configuration, the standardWindowButton method returns None, but the code doesn't check for this possibility before calling unwrap().

According to Apple's documentation (https://developer.apple.com/documentation/appkit/nswindow/standardwindowbutton(_:)), the standardWindowButton(_:) method can return nil:

This is precisely what's happening when buttons are disabled in the window configuration - the method correctly returns nil (None in Rust terms), but the tao implementation tries to unwrap this value unconditionally.

A proper fix would involve using if let Some(button) = window.standardWindowButton(...) or similar pattern matching to safely handle cases where buttons are disabled or not available, rather than directly unwrapping the returned value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions