Update of /cvsroot/plib/plib/src/pui
In directory sc8-pr-cvs1:/tmp/cvs-serv11817
Modified Files:
puInput.cxx puGroup.cxx
Log Message:
Patch from John Fay:
* The patch to "puInput.cxx" takes care of a case in which the input is being passed an empty string. Without this patch, "new_len" gets decremented to -1 on line 48 and then on line 58 bad things could happen.
* The patch to "puGroup.cxx" adds a new function to remove a group from the middle of the stack. Without it, when my application creates and destroys windows in random order bad things happen to the group stack.
Index: puInput.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puInput.cxx,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- puInput.cxx 7 Feb 2003 16:04:24 -0000 1.32
+++ puInput.cxx 12 Nov 2003 19:02:02 -0000 1.33
@@ -34,24 +34,32 @@
int n = 0 ;
int w ;
- do
+ if ( new_len == 0 )
{
- memcpy ( res, s + n, new_len + 1 ) ;
- n++ ;
- new_len -- ;
- w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ;
- } while ( ( w >= width ) && ( n < cursor_position - 1 ) ) ;
+ *res = '\0' ;
+ if ( ncut != NULL ) *ncut = 0 ;
+ }
+ else
+ {
+ do
+ {
+ memcpy ( res, s + n, new_len + 1 ) ;
+ n++ ;
+ new_len -- ;
+ w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ;
+ } while ( ( w >= width ) && ( n < cursor_position - 1 ) ) ;
- if ( ncut != NULL ) *ncut = n - 1 ;
+ if ( ncut != NULL ) *ncut = n - 1 ;
- n = 0 ;
+ n = 0 ;
- while ( w >= width )
- {
- res[new_len] = '\0' ;
- n++ ;
- new_len -- ;
- w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ;
+ while ( w >= width )
+ {
+ res[new_len] = '\0' ;
+ n++ ;
+ new_len -- ;
+ w = fnt.getStringWidth ( res ) + 2 * PUSTR_RGAP + PUSTR_LGAP ;
+ }
}
return res ;
Index: puGroup.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/pui/puGroup.cxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- puGroup.cxx 7 Feb 2003 17:01:03 -0000 1.25
+++ puGroup.cxx 12 Nov 2003 19:02:03 -0000 1.26
@@ -49,6 +49,28 @@
ulSetError ( UL_WARNING, "PUI: puGroup stack is empty!" ) ;
}
+void puRemoveGroup ( puGroup *gr )
+{
+ int index = currGroup ;
+ while ( index >= 0 )
+ {
+ if ( groupStack [ index ] == gr )
+ {
+ int jndx ;
+ for ( jndx = index; jndx < currGroup - 1; jndx ++ )
+ groupStack [ jndx ] = groupStack [ jndx + 1 ] ;
+
+ currGroup -- ;
+ return ;
+ }
+
+ index -- ;
+ }
+
+ ulSetError ( UL_WARNING, "PUI: Trying to remove invalid puGroup from puGroup stack!" ) ;
+}
+
+
int puNoGroup ( void )
{
return currGroup < 0 ;
@@ -351,6 +373,8 @@
puGroup::~puGroup ()
{
void puCleanUpJunk ( void ) ;
+
+ puRemoveGroup ( this ) ;
puObject *bo = getLastChild () ;
|