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

SetWindowTitle panic after upgrade from v0.26.2 -> v0.26.3 #1029

Closed
DziedzicGrzegorz opened this issue May 30, 2024 · 1 comment · Fixed by #1030
Closed

SetWindowTitle panic after upgrade from v0.26.2 -> v0.26.3 #1029

DziedzicGrzegorz opened this issue May 30, 2024 · 1 comment · Fixed by #1030
Labels
bug Something isn't working

Comments

@DziedzicGrzegorz
Copy link

Describe the bug

The application crashes with a runtime error: "invalid memory address or nil pointer dereference" when trying to set the window title using Bubble Tea's SetWindowTitle method.

This behavior occurs on both Windows and Ubuntu

Source Code

func main() {
    var rootCmd = &cobra.Command{
        Use:   "game",
        Short: "Tic-Tac-Toe game",
        Long:  "A simple Tic-Tac-Toe game written in Go using the Bubble Tea library and the Lip Gloss library.",
        Run: func(cmd *cobra.Command, args []string) {
            p := tea.NewProgram(model{}, tea.WithAltScreen())
            p.SetWindowTitle("Welcome to the game")
            if _, err := p.Run(); err != nil {
                fmt.Fprintf(os.Stderr, "Error: %v\n", err)
                os.Exit(1)
            }
        },
    }

    if err := rootCmd.Execute(); err != nil {
        fmt.Fprintf(os.Stderr, "Error: %v\n", err)
        os.Exit(1)
    }
}

nilPointer

@aymanbagabas aymanbagabas added the bug Something isn't working label May 30, 2024
@aymanbagabas
Copy link
Member

Hi @DziedzicGrzegorz, that's a bug indeed! FWIW, using p.SetWindowTitle is deprecated or should be, you should use tea.SetWindowTitle instead in your model Init(). Meanwhile, I will push a fix for this bug momentarily.

aymanbagabas added a commit that referenced this issue May 30, 2024
Using program commands like p.EnableMouseCellMotion and p.SetWindowTitle
_before_ the program starts can panic the application since `renderer`
hasn't been initialized yet. Use program options to enable and set these
options if `renderer` is not initialized.

Fixes: #1029
aymanbagabas added a commit that referenced this issue May 30, 2024
Using program commands like p.EnableMouseCellMotion and p.SetWindowTitle
_before_ the program starts can panic the application since `renderer`
hasn't been initialized yet. Use program options to enable and set these
options if `renderer` is not initialized.

Fixes: #1029
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants