Skip to content

Commit 6a42f49

Browse files
committed
More defense.
1 parent ac97b14 commit 6a42f49

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

crates/processing_pyo3/src/glfw.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,16 @@ impl GlfwContext {
8181

8282
for (_, event) in glfw::flush_messages(&self.events) {
8383
if event == WindowEvent::Close {
84+
self.window.hide();
8485
return false;
8586
}
8687
}
8788

88-
!self.window.should_close()
89+
if self.window.should_close() {
90+
self.window.hide();
91+
return false;
92+
}
93+
94+
true
8995
}
9096
}

crates/processing_pyo3/src/python/jupyter_post_execute.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import IPython.display as _ipy_display
33

44
def _processing_post_execute(result):
5-
processing._end_draw()
5+
if getattr(processing, '_graphics', None) is None:
6+
return
7+
processing._present()
68
png_data = processing._readback_png()
79
_ipy_display.display(_ipy_display.Image(data=bytes(png_data)))
8-
processing._begin_draw()
910

1011
get_ipython().events.register('post_run_cell', _processing_post_execute)

crates/processing_render/src/image.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ pub fn create(
7777
texture_format,
7878
RenderAssetUsages::all(),
7979
);
80-
// When used as a render target (offscreen surface), the texture needs RENDER_ATTACHMENT
80+
// we need to mark this as a render attachment so it can be used as a render target for
81+
// drawing and readback
8182
image.texture_descriptor.usage |= TextureUsages::RENDER_ATTACHMENT;
8283

8384
let handle = images.add(image);

0 commit comments

Comments
 (0)