summaryrefslogtreecommitdiffhomepage
path: root/ext
diff options
context:
space:
mode:
authorTom Black <[email protected]>2019-01-06 00:54:48 -0800
committerTom Black <[email protected]>2019-01-06 00:54:48 -0800
commit5f7f348ffece2c80663c0f1a002ea25fb0979076 (patch)
treebff8f80067e4e370d0448bedf0cf6f4a39e5ede9 /ext
parent9d2de68fea9ea8dec9c52b5cf7d2f9fdee5333a4 (diff)
downloadruby2d-5f7f348ffece2c80663c0f1a002ea25fb0979076.tar.gz
ruby2d-5f7f348ffece2c80663c0f1a002ea25fb0979076.zip
Don't allow screenshots before window is shown
Diffstat (limited to 'ext')
-rw-r--r--ext/ruby2d/ruby2d.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c
index 300c8e0..7c17bac 100644
--- a/ext/ruby2d/ruby2d.c
+++ b/ext/ruby2d/ruby2d.c
@@ -176,8 +176,13 @@ static R_VAL ruby2d_ext_screenshot(mrb_state* mrb, R_VAL self) {
#else
static R_VAL ruby2d_ext_screenshot(R_VAL self, R_VAL path) {
#endif
- S2D_Screenshot(window, RSTRING_PTR(path));
- return R_NIL;
+ if (window) {
+ S2D_Screenshot(window, RSTRING_PTR(path));
+ return path;
+ } else {
+ S2D_Log(S2D_WARN, "Cannot take screenshot before window is shown");
+ return R_FALSE;
+ }
}