Skip to content

Conversation

@mariovisic
Copy link
Contributor

Add two errors:

  1. prevent users from calling 'show' multiple times as it currently
    doesn't function
  2. prevent users directly drawing objects outside of the render block
    (this does not work as the window is not yet ready)

Add two errors:
1) prevent users from calling 'show' multiple times as it currently
   doesn't function
2) prevent users directly drawing objects outside of the render block
   (this does not work as the window is not yet ready)
@mariovisic
Copy link
Contributor Author

I'm not sure what general approach is best in these cases, do we want to try and have helpful error messages, should we link to the website?

This should make issues #212 and #190 not segfault but rather present a more helpful error message to the users.

Copy link
Member

@blacktm blacktm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, seems to work. Would need to add guards to all the "renderable" classes. Also, we may need to keep @@open_window set to true even after close is called, because this will still cause a crash when a key is pressed:

require 'ruby2d'

on :key do |e|
  close
end

show
show

@mariovisic
Copy link
Contributor Author

Cool, seems to work. Would need to add guards to all the "renderable" classes. Also, we may need to keep @@open_window set to true even after close is called, because this will still cause a crash when a key is pressed:

require 'ruby2d'

on :key do |e|
  close
end

show
show

Great, I tested this and it works well 👍

For some reason I had missed these classes earlier. Also remove one call
in Triangle to the window check, as we only need to perform it on direct
draw calls, not when the private render method is called (as the window
is always ready in that case).
@mariovisic
Copy link
Contributor Author

Cool, seems to work. Would need to add guards to all the "renderable" classes. Also, we may need to keep @@open_window set to true even after close is called, because this will still cause a crash when a key is pressed:

require 'ruby2d'

on :key do |e|
  close
end

show
show

oh wierd, not sure how I missed some of them. Fixed in 851acf4

@mariovisic
Copy link
Contributor Author

This is now ready for re-review when you have a spare moment @blacktm 👍

@mariovisic mariovisic merged commit 54ec3db into main Aug 27, 2021
@mariovisic mariovisic deleted the window_ready_error_handling branch August 27, 2021 02:45
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