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
This commit is contained in:
parent
425fe6ac8c
commit
f4ec7192a9
@ -31,26 +31,41 @@ Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int
|
||||
/** the constructor */
|
||||
Fl_Copy_Surface::Fl_Copy_Surface(int w, int h) : Fl_Widget_Surface(NULL) {
|
||||
platform_surface = Fl_Copy_Surface_Driver::newCopySurfaceDriver(w, h);
|
||||
driver(platform_surface->driver());
|
||||
if (platform_surface) driver(platform_surface->driver());
|
||||
}
|
||||
|
||||
Fl_Copy_Surface::~Fl_Copy_Surface() { delete platform_surface; }
|
||||
|
||||
void Fl_Copy_Surface::origin(int x, int y) {platform_surface->origin(x, y);}
|
||||
|
||||
void Fl_Copy_Surface::origin(int *x, int *y) {platform_surface->origin(x, y);}
|
||||
void Fl_Copy_Surface::origin(int *x, int *y) {
|
||||
if (platform_surface) platform_surface->origin(x, y);
|
||||
}
|
||||
|
||||
void Fl_Copy_Surface::set_current() {platform_surface->set_current();}
|
||||
void Fl_Copy_Surface::set_current() {
|
||||
if (platform_surface) platform_surface->set_current();
|
||||
}
|
||||
|
||||
void Fl_Copy_Surface::translate(int x, int y) {platform_surface->translate(x, y);}
|
||||
void Fl_Copy_Surface::translate(int x, int y) {
|
||||
if (platform_surface) platform_surface->translate(x, y);
|
||||
}
|
||||
|
||||
void Fl_Copy_Surface::untranslate() {platform_surface->untranslate();}
|
||||
void Fl_Copy_Surface::untranslate() {
|
||||
if (platform_surface) platform_surface->untranslate();
|
||||
}
|
||||
|
||||
int Fl_Copy_Surface::w() {return platform_surface->width;}
|
||||
int Fl_Copy_Surface::w() {return platform_surface ? platform_surface->width : 0;}
|
||||
|
||||
int Fl_Copy_Surface::h() {return platform_surface->height;}
|
||||
int Fl_Copy_Surface::h() {return platform_surface ? platform_surface->height : 0;}
|
||||
|
||||
int Fl_Copy_Surface::printable_rect(int *w, int *h) {return platform_surface->printable_rect(w, h);}
|
||||
int Fl_Copy_Surface::printable_rect(int *w, int *h) {
|
||||
if (platform_surface)
|
||||
return platform_surface->printable_rect(w, h);
|
||||
else {
|
||||
*w = *h = 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
@ -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);
|
||||
|
@ -72,7 +72,7 @@ int Fl_Native_File_Chooser::type() const
|
||||
*/
|
||||
void Fl_Native_File_Chooser::options(int o)
|
||||
{
|
||||
platform_fnfc->options(o);
|
||||
if (platform_fnfc) platform_fnfc->options(o);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#ifdef FL_PORTING
|
||||
# pragma message "FL_PORTING: implement print support for your platform, or define NO_PRINT_SUPPORT"
|
||||
#define NO_PRINT_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#if defined(NO_PRINT_SUPPORT)
|
||||
|
@ -574,12 +574,14 @@ void copy(Fl_Widget *, void *data) {
|
||||
Fl_Image *img = rgb_surf->highres_image();
|
||||
delete rgb_surf;
|
||||
Fl_Display_Device::display_device()->set_current();
|
||||
Fl_Window* g2 = new Fl_Window(img->w()+10, img->h()+10);
|
||||
g2->color(FL_YELLOW);
|
||||
Fl_Box *b = new Fl_Box(FL_NO_BOX,5,5,img->w(), img->h(),0);
|
||||
b->image(img);
|
||||
g2->end();
|
||||
g2->show();
|
||||
if (img) {
|
||||
Fl_Window* g2 = new Fl_Window(img->w()+10, img->h()+10);
|
||||
g2->color(FL_YELLOW);
|
||||
Fl_Box *b = new Fl_Box(FL_NO_BOX,5,5,img->w(), img->h(),0);
|
||||
b->image(img);
|
||||
g2->end();
|
||||
g2->show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user