summaryrefslogtreecommitdiffhomepage
path: root/ext
diff options
context:
space:
mode:
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;
+ }
}