From d91b3d80e560a698f394e12e777f58e5bfaf2a8b Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Mon, 24 Apr 2017 09:23:33 +0000 Subject: Allow the use of Fl_Image_Surface::image() also when the Fl_Image_Surface object is not the current drawing surface. This fixes an issue uncovered in a thread of fltk.general entitled fl_pop_clip: clip stack underflow! warning on X11 git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12222 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Image_Surface.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx index 632bc3de0..b8b50a2bc 100644 --- a/src/Fl_Image_Surface.cxx +++ b/src/Fl_Image_Surface.cxx @@ -77,7 +77,13 @@ int Fl_Image_Surface::printable_rect(int *w, int *h) {return platform_surface-> The returned object contains its own copy of the RGB data. The caller is responsible for deleting the image. */ -Fl_RGB_Image *Fl_Image_Surface::image() {return platform_surface->image();} +Fl_RGB_Image *Fl_Image_Surface::image() { + bool need_push = (Fl_Surface_Device::surface() != this); + if (need_push) Fl_Surface_Device::push_current(this); + Fl_RGB_Image *img = platform_surface->image(); + if (need_push) Fl_Surface_Device::pop_current(); + return img; +} /** Returns a possibly high resolution image made of all drawings sent to the Fl_Image_Surface object. The Fl_Image_Surface object should have been constructed with Fl_Image_Surface(W, H, 1). -- cgit v1.2.3