summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-03-07 14:16:26 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-03-07 14:16:26 (GMT)
commit1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6 (patch)
treef8212c5e60edf4d0f1cd2de335836b8c83dad5a2
parentc7743f2ce4ec3fec9d6ea18f1edb649f89085448 (diff)
downloadtk-1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6.zip
tk-1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6.tar.gz
tk-1315c522b0ca1b7e4ebb733c2bfbf4290ac3ecb6.tar.bz2
* generic/tkObj.c (GetPixelsFromObjEx): [Bug 3497848]: Better rounding
of pixel values to integers.
-rw-r--r--ChangeLog9
-rw-r--r--generic/tkObj.c8
2 files changed, 9 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 63f52e9..6afbfb5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-07 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tkObj.c (GetPixelsFromObjEx): [Bug 3497848]: Better rounding
+ of pixel values to integers.
+
2012-03-04 Jan Nijtmans <nijtmans@users.sf.net>
* unix/tcl.m4: Patch from the cygwin folks
@@ -5,11 +10,11 @@
2012-02-28 Francois Vogel <fvogelnew1@free.fr>
- * generic/tkText.c: [Bug-1630262], [Bug-1615425]: segfault
+ * generic/tkText.c: [Bug 1630262, Bug 1615425]: segfault
* generic/tkTextBTree.c when deleting lines or tagging outside of
* generic/tkTextDisp.c the -startline/-endline range with peer
* generic/tkTextMark.c text widgets.
- * tests/text.test [Bug-3487407]: Weird text indices.
+ * tests/text.test [Bug 3487407]: Weird text indices.
* tests/textMark.test
2012-02-28 Donal K. Fellows <dkf@users.sf.net>
diff --git a/generic/tkObj.c b/generic/tkObj.c
index 4c8516e..b9c4f02 100644
--- a/generic/tkObj.c
+++ b/generic/tkObj.c
@@ -211,7 +211,7 @@ GetPixelsFromObjEx(
if (dblPtr != NULL) {
*dblPtr = d;
}
- *intPtr = (int) d;
+ *intPtr = (int) (d<0 ? d-0.5 : d+0.5);
return TCL_OK;
} else if (objPtr->typePtr == tsdPtr->intTypePtr) {
(void) Tcl_GetIntFromObj(interp, objPtr, intPtr);
@@ -255,11 +255,7 @@ GetPixelsFromObjEx(
d *= bias[pixelPtr->units] * WidthOfScreen(Tk_Screen(tkwin));
d /= WidthMMOfScreen(Tk_Screen(tkwin));
}
- if (d < 0) {
- pixelPtr->returnValue = (int) (d - 0.5);
- } else {
- pixelPtr->returnValue = (int) (d + 0.5);
- }
+ pixelPtr->returnValue = (int) (d<0 ? d-0.5 : d+0.5);
pixelPtr->tkwin = tkwin;
if (dblPtr) {
*dblPtr=(double)d;