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

mlx_destroy_display() #21

Closed
jipay opened this issue Nov 23, 2020 · 1 comment
Closed

mlx_destroy_display() #21

jipay opened this issue Nov 23, 2020 · 1 comment

Comments

@jipay
Copy link

jipay commented Nov 23, 2020

Hello ! I get some issues with mlx_destroy_display()
I am using it in a quit function, no problem via ESC key event for close the program but I get this error message via red cross windows close program :

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  4 (X_DestroyWindow)
  Resource id in failed request:  0x6e00001
  Serial number of failed request:  658
  Current serial number in output stream:  661

I have noticed If i don't use it with mlx_destroy_windows() this way, I don't have this issue. Maybe I don't have understand the way to use it ?
Here is my implementation :

void	ft_init_mrt(t_minirt *mrt)
{
	mrt->mlx = mlx_init();
	mrt->win = mlx_new_window(mrt->mlx, 1024, 768, "miniRT");
}

int		ft_exit_mrt(t_minirt *mrt)
{
	mlx_destroy_window(mrt->mlx, mrt->win);
	mlx_destroy_display(mrt->mlx);
	ft_putstr_fd("bye bye !", 1);
	exit(0);
	return (0);
}

int	key_win3(int key, t_minirt *mrt)
{
	printf("Key in Win3 : %d\n",key);
	if (key==0xFF1B)
		ft_exit_mrt(mrt);
	return (0);
}

int		main()
{
	t_minirt	mrt;
	ft_init_mrt(&mrt);
	mlx_key_hook(mrt.win, key_win3, &mrt);
	mlx_hook(mrt.win, 17, 1L<<17, ft_exit_mrt, &mrt);
	mlx_loop(mrt.mlx);
	return (0);
}
@ghost
Copy link

ghost commented Nov 30, 2020

fixed

@ghost ghost closed this as completed Nov 30, 2020
This issue was closed.
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

No branches or pull requests

1 participant