Beispiel #1
0
BOOL COleLinkingDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	ASSERT_VALID(this);

	// always register the document before opening it
	Revoke();
	if (!RegisterIfServerAttached(lpszPathName, FALSE))
	{
		// always output a trace (it is just an FYI -- not generally fatal)
		TRACE(traceOle, 0, _T("Warning: Unable to register moniker '%s' as running\n"), lpszPathName);
	}

	if (!COleDocument::OnOpenDocument(lpszPathName))
	{
		Revoke();
		return FALSE;
	}

	// if the app was started only to print, don't set user control

	CWinApp* pApp = AfxGetApp();
	ASSERT(pApp != NULL);
	if (pApp->m_pCmdInfo == NULL ||
		(pApp->m_pCmdInfo->m_nShellCommand != CCommandLineInfo::FileDDE &&
		 pApp->m_pCmdInfo->m_nShellCommand != CCommandLineInfo::FilePrint))
	{
		AfxOleSetUserCtrl(TRUE);
	}

	return TRUE;
}
Beispiel #2
0
void COleLinkingDoc::LockExternal(BOOL bLock, BOOL bRemoveRefs)
{
	// when an item binding is successful, the original document
	//  is released.  To keep it alive and the RPC stubs that make
	//  it available to the external world (via the running object
	//  table), we need to place a lock on it.

	// a lock created with CoLockObjectExternal adds a reference
	//  to the object itself (with IUnknown::AddRef) as well
	//  as keeping the RPC stub alive.

	::CoLockObjectExternal((LPUNKNOWN)GetInterface(&IID_IUnknown),
		bLock, bRemoveRefs);

	if (bLock)
	{
		// avoid "dead" objects in the running object table (ROT), by
		//  re-registering this object in the ROT.
		if (!m_strPathName.IsEmpty())
		{
			Revoke();
			RegisterIfServerAttached(m_strPathName, FALSE);
		}
	}
}
Beispiel #3
0
void COleLinkingDoc::OnCloseDocument()
{
	InternalAddRef();   // protect document during shutdown

	// update lock count before sending notifications
	UpdateVisibleLock(FALSE, FALSE);

	Revoke();   // cleanup naming support

	// remove visible lock if present
	if (m_bVisibleLock)
	{
		m_bVisibleLock = FALSE;
		LockExternal(FALSE, FALSE);
	}

	// cleanup the document but don't delete yet
	BOOL bAutoDelete = m_bAutoDelete;
	m_bAutoDelete = FALSE;
	COleDocument::OnCloseDocument();
	ASSERT_VALID(this);

	// remove extra reference count and destroy
	InterlockedDecrement(&m_dwRef);
	if (bAutoDelete)
		delete this;    // now safe to destroy document
}
Beispiel #4
0
BOOL COleLinkingDoc::OnNewDocument()
{
	ASSERT_VALID(this);

	Revoke();
	RegisterIfServerAttached(NULL, TRUE);

	if (!COleDocument::OnNewDocument())
		return FALSE;

	AfxOleSetUserCtrl(TRUE);

	return TRUE;
}
Beispiel #5
0
COleDropTarget::~COleDropTarget()
{
	AFX_BEGIN_DESTRUCTOR

	ASSERT_VALID(this);

	if (m_hWnd != NULL)
	{
		TRACE(traceOle, 0, "COleDropTarget::Revoke not called before destructor --\n");
		TRACE(traceOle, 0, "\tmay cause RIPs under debug Windows.\n");
		Revoke();
	}

	AFX_END_DESTRUCTOR
}
Beispiel #6
0
BOOL COleLinkingDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
	ASSERT_VALID(this);

	BOOL bRemember = m_bRemember;
	if (!COleDocument::OnSaveDocument(lpszPathName))
		return FALSE;

	if (bRemember && (m_strMoniker != lpszPathName))
	{
		// update the moniker/registration since the name has changed
		Revoke();
		RegisterIfServerAttached(lpszPathName, TRUE);
	}
	return TRUE;
}
Beispiel #7
0
COleLinkingDoc::~COleLinkingDoc()
{
	AFX_BEGIN_DESTRUCTOR

		ASSERT_VALID(this);

		ASSERT(!m_bVisibleLock);

		DisconnectViews();
		ASSERT(m_viewList.IsEmpty());

		Revoke();   // cleanup naming support

		ExternalDisconnect();

	AFX_END_DESTRUCTOR
}
Beispiel #8
0
COleObjectFactory::~COleObjectFactory()
{
	ASSERT_VALID(this);

#ifdef _AFXDLL
	if (m_pModuleState == NULL)
		return;
#endif

	// deregister this class factory
	Revoke();

	// remove this class factory from the list of active class factories
#ifdef _AFXDLL
	AFX_MODULE_STATE* pModuleState = m_pModuleState;
#else
	AFX_MODULE_STATE* pModuleState = _AFX_CMDTARGET_GETSTATE();
#endif
	AfxLockGlobals(CRIT_OBJECTFACTORYLIST);
	BOOL bResult = pModuleState->m_factoryList.Remove(this);
	AfxUnlockGlobals(CRIT_OBJECTFACTORYLIST);
	if (bResult)
		return;

	// check CDynLinkLibrary objects in case it was transfered during init
#ifdef _AFXDLL
	AfxLockGlobals(CRIT_DYNLINKLIST);
	for (CDynLinkLibrary* pDLL = pModuleState->m_libraryList; pDLL != NULL;
		pDLL = pDLL->m_pNextDLL)
	{
		if (pDLL->m_factoryList.Remove(this))
		{
			AfxUnlockGlobals(CRIT_DYNLINKLIST);
			return;
		}
	}
	AfxUnlockGlobals(CRIT_DYNLINKLIST);
#endif
}
Beispiel #9
0
Provider::~Provider()
{
	if(Providing())
		Revoke();
}
Beispiel #10
0
void CAI_FreePass::Update( )
{
	CBaseEntity *pTarget = GetPassTarget();
	if ( !pTarget || m_Params.duration < 0.1 )
		return;

	//---------------------------------
	//
	// Free pass logic
	//
	AI_EnemyInfo_t *pTargetInfo = GetOuter()->GetEnemies()->Find( pTarget );

	// This works with old data because need to do before base class so as to not choose as enemy
	if ( !HasPass() )
	{
		float timePlayerLastSeen = (pTargetInfo) ? pTargetInfo->timeLastSeen : AI_INVALID_TIME;
		float lastTimeDamagedBy = (pTargetInfo) ? pTargetInfo->timeLastReceivedDamageFrom : AI_INVALID_TIME;

		if ( timePlayerLastSeen == AI_INVALID_TIME || gpGlobals->curtime - timePlayerLastSeen > .15 ) // If didn't see the player last think
		{
			trace_t tr;
			UTIL_TraceLine( pTarget->EyePosition(), GetOuter()->EyePosition(), MASK_OPAQUE, GetOuter(), COLLISION_GROUP_NONE, &tr );
			if ( tr.fraction != 1.0 && tr.m_pEnt != pTarget )
			{
				float dist = (tr.endpos - tr.startpos).Length() * tr.fraction;

				if ( dist < m_Params.coverDist )
				{
					if ( ( timePlayerLastSeen == AI_INVALID_TIME || gpGlobals->curtime - timePlayerLastSeen > m_Params.timeToTrigger ) &&
						 ( lastTimeDamagedBy == AI_INVALID_TIME || gpGlobals->curtime - lastTimeDamagedBy > m_Params.timeToTrigger ) )
					{
						m_FreePassTimeRemaining = m_Params.duration;
						m_FreePassMoveMonitor.SetMark( pTarget, m_Params.moveTolerance );
					}
				}
			}
		}
	}
	else
	{
		float temp = m_FreePassTimeRemaining;
		m_FreePassTimeRemaining = 0;
		CAI_Senses *pSenses = GetOuter()->GetSenses();
		bool bCanSee = ( pSenses && pSenses->ShouldSeeEntity( pTarget ) && pSenses->CanSeeEntity( pTarget ) );
		m_FreePassTimeRemaining = temp;

		if ( bCanSee )
		{
			if ( !m_FreePassMoveMonitor.TargetMoved( pTarget ) )
				m_FreePassTimeRemaining -= 0.1;
			else
				Revoke( true );
		}
		else
		{
			m_FreePassTimeRemaining += 0.1 * m_Params.refillRate;
			if ( m_FreePassTimeRemaining > m_Params.duration )
				m_FreePassTimeRemaining = m_Params.duration;
			m_FreePassMoveMonitor.SetMark( pTarget, m_Params.moveTolerance );
		}
	}
}
Beispiel #11
0
CWinDropTarget::~CWinDropTarget()
{_STT();
	Revoke();
}
Beispiel #12
0
// Destructor
CSimpleDropTarget::~CSimpleDropTarget()
{
	if (m_hWndRegistered)
		Revoke();
}
Beispiel #13
0
void CDropTarget::Terminate()
{
  m_bRegistered = FALSE;
  Revoke();
}