summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2011-05-29 16:29:09 +0000
committerManolo Gouy <Manolo>2011-05-29 16:29:09 +0000
commit493accc9057b38220fac3330fbf78e278fc3fa18 (patch)
treeb51270a00017172950ae2c6cf5627b3f38a582b2
parent76454cb77bacee054c5e763fa6a8472a5be90cab (diff)
Attempt to fix STR #2648 by testing all X-API return codes.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8753 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_x.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 77431676b..61b3082b4 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -1998,17 +1998,23 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
if (win->parent() || !win->border()) {
this->print_widget(win, x_offset, y_offset);
return;
- }
+ }
Fl_Display_Device::display_device()->set_current();
win->show();
Fl::check();
win->make_current();
Window root, parent, *children, child_win, from;
- unsigned n;
- int bx, bt;
+ unsigned n = 0;
+ int bx, bt, do_it;
from = fl_window;
- XQueryTree(fl_display, fl_window, &root, &parent, &children, &n); if (n) XFree(children);
- XTranslateCoordinates(fl_display, fl_window, parent, 0, 0, &bx, &bt, &child_win);
+ do_it = (XQueryTree(fl_display, fl_window, &root, &parent, &children, &n) != 0 &&
+ XTranslateCoordinates(fl_display, fl_window, parent, 0, 0, &bx, &bt, &child_win) == True);
+ if (n) XFree(children);
+ if (!do_it) {
+ this->set_current();
+ this->print_widget(win, x_offset, y_offset);
+ return;
+ }
fl_window = parent;
uchar *top_image = 0, *left_image = 0, *right_image = 0, *bottom_image = 0;
top_image = fl_read_image(NULL, 0, 0, - (win->w() + 2 * bx), bt);
@@ -2032,7 +2038,6 @@ void Fl_Paged_Device::print_window(Fl_Window *win, int x_offset, int y_offset)
this->print_widget( win, x_offset + bx, y_offset + bt );
}
-
#ifdef USE_PRINT_BUTTON
// to test the Fl_Printer class creating a "Print front window" button in a separate window
// contains also preparePrintFront call above