void Window::DeleteChild( const rString& name ) { for( auto itChild = m_OrderedChildren.begin(); itChild != m_OrderedChildren.end(); itChild++ ) { if( ( *itChild )->GetName() == name ) { m_OrderedChildren.erase( itChild ); break; } } for( auto& child : m_Children ) { if( child.second->GetName() == name ) { pDelete( child.second ); child.second = nullptr; m_Children.erase( name ); return; } else if( child.second->IsWindow() ) { Window* window = static_cast<Window*>( child.second ); window->DeleteChild( name ); } } }
AOSDatabaseConnectionPool::~AOSDatabaseConnectionPool() { try { pDelete(mp_DatabasePool); } catch(...) {} }
void gfx::MaterialBank::ClearMaterials() { for ( auto& material : m_Materials ) { pDelete( material ); } m_Materials.clear(); m_MatMap.clear(); pDeleteArray(m_TextureAtlasses); }
PacketPump::~PacketPump( ) { const Message* p; for ( auto& sendQueuePair : m_SendQueues ) { while ( sendQueuePair.second->Consume( p ) ) // Delete all enqueued packets tDelete( p ); pDelete( sendQueuePair.second ); // Delete the queue } }
AOSOutputExecutor::~AOSOutputExecutor() { try { OutputGeneratorContainer::iterator it = m_OutputGenerators.begin(); while (it != m_OutputGenerators.end()) { (*it).second->deinit(); pDelete((*it).second); ++it; } } catch(...) {} }
//+----------------------------------------------------------------------------+ //|void Cleanup(void) //\----------------------------------------------------------------------------+ void SoundSDL::Cleanup(void) { if(m_AudioCVT) { pDelete(m_AudioCVT); m_AudioCVT = nullptr; } if(m_BufferData) { tDelete(m_BufferData); m_BufferData = nullptr; } if(m_AudioFile) { pDelete(m_AudioFile); m_AudioFile = nullptr; } m_AudioEngine = nullptr; m_Name = ""; };
void PacketPump::RemoveQueue( const short queueID ) { auto itemToRemove = m_SendQueues.find( queueID ); if ( itemToRemove != m_SendQueues.end( ) ) { LocklessQueue<const Message*>* queueToRemove = itemToRemove->second; m_SendQueues.erase( itemToRemove ); // Remove the queue from the list of available queues so that no more packets gets sent to it const Message* p; while ( queueToRemove->Consume( p ) ) // Delete all packets waiting to be sent tDelete( p ); pDelete( queueToRemove ); // Delete the queue itself } else Logger::Log( "Attempted to remove nonixistent SendQueue", "PacketPump", LogSeverity::WARNING_MSG ); }
AIPlayer::~AIPlayer() { //SaveGenes(); //SaveDebugData(); if (m_IsNeuralNetAI) { if (m_IsWinner && AI_TRAIN_NEURAL_NETS) m_Net->WriteWeights(); pDelete(m_Net); } g_SSMail.UnregisterSubscriber(this); }
void AOSContextQueue_IsAvailable::stop() { for (size_t i=0; i<m_Queues.size(); ++i) { if (m_Queues.at(i)->pthread) m_Queues.at(i)->pthread->setRun(false); } int tries = 3; bool stillStopping = true; while (stillStopping) { size_t i; for (i=0; i<m_Queues.size(); ++i) { QueueWithThread *pqt = m_Queues.at(i); if (pqt->pthread) { if (pqt->pthread->isRunning()) { AThread::sleep(200); --tries; break; } else { pDelete(pqt->pthread); } } } // Everything stopped if (i == m_Queues.size()) return; // Time to terminate the threads if (tries == 0) break; } //a_Cleanup for (size_t i=0; i<m_Queues.size(); ++i) { delete m_Queues.at(i)->pthread; } }
Window::~Window() { for( auto& child : m_Children ) { if( child.second ) { if( child.second->IsWindow() ) g_GUI.EraseWindow( child.second->GetName() ); pDelete( child.second ); child.second = nullptr; } } g_GUI.EraseWindow( m_Name ); m_Children.clear(); m_OrderedChildren.clear(); }
void GUIEngine::AddChild( const rString& name, Object* child, const rString& parent ) { rString newName = name; if( name == "" ) newName = "ChildObject" + rToString( m_ObjectNameIndex ); bool success = false; for( auto& windowIt : m_Windows ) { if( parent == windowIt.second->GetName() ) success = windowIt.second->AddChild( newName, child ); } if( !success ) { Logger::Log( "Failed to add child object: " + newName, "GUIEngine", LogSeverity::ERROR_MSG ); pDelete( child ); } else m_ObjectNameIndex++; }
Window* GUIEngine::AddWindow( rString name, Rectangle boundingBox, rString parent , bool border ) { Window* newWindow = pNew( Window, name, parent, boundingBox, border ); bool success = false; for( auto& windowIt : m_Windows ) { if( parent == windowIt.second->GetName() ) success = windowIt.second->AddChild( name, newWindow ); } if( success ) { m_Windows.emplace( name, newWindow ); return newWindow; } else { Logger::Log( "Failed to add window: " + name, "GUIEngine", LogSeverity::ERROR_MSG ); pDelete( newWindow ); return nullptr; } }
ALog_AFile::~ALog_AFile() { try { //a_Stop logger thread m_LoggerThread.setRun(false); int i=5; while(m_LoggerThread.isRunning() && i > 0) { AThread::sleep(getLoggerCycleSleep()); --i; } //a_Flush data if (mp_File) { BufferContainer::iterator it = m_BuffersToWrite.begin(); if (it != m_BuffersToWrite.end()) { mp_File->open(); while (it != m_BuffersToWrite.end()) { if (mp_File && (*it)->m_ReadyToWrite) mp_File->write((*it)->m_Buffer); delete (*it); ++it; } mp_File->close(); } //a_Cleanup if (m_DeleteFileObject) pDelete(mp_File); } } catch(...) {} }
GUIEngine::~GUIEngine() { pDelete( m_RootWindow ); }
void SSWindow::Shutdown( SubsystemCollection* const ) { pDelete( m_Window ); }
gfx::TextureAtlas::~TextureAtlas() { pDelete(m_Texture); }
int main(int argc, char* argv[]) { int exitCode = EXIT_SUCCESS; PActivity* activity = pNew(PActivity(argc, argv)); // Enable memory leak checks and heap validation. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetBreakAlloc(-1); pMain(argc, argv); // Set console title. SetConsoleTitle(L"protoss debug console"); // Disable the close button of the console window. HWND hConsoleWindow = GetConsoleWindow(); if (hConsoleWindow != NULL) { HMENU hMenu = GetSystemMenu(hConsoleWindow, 0); if (hMenu != NULL) { DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); DrawMenuBar(hConsoleWindow); } } PContext* context = activity->findContext(pUint32(0)); pAssert(context != P_NULL); if (context == P_NULL) { exitCode = EXIT_FAILURE; pDelete(activity); return exitCode; } PWin32Window window(context); if (!window.create()) { exitCode = EXIT_FAILURE; pDelete(activity); return exitCode; } // Initialize the context. // kzaPlatformSetInstanceHandle(context, GetModuleHandle(NULL)); context->setState(P_CONTEXT_STATE_UNINITIALIZED); if (!context->initialize()) { exitCode = EXIT_FAILURE; } if (!context->onInitialized()) { context->setState(P_CONTEXT_STATE_ERROR); } else { pLogDebug("Starting program main loop"); context->setState(P_CONTEXT_STATE_RUNNING); } if (context->getState() == P_CONTEXT_STATE_ERROR) { exitCode = EXIT_FAILURE; } // The mainloop of window. window.run(); // Right before destroy the context, user might have // something to do. context->onDestroy(); context->destroy(); // Destroy native window. window.destroy(); // Destroy the activity pDelete(activity); // If debugger is present, a pause is required to keep the console output // visible. Otherwise the pause is automatic. if (IsDebuggerPresent()) { system("pause"); } return exitCode; }
PDevice::~PDevice() { pDelete(m_inputEventQueue); }
void SubsystemBank::Deinitialize() { for ( auto& subsystem : m_SubsystemTemplates ) { pDelete( subsystem ); } }