bool16
CZPAMLockable::Unlock( UIFlags uiFlags, bool16 allowOverride )
#endif
{
	LogFunctionEnterExit;
	
	bool16 unlockSucceeded = kFalse;
	
	do
	{
		InterfacePtr<IManageableAsset> asset( this->QueryAsset());
		ASSERT(asset);
		
		if( !asset )
			break;
		ClassID amProviderClass = asset->GetServiceProviderClass();
		unlockSucceeded = Utils<IZPAMHelper>()->CallAMServiceDo( asset, amProviderClass, IAMServiceProvider::enCancelCheckOut );

#if defined(InDnCS5) || defined(InDnCS5_5)
		VerifyState( kSuppressUI, objectUID );
#else
		VerifyState( kSuppressUI );
#endif
		
		unlockSucceeded = fLockState != IAMLockable::enCheckedOut;
	}while (kFalse);
	
	return unlockSucceeded;
}
bool16
CZPAMLockable::HasLock()
#endif
{
	LogFunctionEnterExit;
	
	bool16 hasLock = kFalse;

#ifdef DEBUG
	IAMLockable::LockState oldCachedState = fLockState;
#endif
	//if ( fLockState == IAMLockable::enUndefined )
	
	// not yet initialized
#if defined(InDnCS5) || defined(InDnCS5_5)
	VerifyState( kSuppressUI, objectUID );
#else
	VerifyState( kSuppressUI );	
#endif

#ifdef DEBUG
	if( fLockState != oldCachedState )
		IZPLog_Str_( thisFileLA, enLT_DebugInfo, "Lock state changed from %d to %d", oldCachedState, fLockState);
#endif	
	
	if ( fLockState == IAMLockable::enCheckedOut )
	{
		hasLock = kTrue;
	}
	
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "HasLock = %s\n",(hasLock?"true":"false"));
	
	return hasLock;
}
//----------------------------------------------------------------------------------------
// IsLocked
//----------------------------------------------------------------------------------------
bool16
CZPAMLockable::IsLocked()
{
	LogFunctionEnterExit;
	
	bool16 isLocked = kFalse;
#ifdef DEBUG
	IAMLockable::LockState oldCachedState = fLockState;
#endif
	//if ( fLockState == IAMLockable::enUndefined )
	// not yet initialized
#if defined(InDnCS5) || defined(InDnCS5_5)
	VerifyState( kSuppressUI, GetLockObjectUID() );
#else
	VerifyState( kSuppressUI );	
#endif

#ifdef DEBUG
	if( fLockState != oldCachedState )
		IZPLog_Str_( thisFileLA, enLT_DebugInfo, "Lock state changed from %d to %d", oldCachedState, fLockState);
#endif	
	if ( fLockState == IAMLockable::enCheckedOut || fLockState==IAMLockable::enLocked )
	{
		isLocked =  kTrue;
	}
	
	// retrieve lock state from server?
	
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "IsLocked = %s\n",(isLocked?"true":"false"));
	
	return isLocked;
}
int
main(int argc, const char **argv)
{
	set_debug_flags(NULL, D_ALWAYS);

	set_mySubSystem( "TEST_LOG_READER_STATE", SUBSYSTEM_TYPE_TOOL );

		// initialize to read from config file
	myDistro->Init( argc, argv );
	config();

		// Set up the dprintf stuff...
	dprintf_config("TEST_LOG_READER_STATE");

	Options	opts;
	if ( CheckArgs( argc, argv, opts ) < 0 ) {
		fprintf( stderr, "CheckArgs() failed\n" );
		exit( 1 );
	}

	ReadUserLog::FileState	state;
	if ( opts.needStateFile() && ( ReadState( opts, state ) < 0 )  ) {
		fprintf( stderr, "ReadState() failed\n" );
		exit( 1 );
	}
	ReadUserLog::FileState	state2;
	if ( opts.needStateFile2() && ( ReadState( opts, state2 ) < 0 )  ) {
		fprintf( stderr, "ReadState() failed\n" );
		exit( 1 );
	}

	int	status = 0;
	switch( opts.getCommand() )
	{
	case CMD_NONE:
		status = -1;
		break;
	case CMD_LIST:
		opts.dumpFieldList( );
		break;
	case CMD_DUMP:
		status = DumpState( opts, state );
		break;
	case CMD_DIFF:
		status = DiffState( opts, state, state2 );
		break;
	case CMD_ACCESS:
		status = CheckStateAccess( opts, state );
		break;
	case CMD_VERIFY:
		status = VerifyState( opts, state );
		break;
	}

	if ( status == 0 ) {
		exit( 0 );
	} else {
		exit( 2 );
	}
}
Example #5
0
bool WrappedID3D11DeviceContext::Serialise_BeginCaptureFrame(bool applyInitialState)
{
	D3D11RenderState state(m_pSerialiser);

	if(m_State >= WRITING)
	{
		state = *m_CurrentPipelineState;

		state.SetSerialiser(m_pSerialiser);

		state.MarkReferenced(this, true);
	}

	state.Serialise(m_State, m_pDevice);

	if(m_State <= EXECUTING && applyInitialState)
	{
		m_DoStateVerify = false;
		{
			*m_CurrentPipelineState = state;
			state.ApplyState(this);
		}
		m_DoStateVerify = true;
		VerifyState();
	}

	return true;
}
Example #6
0
void AwtLabel::Enable(BOOL bEnable)
{
    ::EnableWindow(GetHWnd(), bEnable);
    // Fix for Bug #4038881 Labels don't enable and disable properly
    // Fix for Bug #4096745 disable()/enable() make AWT components blink
    // This fix is moved from awt_Component.cpp for Bug #4096745
    ::InvalidateRect(GetHWnd(), NULL, FALSE);
    CriticalSection::Lock l(GetLock());
    VerifyState();
}
bool16
CZPAMLockable::Relock( UIFlags uiFlags, bool16 allowOverride )
#endif
{
	LogFunctionEnterExit;
	
	bool16 lockSucceeded = kFalse;
	
	do
	{
		InterfacePtr<IManagedStatus> managedStatus( this, UseDefaultIID() );
		if ( !managedStatus )
			break;
		
#if defined(InDnCS5) || defined(InDnCS5_5)
		this->VerifyState( kSuppressUI, objectUID);
#else
		this->VerifyState();
#endif
	
		
		//if ( fLockState == IAMLockable::enLocked || fLockState == IAMLockable::enCheckedOut )
		{
			UIDRef storyRef = Utils<Facade::IWorkgroupStoryFacade>()->GetStoryUIDRef( managedStatus->GetAsset() );
			
			IZPLog_Str_( thisFileLA, enLT_DebugInfo, "story UID=0x%08X", storyRef.GetUID().Get() );
			
			//
			// Relock is called when the user updates a checked-out link
			// or when a doc with locked stories is opened
			//
			// In both cases the story is already locked but the metadata or story UID associated
			//  with the asset may have changed.  Relock gives you a chance to update this metadata
			//
			// We have no such metadata in this example so we do nothing but verify
			//  that the asset is indeed already locked
			
			InterfacePtr<IManageableAsset> asset( this->QueryAsset());
			ASSERT(asset);
			if( !asset )
				break;
#if 0		//Comment otherwise assignment acquire lock for all stories irrespective of prefs setting
			ClassID amProviderClass = asset->GetServiceProviderClass();
			lockSucceeded = Utils<IZPAMHelper>()->CallAMServiceDo( asset, amProviderClass, IAMServiceProvider::enCheckOut );
			VerifyState( kSuppressUI );
#else
			lockSucceeded = true;
#endif
		}
	}while (kFalse);
	
	return lockSucceeded;
}
IAMLockable::LockState
CZPAMLockable::GetLockState()
#endif
{
	//LogFunctionEnterExit;
#ifdef DEBUG
	IAMLockable::LockState oldCachedState = fLockState;
#endif
	//if ( fLockState == IAMLockable::enUndefined || fLockState  == IAMLockable::enUnavailable )
	
	// not yet initialized
#if defined(InDnCS5) || defined(InDnCS5_5)
	VerifyState( kSuppressUI, objectUID );
#else
	VerifyState( kSuppressUI );	
#endif

#ifdef DEBUG
	if( fLockState != oldCachedState )
		IZPLog_Str_( thisFileLA, enLT_DebugInfo, "Lock state changed from %d to %d", oldCachedState, fLockState);
#endif	
	return fLockState;
}
//----------------------------------------------------------------------------------------
// IsLocked
//----------------------------------------------------------------------------------------
bool16
CZPAMLockable::IsLocked(
	const PMString & userName)
{
	LogFunctionEnterExit;
	//TODO: CS5: Implement functionality
	bool16 isLocked = kFalse;

	VerifyState( kSuppressUI, GetLockObjectUID() );	
	
	if(userName.IsEqual(fLockOwnerName))
	{
		if( fLockState == IAMLockable::enCheckedOut || fLockState == IAMLockable::enLocked )
		{
			isLocked =  kTrue;
		}
	}

	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "IsLocked = %s\n",(isLocked?"true":"false"));
	
	return isLocked;
}
Example #10
0
bool WrappedID3D11DeviceContext::Serialise_BeginCaptureFrame(bool applyInitialState)
{
	D3D11RenderState state(m_pSerialiser);

	if(m_State >= WRITING)
	{
		state = *m_CurrentPipelineState;

		state.SetSerialiser(m_pSerialiser);

		state.MarkReferenced(this, true);
	}

	state.Serialise(m_State, m_pDevice);

	if(m_State <= EXECUTING && applyInitialState)
	{
		m_DoStateVerify = false;
		{
			*m_CurrentPipelineState = state;
			m_CurrentPipelineState->SetDevice(m_pDevice);
			state.ApplyState(this);
		}
		m_DoStateVerify = true;
		VerifyState();
	}

	// stream-out hidden counters need to be saved, in case their results are used
	// for a DrawAuto() somewhere. Each buffer used as a stream-out target has a hidden
	// counter saved with it that stores the number of primitives written, which is then
	// used for a DrawAuto(). If the stream-out happens in frame we don't need to worry,
	// but if it references a buffer from before we need to have that counter available
	// on replay to 'fake' the DrawAuto() just as a Draw() with known values
	if(m_State >= WRITING)
	{
		// this may break API guarantees, but we need to fetch the hidden counters
		// so we need to restart any queries for currently set SO targets.
		// Potentially to be more correct we could defer fetching the results of queries
		// that are still running until they get detached (as they must be detached
		// before being used for any DrawAuto calls - if we're in CAPFRAME we could
		// serialise the data then. If they're never detached, we don't need the results)

		bool restart[4] = { false };

		for(UINT b=0; b < 4; b++)
		{
			ID3D11Buffer *buf = m_CurrentPipelineState->SO.Buffers[b];

			if(buf)
			{
				ResourceId id = GetIDForResource(buf);

				m_pRealContext->End(m_StreamOutCounters[id].query);
				m_StreamOutCounters[id].running = false;

				restart[b] = true;
			}
		}
		
		D3D11_QUERY_DATA_SO_STATISTICS numPrims;

		// readback all known counters
		SERIALISE_ELEMENT(uint32_t, numStreamOutCounters, (uint32_t)m_StreamOutCounters.size());
		for(auto it = m_StreamOutCounters.begin(); it != m_StreamOutCounters.end(); ++it)
		{
			SERIALISE_ELEMENT(ResourceId, id, it->first);
			
			RDCEraseEl(numPrims);

			HRESULT hr = S_FALSE;

			do 
			{
				hr = m_pRealContext->GetData(it->second.query, &numPrims, sizeof(D3D11_QUERY_DATA_SO_STATISTICS), 0);
			} while(hr == S_FALSE);

			if(hr != S_OK)
			{
				numPrims.NumPrimitivesWritten = 0;
				RDCERR("Couldn't retrieve hidden buffer counter for streamout on buffer %llx", id);
			}

			SERIALISE_ELEMENT(uint64_t, hiddenCounter, (uint64_t)numPrims.NumPrimitivesWritten);
		}
			
		// restart any counters we were forced to stop
		for(UINT b=0; b < 4; b++)
		{
			ID3D11Buffer *buf = m_CurrentPipelineState->SO.Buffers[b];
			
			if(buf && restart[b])
			{
				ResourceId id = GetIDForResource(buf);

				// release any previous query as the hidden counter is overwritten
				SAFE_RELEASE(m_StreamOutCounters[id].query);

				D3D11_QUERY queryTypes[] = {
					D3D11_QUERY_SO_STATISTICS_STREAM0,
					D3D11_QUERY_SO_STATISTICS_STREAM1,
					D3D11_QUERY_SO_STATISTICS_STREAM2,
					D3D11_QUERY_SO_STATISTICS_STREAM3,
				};

				D3D11_QUERY_DESC qdesc;
				qdesc.MiscFlags = 0;
				qdesc.Query = queryTypes[b];

				m_pDevice->GetReal()->CreateQuery(&qdesc, &m_StreamOutCounters[id].query);

				m_pRealContext->Begin(m_StreamOutCounters[id].query);
				m_StreamOutCounters[id].running = true;
			}
		}
	}
	// version 5 added this set of data, we can assume for older logs there's just no counters
	else if(m_pDevice->GetLogVersion() >= 0x000005)
	{
		// read in the known stream-out counters at the start of the frame.
		// any stream-out that happens in the captured frame will be replayed
		// and those counters will override this value when it comes to a
		// DrawAuto()
		SERIALISE_ELEMENT(uint32_t, numStreamOutCounters, 0);
		for(uint32_t i=0; i < numStreamOutCounters; i++)
		{
			SERIALISE_ELEMENT(ResourceId, id, ResourceId());
			SERIALISE_ELEMENT(uint64_t, hiddenCounter, 0);
			
			if(m_pDevice->GetResourceManager()->HasLiveResource(id))
				m_StreamOutCounters[m_pDevice->GetResourceManager()->GetLiveID(id)].numPrims = hiddenCounter;
		}
	}

	return true;
}