summaryrefslogtreecommitdiff
path: root/src/Fl_Image_Surface.cxx
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-04-27 16:42:20 +0000
committerManolo Gouy <Manolo>2016-04-27 16:42:20 +0000
commitf4ec7192a9f2c3ada9f7676ca90942306f910db3 (patch)
tree332be43a0ec07951d86029126a54840ddd981a5d /src/Fl_Image_Surface.cxx
parent425fe6ac8c31ff1500a1745d67aa6bbe781f5328 (diff)
Add tests to avoid null pointer errors
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11703 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Image_Surface.cxx')
-rw-r--r--src/Fl_Image_Surface.cxx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/Fl_Image_Surface.cxx b/src/Fl_Image_Surface.cxx
index 3db192962..d69b34c4a 100644
--- a/src/Fl_Image_Surface.cxx
+++ b/src/Fl_Image_Surface.cxx
@@ -38,7 +38,7 @@ Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, i
*/
Fl_Image_Surface::Fl_Image_Surface(int w, int h, int high_res, Fl_Offscreen pixmap) : Fl_Widget_Surface(NULL) {
platform_surface = Fl_Image_Surface_Driver::newImageSurfaceDriver(w, h, high_res, pixmap);
- driver(platform_surface->driver());
+ if (platform_surface) driver(platform_surface->driver());
}
@@ -47,16 +47,24 @@ Fl_Image_Surface::~Fl_Image_Surface() { delete platform_surface; }
void Fl_Image_Surface::origin(int x, int y) {platform_surface->origin(x, y);}
-void Fl_Image_Surface::origin(int *x, int *y) {platform_surface->origin(x, y);}
+void Fl_Image_Surface::origin(int *x, int *y) {
+ if (platform_surface) platform_surface->origin(x, y);
+}
-void Fl_Image_Surface::set_current() {platform_surface->set_current();}
+void Fl_Image_Surface::set_current() {
+ if (platform_surface) platform_surface->set_current();
+}
/** Stop sending graphics commands to the surface */
void Fl_Image_Surface::end_current() {platform_surface->end_current();}
-void Fl_Image_Surface::translate(int x, int y) {platform_surface->translate(x, y);}
+void Fl_Image_Surface::translate(int x, int y) {
+ if (platform_surface) platform_surface->translate(x, y);
+}
-void Fl_Image_Surface::untranslate() {platform_surface->untranslate();}
+void Fl_Image_Surface::untranslate() {
+ if (platform_surface) platform_surface->untranslate();
+}
/** Returns the Fl_Offscreen object associated to the image surface */
Fl_Offscreen Fl_Image_Surface::offscreen() {return platform_surface->offscreen;}
@@ -78,6 +86,7 @@ Fl_RGB_Image *Fl_Image_Surface::image() {return platform_surface->image();}
*/
Fl_Shared_Image* Fl_Image_Surface::highres_image()
{
+ if (!platform_surface) return NULL;
Fl_Shared_Image *s_img = Fl_Shared_Image::get(platform_surface->image());
int width, height;
platform_surface->printable_rect(&width, &height);