1 diff --git basic/source/runtime/runtime.cxx basic/source/runtime/runtime.cxx
2 index 5cec3e2..69c75b3 100644
3 --- basic/source/runtime/runtime.cxx
4 +++ basic/source/runtime/runtime.cxx
6 #include "sbunoobj.hxx"
7 #include "errobject.hxx"
9 +SbxVariable* getDefaultProp( SbxVariable* pRef );
11 bool SbiRuntime::isVBAEnabled()
14 @@ -961,7 +963,25 @@ SbxVariable* SbiRuntime::GetTOS( short n
15 void SbiRuntime::TOSMakeTemp()
17 SbxVariable* p = refExprStk->Get( nExprLvl - 1 );
18 - if( p->GetRefCount() != 1 )
19 + if ( p->GetType() == SbxEMPTY )
20 + p->Broadcast( SBX_HINT_DATAWANTED );
22 + SbxVariable* pDflt = NULL;
23 + if ( bVBAEnabled && ( p->GetType() == SbxOBJECT || p->GetType() == SbxVARIANT ) && ( pDflt = getDefaultProp( p ) ) )
25 + pDflt->Broadcast( SBX_HINT_DATAWANTED );
26 + // replacing new p on stack causes object pointed by
27 + // pDft->pParent to be deleted, when p2->Compute() is
28 + // called below pParent is accessed ( but its deleted )
29 + // so set it to NULL now
30 + pDflt->SetParent( NULL );
31 + p = new SbxVariable( *pDflt );
32 + p->SetFlag( SBX_READWRITE );
33 + refExprStk->Put( p, nExprLvl - 1 );
37 + else if( p->GetRefCount() != 1 )
39 SbxVariable* pNew = new SbxVariable( *p );
40 pNew->SetFlag( SBX_READWRITE );
41 @@ -970,7 +990,6 @@ void SbiRuntime::TOSMakeTemp()
44 // Der GOSUB-Stack nimmt Returnadressen fuer GOSUBs auf
46 void SbiRuntime::PushGosub( const BYTE* pc )
48 if( ++nGosubLvl > MAXRECURSION )
49 diff --git basic/source/runtime/step0.cxx basic/source/runtime/step0.cxx
50 index cbd2fad..0666725 100644
51 --- basic/source/runtime/step0.cxx
52 +++ basic/source/runtime/step0.cxx
53 @@ -59,34 +59,6 @@ void SbiRuntime::StepArith( SbxOperator
55 SbxVariable* p2 = GetTOS();
58 - // This could & should be moved to the MakeTempTOS() method in runtime.cxx
59 - // In the code which this is cut'npaste from there is a check for a ref
60 - // count != 1 based on which the copy of the SbxVariable is done.
61 - // see orig code in MakeTempTOS ( and I'm not sure what the significance,
63 - // here we alway seem to have a refcount of 1. Also it seems that
64 - // MakeTempTOS is called for other operation, so I hold off for now
65 - // until I have a better idea
67 - && ( p2->GetType() == SbxOBJECT || p2->GetType() == SbxVARIANT )
70 - SbxVariable* pDflt = getDefaultProp( p2 );
73 - pDflt->Broadcast( SBX_HINT_DATAWANTED );
74 - // replacing new p2 on stack causes object pointed by
75 - // pDft->pParent to be deleted, when p2->Compute() is
76 - // called below pParent is accessed ( but its deleted )
77 - // so set it to NULL now
78 - pDflt->SetParent( NULL );
79 - p2 = new SbxVariable( *pDflt );
80 - p2->SetFlag( SBX_READWRITE );
81 - refExprStk->Put( p2, nExprLvl - 1 );
85 p2->ResetFlag( SBX_FIXED );
86 p2->Compute( eOp, *p1 );