void nsCOMArray_base::Clear() { nsTArray<nsISupports*> objects; objects.SwapElements(mArray); ReleaseObjects(objects); }
void CGameFrameWork::OnDestroy() { ReleaseObjects(); //////////////////////////////////// //////////////////////////////////// }
void FetchStream::ErrorPropagation(JSContext* aCx, const MutexAutoLock& aProofOfLock, JS::HandleObject aStream, nsresult aError) { AssertIsOnOwningThread(); // Nothing to do. if (mState == eClosed) { return; } // Let's close the stream. if (aError == NS_BASE_STREAM_CLOSED) { CloseAndReleaseObjects(aCx, aProofOfLock, aStream); return; } // Let's use a generic error. RefPtr<DOMException> error = DOMException::Create(NS_ERROR_DOM_TYPE_ERR); JS::Rooted<JS::Value> errorValue(aCx); if (ToJSValue(aCx, error, &errorValue)) { MutexAutoUnlock unlock(mMutex); JS::ReadableStreamError(aCx, aStream, errorValue); } ReleaseObjects(aProofOfLock); }
CEntityObject::~CEntityObject() { ReleaseObjects(); if (m_pXForm) delete m_pXForm; FreeCameraSpacePos(); }
void nsCOMArray_base::RemoveElementsAt(uint32_t aIndex, uint32_t aCount) { nsTArray<nsISupports*> elementsToDestroy(aCount); elementsToDestroy.AppendElements(mArray.Elements() + aIndex, aCount); mArray.RemoveElementsAt(aIndex, aCount); ReleaseObjects(elementsToDestroy); }
//다음 함수는 응용 프로그램이 종료될 때 호출된다는 것에 유의하라. void CGameFramework::OnDestroy() { //게임 객체를 소멸한다. ReleaseObjects(); //Direct3D와 관련된 객체를 소멸한다. if (m_pd3dDeviceContext) m_pd3dDeviceContext->ClearState(); if (m_pd3dRenderTargetView) m_pd3dRenderTargetView->Release(); if (m_pDXGISwapChain) m_pDXGISwapChain->Release(); if (m_pd3dDeviceContext) m_pd3dDeviceContext->Release(); if (m_pd3dDevice) m_pd3dDevice->Release(); }
void D11StateBlock::Apply() { pDeviceContext->RSSetState(pRasterizerState); pDeviceContext->RSSetViewports(uiNumViewports, pViewports); pDeviceContext->OMSetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, pRenderTargetViews, pDepthStencilView); pDeviceContext->OMSetBlendState(pBlendState, fBlendFactor, uiSampleMask); pDeviceContext->IASetInputLayout(pInputLayout); pDeviceContext->IASetIndexBuffer(pIndexBuffer, Format, uiOffset); pDeviceContext->IASetPrimitiveTopology(Topology); pDeviceContext->IASetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, pVertexBuffers, uiStrides, uiOffsets); ReleaseObjects(); }
bool nsCOMArray_base::RemoveObjectsAt(int32_t aIndex, int32_t aCount) { if (uint32_t(aIndex) + uint32_t(aCount) <= mArray.Length()) { nsTArray<nsISupports*> elementsToDestroy(aCount); elementsToDestroy.AppendElements(mArray.Elements() + aIndex, aCount); mArray.RemoveElementsAt(aIndex, aCount); ReleaseObjects(elementsToDestroy); return true; } return false; }
BOOL ActiveScriptImpl::CreateEngine() { HRESULT hr; CLSID clsid; ReleaseObjects(); // Search for LanguageID and create instance of script engine hr = CLSIDFromProgID(scriptType, &clsid); if (!SUCCEEDED(hr)) return false; hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_IActiveScript, (void **)&scriptPtr); if (SUCCEEDED(hr)) { hr = scriptPtr->SetScriptSite(this); if (SUCCEEDED(hr)) { // Script Engine must support IActiveScriptParse for us to use it scriptPtr->QueryInterface(__uuidof(IActiveScriptParse), (void**)&scriptParsePtr); hr = scriptParsePtr->InitNew(); if (SUCCEEDED(hr)) { hr = scriptPtr->SetScriptState(SCRIPTSTATE_INITIALIZED); if (SUCCEEDED(hr)) return true; } } } else { // If this happens, the scripting engine is probably not properly registered } ReleaseObjects(); return false; }
void D11StateBlock::Capture() { // Release potential references to make sure we have no leaks. ReleaseObjects(); pDeviceContext->RSGetState(&pRasterizerState); uiNumViewports = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; pDeviceContext->RSGetViewports(&uiNumViewports, pViewports); pDeviceContext->OMGetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, pRenderTargetViews, &pDepthStencilView); pDeviceContext->OMGetBlendState(&pBlendState, fBlendFactor, &uiSampleMask); pDeviceContext->IAGetInputLayout(&pInputLayout); pDeviceContext->IAGetIndexBuffer(&pIndexBuffer, &Format, &uiOffset); pDeviceContext->IAGetPrimitiveTopology(&Topology); pDeviceContext->IAGetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, pVertexBuffers, uiStrides, uiOffsets); }
//----------------------------------------------------------------------------- // Name : ShutDown () // Desc : Shuts down the game engine, and frees up all resources. //----------------------------------------------------------------------------- bool CGameApp::ShutDown() { // Release any previously built objects ReleaseObjects ( ); // Destroy menu, it may not be attached if ( m_hMenu ) DestroyMenu( m_hMenu ); m_hMenu = NULL; // Destroy the render window SetMenu( m_hWnd, NULL ); if ( m_hWnd ) DestroyWindow( m_hWnd ); m_hWnd = NULL; // Shutdown Success return true; }
void FetchStream::CloseAndReleaseObjects(JSContext* aCx, const MutexAutoLock& aProofOfLock, JS::HandleObject aStream) { AssertIsOnOwningThread(); MOZ_DIAGNOSTIC_ASSERT(mState != eClosed); ReleaseObjects(aProofOfLock); MutexAutoUnlock unlock(mMutex); bool readable; if (!JS::ReadableStreamIsReadable(aCx, aStream, &readable)) { return; } if (readable) { JS::ReadableStreamClose(aCx, aStream); } }
void FetchStream::Close() { AssertIsOnOwningThread(); MutexAutoLock lock(mMutex); if (mState == eClosed) { return; } AutoJSAPI jsapi; if (NS_WARN_IF(!jsapi.Init(mGlobal))) { ReleaseObjects(lock); return; } JSContext* cx = jsapi.cx(); JS::Rooted<JSObject*> stream(cx, mStreamHolder->ReadableStreamBody()); CloseAndReleaseObjects(cx, lock, stream); }
void FileHelper::Finish() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (mFinished) { return; } mFinished = true; if (mLockedFile->IsAborted()) { // Always fire a "error" event with ABORT_ERR if the transaction was // aborted, even if the request succeeded or failed with another error. mResultCode = NS_ERROR_DOM_FILEHANDLE_ABORT_ERR; } LockedFile* oldLockedFile = gCurrentLockedFile; gCurrentLockedFile = mLockedFile; if (mFileRequest) { nsresult rv = mFileRequest->NotifyHelperCompleted(this); if (NS_SUCCEEDED(mResultCode) && NS_FAILED(rv)) { mResultCode = rv; } } NS_ASSERTION(gCurrentLockedFile == mLockedFile, "Should be unchanged!"); gCurrentLockedFile = oldLockedFile; mLockedFile->OnRequestFinished(); mListener->OnFileHelperComplete(this); ReleaseObjects(); MOZ_ASSERT(!(mFileHandle || mLockedFile || mFileRequest || mListener || mRequest), "Subclass didn't call FileHelper::ReleaseObjects!"); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { // Initialisiere und Registriere das Fenster. if (!InitializeWindow(hInstance, nShowCmd, Width, Height, true)) { MessageBox(0, L"Window Initialization - Failed", L"Error", MB_OK); return 0; } //Initialisiere Direct3D if (!InitializeDirect3d11App(hInstance)) { MessageBox(0, L"Direct3D Initialization - Failed", L"Error", MB_OK); return 0; } //Initialisiere die Szene if (!InitScene()) { MessageBox(0, L"Scene Initialization - Failed", L"Error", MB_OK); return 0; } // im der messageloop() Schleife läuft das eigentliche Programm ab. messageloop(); //Räume auf ReleaseObjects(); return 0; }
bool eae6320::Graphics::ShutDown() { bool wereThereErrors = false; if ( s_openGlRenderingContext != NULL ) { ReleaseObjects(); if ( wglMakeCurrent( s_deviceContext, NULL ) != FALSE ) { if ( wglDeleteContext( s_openGlRenderingContext ) == FALSE ) { std::stringstream errorMessage; errorMessage << "Windows failed to delete the OpenGL rendering context: " << GetLastWindowsError(); UserOutput::Print( errorMessage.str() ); } } else { std::stringstream errorMessage; errorMessage << "Windows failed to unset the current OpenGL rendering context: " << GetLastWindowsError(); UserOutput::Print( errorMessage.str() ); } s_openGlRenderingContext = NULL; } if ( s_deviceContext != NULL ) { // The documentation says that this call isn't necessary when CS_OWNDC is used ReleaseDC( s_renderingWindow, s_deviceContext ); s_deviceContext = NULL; } s_renderingWindow = NULL; return !wereThereErrors; }
void SimpleBrowser::PostNcDestroy() { ReleaseObjects(); CWnd::PostNcDestroy(); }
void FetchStream::ReleaseObjects() { MutexAutoLock lock(mMutex); ReleaseObjects(lock); }
ActiveScriptImpl::~ActiveScriptImpl() { ReleaseObjects(); }
SimpleBrowser::~SimpleBrowser() { ReleaseObjects(); }
D11StateBlock::~D11StateBlock() { ReleaseObjects(); pDeviceContext->Release(); }