Skip to content

Commit 77e38b6

Browse files
committed
Adjust TPad::Resize()
Only make sense when pad painter exists and has native funcitonality
1 parent d966c99 commit 77e38b6

1 file changed

Lines changed: 30 additions & 36 deletions

File tree

graf2d/gpad/src/TPad.cxx

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5943,49 +5943,43 @@ void TPad::ResizePad(Option_t *option)
59435943
// Coefficients to convert from canvas pixels to pad world coordinates
59445944

59455945
// Resize all sub-pads
5946-
TObject *obj;
5947-
if (!fPrimitives) fPrimitives = new TList;
5948-
TIter next(GetListOfPrimitives());
5949-
while ((obj = next())) {
5946+
if (!fPrimitives)
5947+
fPrimitives = new TList;
5948+
TIter next(GetListOfPrimitives());
5949+
while (auto obj = next()) {
59505950
if (obj->InheritsFrom(TPad::Class()))
5951-
((TPad*)obj)->ResizePad(option);
5951+
((TPad *)obj)->ResizePad(option);
59525952
}
59535953

59545954
// Reset all current sizes
59555955
if (gPad->IsBatch())
59565956
fPixmapID = 0;
5957-
else {
5958-
auto pp = GetPainter();
5959-
if (pp){
5960-
pp->SetLineWidth(-1);
5961-
pp->SetTextSize(-1);
5962-
}
5963-
// create or re-create off-screen pixmap
5964-
if (fPixmapID) {
5965-
int w = TMath::Abs(XtoPixel(fX2) - XtoPixel(fX1));
5966-
int h = TMath::Abs(YtoPixel(fY2) - YtoPixel(fY1));
5967-
//protection in case of wrong pad parameters.
5968-
//without this protection, the OpenPixmap or ResizePixmap crashes with
5969-
//the message "Error in <RootX11ErrorHandler>: BadValue (integer parameter out of range for operation)"
5970-
//resulting in a frozen xterm
5971-
if ( !(TMath::Finite(fX1)) || !(TMath::Finite(fX2))
5972-
|| !(TMath::Finite(fY1)) || !(TMath::Finite(fY2))
5973-
|| (TMath::IsNaN(fX1)) || (TMath::IsNaN(fX2))
5974-
|| (TMath::IsNaN(fY1)) || (TMath::IsNaN(fY2)))
5975-
Warning("ResizePad", "Inf/NaN propagated to the pad. Check drawn objects.");
5976-
if (w <= 0 || w > 10000) {
5977-
Warning("ResizePad", "%s width changed from %d to %d\n",GetName(),w,10);
5978-
w = 10;
5979-
}
5980-
if (h <= 0 || h > 10000) {
5981-
Warning("ResizePad", "%s height changed from %d to %d\n",GetName(),h,10);
5982-
h = 10;
5983-
}
5984-
if (fPixmapID == -1) { // this case is handled via the ctor
5985-
if (pp)
5957+
else if (auto pp = GetPainter()) {
5958+
if (pp->IsNative()) {
5959+
pp->SetLineWidth(-1);
5960+
pp->SetTextSize(-1);
5961+
// create or re-create off-screen pixmap
5962+
if (fPixmapID) {
5963+
int w = TMath::Abs(XtoPixel(fX2) - XtoPixel(fX1));
5964+
int h = TMath::Abs(YtoPixel(fY2) - YtoPixel(fY1));
5965+
//protection in case of wrong pad parameters.
5966+
//without this protection, the OpenPixmap or ResizePixmap crashes with
5967+
//the message "Error in <RootX11ErrorHandler>: BadValue (integer parameter out of range for operation)"
5968+
//resulting in a frozen xterm
5969+
if (!TMath::Finite(fX1) || !TMath::Finite(fX2) || !TMath::Finite(fY1) || !TMath::Finite(fY2) ||
5970+
TMath::IsNaN(fX1) || TMath::IsNaN(fX2) || TMath::IsNaN(fY1) || TMath::IsNaN(fY2))
5971+
Warning("ResizePad", "Inf/NaN propagated to the pad. Check drawn objects.");
5972+
if (w <= 0 || w > 10000) {
5973+
Warning("ResizePad", "%s width changed from %d to %d\n",GetName(),w,10);
5974+
w = 10;
5975+
}
5976+
if (h <= 0 || h > 10000) {
5977+
Warning("ResizePad", "%s height changed from %d to %d\n",GetName(),h,10);
5978+
h = 10;
5979+
}
5980+
if (fPixmapID == -1) // this case is handled via the ctor
59865981
fPixmapID = pp->CreateDrawable(w, h);
5987-
} else {
5988-
if (pp && pp->ResizeDrawable(fPixmapID, w, h)) {
5982+
else if (pp->ResizeDrawable(fPixmapID, w, h)) {
59895983
Resized();
59905984
Modified(kTRUE);
59915985
}

0 commit comments

Comments
 (0)