Skip to content

Commit

Permalink
Move some checks in alphabetical order. Backported from 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 25, 2025
1 parent c8994cb commit 7f5b66f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
24 changes: 18 additions & 6 deletions generic/tkButton.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,12 +1097,6 @@ ConfigureButton(
} else {
Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder);
}
if (butPtr->wrapLength < 0) {
butPtr->wrapLength = 0;
Tcl_DecrRefCount(butPtr->wrapLengthPtr);
butPtr->wrapLengthPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->wrapLengthPtr);
}
if (butPtr->borderWidth < 0) {
butPtr->borderWidth = 0;
Tcl_DecrRefCount(butPtr->borderWidthPtr);
Expand All @@ -1127,6 +1121,12 @@ ConfigureButton(
butPtr->padYPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->padYPtr);
}
if (butPtr->wrapLength < 0) {
butPtr->wrapLength = 0;
Tcl_DecrRefCount(butPtr->wrapLengthPtr);
butPtr->wrapLengthPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->wrapLengthPtr);
}

if (butPtr->type >= TYPE_CHECK_BUTTON) {
Tcl_Obj *valuePtr, *namePtr;
Expand Down Expand Up @@ -1299,6 +1299,18 @@ ConfigureButton(
goto heightError;
}
}
if (butPtr->width < 0) {
butPtr->width = 0;
Tcl_DecrRefCount(butPtr->widthPtr);
butPtr->widthPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->widthPtr);
}
if (butPtr->height < 0) {
butPtr->height = 0;
Tcl_DecrRefCount(butPtr->heightPtr);
butPtr->heightPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->heightPtr);
}
break;
}
if (!error) {
Expand Down
10 changes: 5 additions & 5 deletions generic/tkFrame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,15 +1042,12 @@ ConfigureFrame(
Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None);
}

if (framePtr->width < 0) {
framePtr->width = 0;
if (framePtr->borderWidth < 0) {
framePtr->borderWidth = 0;
}
if (framePtr->height < 0) {
framePtr->height = 0;
}
if (framePtr->borderWidth < 0) {
framePtr->borderWidth = 0;
}
if (framePtr->highlightWidth < 0) {
framePtr->highlightWidth = 0;
}
Expand All @@ -1066,6 +1063,9 @@ ConfigureFrame(
framePtr->padYObj = Tcl_NewIntObj(0);
Tcl_IncrRefCount(framePtr->padYObj);
}
if (framePtr->width < 0) {
framePtr->width = 0;
}

/*
* If a -labelwidget is specified, check that it is valid and set up
Expand Down
6 changes: 3 additions & 3 deletions generic/tkMessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,6 @@ ConfigureMessage(
* be specified to Tk_ConfigureWidget.
*/

if (msgPtr->width < 0) {
msgPtr->width = 0;
}
if (msgPtr->borderWidth < 0) {
msgPtr->borderWidth = 0;
}
Expand Down Expand Up @@ -521,6 +518,9 @@ ConfigureMessage(
Tcl_IncrRefCount(msgPtr->padYObj);
}
}
if (msgPtr->width < 0) {
msgPtr->width = 0;
}

Tk_FreeSavedOptions(&savedOptions);
MessageWorldChanged(msgPtr);
Expand Down

0 comments on commit 7f5b66f

Please sign in to comment.