Hi there,
I currently am updating some programs used to visualize factory floor
process information at our site from 0.89.9 to 0.91.4. During that I
came to some minor changes I had to do, to get these running stable.
A patch file for vanilla 0.91.4 is included. Here are the main areas
I touched, and some reasoning about them:
1. lib/Xm/List.c
Performance gains while updating undisplayed items. I checked this
very seriously and didn't find any argument against it. It removes
nearly all flicker while updating large lists (that are mostly off
screen) and it is fairly small change.
2. lib/Xm/Text.c
ensure that subscripts are valid (even though they should already
be, our programs manages to core dump occasionaly here). Adding some
trivial tests, that have no real impact on performance but make
(at least our) programs a lot more stable.
3. lib/Xm/String.c
ensure memory gets freed only if it has been allocated. This seems
to be a rare event, but sometimes it crashes our programs. The check
is trivial, and no real impact on performance was seen.
Ok, this is it. I hope you will be able to incorporate these changes to
the lesstif library, which is, in fact a real good piece of software, that
helps a lot to do my day-to-day work.
Best regards
+-------------------------------------+-------------------------------+
| Peter Stein | |
| technische Datenverarbeitung (TB4) | Tel: (+49) (0) 5524-82 415 |
| DETA Akkumulatorenwerke GmbH | Fax: (+49) (0) 5524-82 439 |
| Odertal 35 | e-mail: [EMAIL PROTECTED] |
| 37431 Bad Lauterberg | [EMAIL PROTECTED] |
+-------------------------------------+-------------------------------+
Der Author erklaert sich fuer nicht richtungsweisend in allen Belangen
der deutschen Grammatik, Orthographie und Interpunktion !
Author denies any authority in respect to grammar, orthography and
punctuation of written material !
diff -r -b -B --context=4 --ignore-blank-lines -p -P --exclude-from=diff-exclude
lesstif-0.91.4/lib/Xm/List.c lesstif-0.91.4-deta/lib/Xm/List.c
*** lesstif-0.91.4/lib/Xm/List.c Sun Jun 25 11:26:03 2000
--- lesstif-0.91.4-deta/lib/Xm/List.c Tue Aug 1 07:31:35 2000
*************** XmListReplaceItems(Widget w, XmString *o
*** 5445,5452 ****
--- 5445,5457 ----
void
XmListReplaceItemsPos(Widget w, XmString *new_items, int item_count, int position)
{
int i, j = (position ? position : List_ItemCount(w)) - 1;
+ /* Peter Stein 31 July 2000
+ needed to get rid of flicker while updating
+ display
+ */
+ Boolean need_refresh = False;
DEBUGOUT(XdbDebug(__FILE__, w, "XmListReplaceItemsPos(%d)\n", j));
/* rws 22 May 1998
*************** XmListReplaceItemsPos(Widget w, XmString
*** 5456,5463 ****
--- 5461,5472 ----
*/
for (i = 0; i < item_count && j < List_ItemCount(w); ++i)
{
(void)_XmListDeselectPos(w, j + 1);
+ if( ((j+1) >=List_TopPosition(w))
+ && ( (j+1) <=List_TopPosition(w)+List_VisibleItemCount(w)-1)){
+ need_refresh = True; /* Peter Stein: a
+visible item is changed */
+ }
#ifdef OLD_31_OCT
XmStringFree(List_Items(w)[j]);
List_Items(w)[j] = XmStringCopy(new_items[i]);
*************** XmListReplaceItemsPos(Widget w, XmString
*** 5480,5496 ****
* This is needed because the width of the list may need to
* be changed.
*/
_XmListSetGeometryIfNeeded(w);
!
_XmListRedraw(w, True);
}
void
XmListReplaceItemsPosUnselected(Widget w, XmString *new_items, int item_count,
int position)
{
int i;
DEBUGOUT(XdbDebug(__FILE__, w, "XmListReplaceItemsPosUnselected()\n"));
if (!position)
--- 5489,5514 ----
* This is needed because the width of the list may need to
* be changed.
*/
_XmListSetGeometryIfNeeded(w);
! /* Peter Stein 31 July 2000
! do redraw only if display is actualy changed
! */
! if( need_refresh ){
_XmListRedraw(w, True);
+ }
+
}
void
XmListReplaceItemsPosUnselected(Widget w, XmString *new_items, int item_count,
int position)
{
int i;
+ /* Peter Stein 31 July 2000
+ optimize redisplay (like XmListReplaceItemsPos() above
+ */
+ Boolean need_refresh = False;
DEBUGOUT(XdbDebug(__FILE__, w, "XmListReplaceItemsPosUnselected()\n"));
if (!position)
*************** XmListReplaceItemsPosUnselected(Widget w
*** 5500,5507 ****
--- 5518,5529 ----
for (i = 0; i < item_count && position <= List_ItemCount(w); i++, position++)
{
(void)_XmListDeselectPos(w, position);
+ if( (position >=List_TopPosition(w))
+ && ( position <=List_TopPosition(w)+List_VisibleItemCount(w)-1)){
+ need_refresh = True; /* Peter Stein: a
+visible item is changed */
+ }
#ifdef OLD_31_OCT
XmStringFree(List_Items(w)[position - 1]);
List_Items(w)[position - 1] = XmStringCopy(new_items[i]);
*************** XmListReplaceItemsPosUnselected(Widget w
*** 5510,5518 ****
--- 5532,5546 ----
#endif
}
_XmListSetGeometryIfNeeded(w);
+ /* Peter Stein 31 Jul 2000
+ Do redraw only if necessary
+ */
+ if( need_refresh ){
_XmListRedraw(w, True);
+ }
+
}
void
XmListReplaceItemsUnselected(Widget w, XmString *old_items, int item_count, XmString
*new_items)
*************** XmListReplaceItemsUnselected(Widget w, X
*** 5550,5563 ****
--- 5578,5601 ----
void
XmListReplacePositions(Widget w, int *position_list, XmString *item_list, int
item_count)
{
int i, j;
+ /* Peter Stein 31 July 2000
+ optimize redisplay (like XmListReplaceItemsPos() above
+ */
+ Boolean need_refresh = False;
DEBUGOUT(XdbDebug(__FILE__, w, "XmListReplacePosition()\n"));
for (i = 0; i < item_count; ++i)
{
j = (position_list[i] ? position_list[i] : List_ItemCount(w)) - 1;
+ /* Peter Stein 31 July 2000:
+ optimize redisplay
+ */
+ if( (j >=List_TopPosition(w)) && ( j
+<=List_TopPosition(w)+List_VisibleItemCount(w)-1)){
+ need_refresh = True; /* a visible item is
+changed */
+ }
(void)_XmListDeselectPos(w, j);
if (position_list[i] > List_ItemCount(w))
*************** XmListReplacePositions(Widget w, int *po
*** 5577,5585 ****
--- 5615,5628 ----
}
}
_XmListSetGeometryIfNeeded(w);
+ /* Peter Stein 31 July 2000:
+ optimize redisplay
+ */
+ if( need_refresh ){
_XmListRedraw(w, True);
+ }
}
void
XmListSelectItem(Widget w, XmString item, Boolean notify)
diff -r -b -B --context=4 --ignore-blank-lines -p -P --exclude-from=diff-exclude
lesstif-0.91.4/lib/Xm/Text.c lesstif-0.91.4-deta/lib/Xm/Text.c
*** lesstif-0.91.4/lib/Xm/Text.c Sat May 20 17:46:14 2000
--- lesstif-0.91.4-deta/lib/Xm/Text.c Mon Jul 31 14:47:20 2000
*************** _XmTextInvalidate(XmTextWidget w, XmText
*** 1744,1754 ****
if (i >= Text_LineCount(w))
{
return;
}
!
Text_Line(w)[i - 1].changed = True;
Text_Line(w)[i - 1].changed_position = position;
(*Text_Output(w)->Invalidate) (w, position, topos, delta);
(*Text_Input(w)->Invalidate) (w, position, topos, delta);
}
--- 1744,1759 ----
if (i >= Text_LineCount(w))
{
return;
}
! /* Peter Stein 31 Jul 2000
! ensure valid subscript (I don't know how, but it happens
! and core-dumps ...
! */
! if( i > 0 ){
Text_Line(w)[i - 1].changed = True;
Text_Line(w)[i - 1].changed_position = position;
+ }
(*Text_Output(w)->Invalidate) (w, position, topos, delta);
(*Text_Input(w)->Invalidate) (w, position, topos, delta);
}
diff -r -b -B --context=4 --ignore-blank-lines -p -P --exclude-from=diff-exclude
lesstif-0.91.4/lib/Xm/XmString.c lesstif-0.91.4-deta/lib/Xm/XmString.c
*** lesstif-0.91.4/lib/Xm/XmString.c Tue Jun 27 12:55:17 2000
--- lesstif-0.91.4-deta/lib/Xm/XmString.c Mon Jul 31 15:31:46 2000
*************** _XmStringFree(_XmString string)
*** 1212,1219 ****
--- 1212,1224 ----
return;
for (i = 0; i < string->number_of_components; i++)
{
+ /* Peter Stein, 07/2000 */
+ /* in some wired circumstances this may not be the case */
+ /* leading to a crash */
+ if (string->components[i] != NULL )
+ {
if (string->components[i]->data /*&&
string->components[i]->length*/)
{
/* rws 30 Aug 1998
If we only free this if the length is greater than 0 we end
*************** _XmStringFree(_XmString string)
*** 1221,1233 ****
of 0 but there has been space allocated for it.
*/
XtFree((char *)string->components[i]->data);
}
-
XtFree((char *)string->components[i]);
}
XtFree((char *)string->components);
XtFree((char *)string);
}
char *
--- 1226,1245 ----
of 0 but there has been space allocated for it.
*/
XtFree((char *)string->components[i]->data);
}
XtFree((char *)string->components[i]);
}
+ }
+ if( string->number_of_components > 0 )
+ {
+
+ /* Peter Stein, 07/2000: */
+ /* initialisation in __XmAllocNewXmString() */
+ /* only done in this case */
+ /* so free should also only happen than*/
XtFree((char *)string->components);
+ }
XtFree((char *)string);
}
char *