********> bugfix.42 Author: Bill Ross Date: 7/19/99 Programs: xleap Severity: Severe on Dec Unix. Description: Crashes on close of edit windows, and when moving molecule. Cause: Dec is more rigorous in tracking memory use than others. Fix: Make the following changes to xAction.c and basics.c: ----------------------------------------------------------------------------- *** OLD xAction.c --- NEW xAction.c *************** *** 245,251 GVECTOR *gvPA, *gvPB; BOOL bInside; int iTop, iBottom, iDX, iDY, iDistSquared; ! double dFraction; BOOL bFoundOne; /* By default we found nothing */ --- 245,251 ----- GVECTOR *gvPA, *gvPB; BOOL bInside; int iTop, iBottom, iDX, iDY, iDistSquared; ! double dFraction = 0.0; BOOL bFoundOne; /* By default we found nothing */ *************** *** 1496,1502 BEGIN bGotOne = FALSE; ! *aPAtom == NULL; ActionPickAtom( tTank, *iPX, *iPY, aPAtom, &iAX, &iAY ); if ( *aPAtom != NULL ) { bGotOne = TRUE; --- 1496,1502 ----- BEGIN bGotOne = FALSE; ! *aPAtom = NULL; ActionPickAtom( tTank, *iPX, *iPY, aPAtom, &iAX, &iAY ); if ( *aPAtom != NULL ) { bGotOne = TRUE; *************** *** 1908,1913 nGVX(gvScreen) = iX; nGVY(gvScreen) = iY; X3dScreenToView( tTank->tank.x3dEngine, &gvScreen, &gvA ); nGVX(gvScreen) = tTank->tank.iActionX; --- 1908,1914 ----- nGVX(gvScreen) = iX; nGVY(gvScreen) = iY; + nGVZ(gvScreen) = 0; X3dScreenToView( tTank->tank.x3dEngine, &gvScreen, &gvA ); nGVX(gvScreen) = tTank->tank.iActionX; ----------------------------------------------------------------------------- *** OLD basics.c --- NEW basics.c *************** *** 1143,1148 static int SiaSinkStack[MAX_SINK_STACK]; static int SiNextSink = 0; /* * iCreatePrintSink --- 1143,1149 ----- static int SiaSinkStack[MAX_SINK_STACK]; static int SiNextSink = 0; + static int iCurrentPrintSink = -1; /* * iCreatePrintSink *************** *** 1195,1200 REALLOC( SsiPSinks, SINKINFOt*, SsiPSinks, sizeof(SINKINFOt)*(SiNumberOfSinks+1) ); SiNumberOfSinks++; } } --- 1196,1211 ----- REALLOC( SsiPSinks, SINKINFOt*, SsiPSinks, sizeof(SINKINFOt)*(SiNumberOfSinks+1) ); SiNumberOfSinks++; + /* + * realloc can mean that globals pointing to the + * current print sink now point to freed memory + */ + if (iCurrentPrintSink == -1) + DFATAL(("iCurrentPrintSink == -1\n")); + GcPPrefix = SsiPSinks[iCurrentPrintSink].sPrefix; + GbPrintPrefix = SsiPSinks[iCurrentPrintSink].bPrintPrefix; + GfPrintStringCallback = SsiPSinks[iCurrentPrintSink].fCallback; + GPData = SsiPSinks[iCurrentPrintSink].PData; } } *************** *** 1234,1239 } MESSAGE(( "Selecting print sink: %d\n", iHandle )); if ( SsiPSinks[iHandle].bSinkUsed ) { GcPPrefix = SsiPSinks[iHandle].sPrefix; --- 1245,1251 ----- } MESSAGE(( "Selecting print sink: %d\n", iHandle )); + iCurrentPrintSink = iHandle; if ( SsiPSinks[iHandle].bSinkUsed ) { GcPPrefix = SsiPSinks[iHandle].sPrefix; -----------------------------------------------------------------------------