Lines 330-335
Link Here
|
330 |
if( pModel ) |
330 |
if( pModel ) |
331 |
EndListening( *pModel ); |
331 |
EndListening( *pModel ); |
332 |
|
332 |
|
|
|
333 |
if ( pObj ) |
334 |
{ |
335 |
pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); |
336 |
pObj = NULL; |
337 |
} |
338 |
|
333 |
if( mpImpl ) |
339 |
if( mpImpl ) |
334 |
{ |
340 |
{ |
335 |
if(mpImpl->mpMaster) |
341 |
if(mpImpl->mpMaster) |
Lines 436-441
Link Here
|
436 |
} |
442 |
} |
437 |
|
443 |
|
438 |
//---------------------------------------------------------------------- |
444 |
//---------------------------------------------------------------------- |
|
|
445 |
void SvxShape::onSdrObjectDying( GrantSdrObjectAccess ) |
446 |
{ |
447 |
DBG_TESTSOLARMUTEX(); |
448 |
|
449 |
if ( m_refCount == 0 ) |
450 |
{ |
451 |
// we're currently dying, anyway. No dispose notifications, just reset the pObj |
452 |
// member so we don't access it in our dtor anymore. |
453 |
pObj = 0; |
454 |
} |
455 |
else |
456 |
{ |
457 |
dispose(); |
458 |
} |
459 |
} |
460 |
|
461 |
//---------------------------------------------------------------------- |
439 |
SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw() |
462 |
SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw() |
440 |
{ |
463 |
{ |
441 |
return getImplementation( pObj->getUnoShape() ); |
464 |
return getImplementation( pObj->getUnoShape() ); |
Lines 443-449
Link Here
|
443 |
|
466 |
|
444 |
void SvxShape::Init() throw() |
467 |
void SvxShape::Init() throw() |
445 |
{ |
468 |
{ |
446 |
if( NULL == mpImpl ) |
469 |
DBG_TESTSOLARMUTEX(); |
|
|
470 |
|
471 |
if( NULL == mpImpl ) |
447 |
{ |
472 |
{ |
448 |
mpImpl = new SvxShapeImpl; |
473 |
mpImpl = new SvxShapeImpl; |
449 |
mpImpl->mpItemSet = NULL; |
474 |
mpImpl->mpItemSet = NULL; |
Lines 463-473
Link Here
|
463 |
if(pObj == NULL) |
488 |
if(pObj == NULL) |
464 |
return; |
489 |
return; |
465 |
|
490 |
|
466 |
osl_incrementInterlockedCount( &m_refCount ); |
491 |
pObj->setUnoShape( this, SdrObject::GrantXShapeAccess() ); |
467 |
{ |
|
|
468 |
pObj->setUnoShape( *this, SdrObject::GrantXShapeAccess() ); |
469 |
} |
470 |
osl_decrementInterlockedCount( &m_refCount ); |
471 |
|
492 |
|
472 |
pModel = pObj->GetModel(); |
493 |
pModel = pObj->GetModel(); |
473 |
|
494 |
|
Lines 529-534
Link Here
|
529 |
EndListening( *pObj->GetModel() ); |
550 |
EndListening( *pObj->GetModel() ); |
530 |
} |
551 |
} |
531 |
|
552 |
|
|
|
553 |
if ( pObj ) |
554 |
pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); |
532 |
pObj = pNewObj; |
555 |
pObj = pNewObj; |
533 |
|
556 |
|
534 |
Init(); |
557 |
Init(); |
Lines 1074-1082
Link Here
|
1074 |
(pSdrHint->GetKind() != HINT_OBJCHG))) |
1097 |
(pSdrHint->GetKind() != HINT_OBJCHG))) |
1075 |
return; |
1098 |
return; |
1076 |
|
1099 |
|
1077 |
uno::Reference< uno::XInterface > xSelf( pObj->getWeakUnoShape() ); |
1100 |
DBG_TESTSOLARMUTEX(); |
|
|
1101 |
|
1102 |
if ( m_refCount == 0 ) |
1103 |
{ |
1104 |
// we're probably just blocking inside our |release| call, in another thread. |
1105 |
// Don't create the temporary reference below, this would cause a duplicate |
1106 |
// "delete this" |
1107 |
return; |
1108 |
} |
1109 |
|
1110 |
uno::Reference< uno::XInterface > xSelf( pObj->getUnoShape() ); |
1078 |
if( !xSelf.is() ) |
1111 |
if( !xSelf.is() ) |
1079 |
{ |
1112 |
{ |
|
|
1113 |
if ( pObj ) |
1114 |
pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); |
1080 |
pObj = NULL; |
1115 |
pObj = NULL; |
1081 |
return; |
1116 |
return; |
1082 |
} |
1117 |
} |
Lines 1123-1128
Link Here
|
1123 |
|
1158 |
|
1124 |
if( bClearMe ) |
1159 |
if( bClearMe ) |
1125 |
{ |
1160 |
{ |
|
|
1161 |
if ( pObj ) |
1162 |
pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); |
1126 |
pObj = NULL; |
1163 |
pObj = NULL; |
1127 |
if(!bDisposing) |
1164 |
if(!bDisposing) |
1128 |
dispose(); |
1165 |
dispose(); |
Lines 1292-1297
Link Here
|
1292 |
|
1329 |
|
1293 |
//---------------------------------------------------------------------- |
1330 |
//---------------------------------------------------------------------- |
1294 |
|
1331 |
|
|
|
1332 |
void SAL_CALL SvxShape::release() throw() |
1333 |
{ |
1334 |
Reference<XInterface > xDelegator( xDelegator ); |
1335 |
if ( xDelegator.is() ) |
1336 |
xDelegator->release(); |
1337 |
else |
1338 |
{ |
1339 |
if ( osl_decrementInterlockedCount( &m_refCount ) == 0 ) |
1340 |
{ |
1341 |
// make releasing the last reference, plus subsequent deletion of |this|, |
1342 |
// a solar-guarded transaction. Else, we might run into different race conditions |
1343 |
// if one thread releases a reference to an SvxShape, and another thread destroys |
1344 |
// the respective SdrObject, resulting in either one (SvxShape/SdrObject) accessing |
1345 |
// a dead counterpart (SdtObject/SvxShape), or an SvxShape being deleted twice du |
1346 |
// to temporary references created in thread A while thread B blocks within the |
1347 |
// dtor-chain of an SvxShape derivee. |
1348 |
OGuard aGuard( Application::GetSolarMutex() ); |
1349 |
osl_incrementInterlockedCount( &m_refCount ); |
1350 |
SvxShape_UnoImplHelper::release(); |
1351 |
} |
1352 |
} |
1353 |
} |
1354 |
|
1355 |
//---------------------------------------------------------------------- |
1356 |
|
1295 |
// XNamed |
1357 |
// XNamed |
1296 |
OUString SAL_CALL SvxShape::getName( ) throw(::com::sun::star::uno::RuntimeException) |
1358 |
OUString SAL_CALL SvxShape::getName( ) throw(::com::sun::star::uno::RuntimeException) |
1297 |
{ |
1359 |
{ |
Lines 1351-1357
Link Here
|
1351 |
OGuard aGuard( Application::GetSolarMutex() ); |
1413 |
OGuard aGuard( Application::GetSolarMutex() ); |
1352 |
|
1414 |
|
1353 |
if( bDisposing ) |
1415 |
if( bDisposing ) |
1354 |
return; // catched a recursion |
1416 |
return; // caught a recursion |
1355 |
|
1417 |
|
1356 |
bDisposing = sal_True; |
1418 |
bDisposing = sal_True; |
1357 |
|
1419 |
|
Lines 1360-1380
Link Here
|
1360 |
aDisposeListeners.disposeAndClear(aEvt); |
1422 |
aDisposeListeners.disposeAndClear(aEvt); |
1361 |
|
1423 |
|
1362 |
SdrObject* pObj = GetSdrObject(); |
1424 |
SdrObject* pObj = GetSdrObject(); |
1363 |
if(pObj && pObj->IsInserted() && pObj->GetPage() ) |
1425 |
if ( pObj ) |
1364 |
{ |
1426 |
{ |
1365 |
SdrPage* pPage = pObj->GetPage(); |
1427 |
pObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() ); |
1366 |
// SdrObject aus der Page loeschen |
1428 |
if ( pObj->IsInserted() && pObj->GetPage() ) |
1367 |
sal_uInt32 nCount = pPage->GetObjCount(); |
1429 |
{ |
1368 |
for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ ) |
1430 |
SdrPage* pPage = pObj->GetPage(); |
1369 |
{ |
1431 |
// SdrObject aus der Page loeschen |
1370 |
if(pPage->GetObj(nNum) == pObj) |
1432 |
sal_uInt32 nCount = pPage->GetObjCount(); |
1371 |
{ |
1433 |
for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ ) |
1372 |
delete pPage->RemoveObject(nNum); |
1434 |
{ |
1373 |
InvalidateSdrObject(); |
1435 |
if(pPage->GetObj(nNum) == pObj) |
1374 |
break; |
1436 |
{ |
1375 |
} |
1437 |
delete pPage->RemoveObject(nNum); |
1376 |
} |
1438 |
InvalidateSdrObject(); |
1377 |
} |
1439 |
break; |
|
|
1440 |
} |
1441 |
} |
1442 |
} |
1443 |
this->pObj = NULL; |
1444 |
} |
1378 |
|
1445 |
|
1379 |
if( pModel ) |
1446 |
if( pModel ) |
1380 |
{ |
1447 |
{ |