void XCSoarInterface::Shutdown(void) { gcc_unused ScopeBusyIndicator busy; // Show progress dialog ProgressGlue::Create(_("Shutdown, please wait...")); // Log shutdown information LogStartUp(_T("Entering shutdown...")); StartupLogFreeRamAndStorage(); // Turn off all displays globalRunningEvent.reset(); // Stop logger and save igc file ProgressGlue::Create(_("Shutdown, saving logs...")); logger.guiStopLogger(Basic(), true); // Save settings to profile ProgressGlue::Create(_("Shutdown, saving profile...")); Profile::Save(); // Stop sound LogStartUp(_T("SaveSoundSettings")); Profile::SetSoundSettings(); #ifndef DISABLEAUDIOVARIO // VarioSound_EnableSound(false); // VarioSound_Close(); #endif ProgressGlue::Create(_("Shutdown, please wait...")); // Stop threads LogStartUp(_T("Stop threads")); #ifndef ENABLE_OPENGL draw_thread->stop(); #endif calculation_thread->stop(); // Wait for the calculations thread to finish LogStartUp(_T("Waiting for calculation thread")); calculation_thread->join(); delete calculation_thread; calculation_thread = NULL; // Wait for the drawing thread to finish #ifndef ENABLE_OPENGL LogStartUp(_T("Waiting for draw thread")); draw_thread->join(); delete draw_thread; #endif LogStartUp(_T("delete MapWindow")); main_window.map.reset(); // Save the task for the next time ProgressGlue::Create(_("Shutdown, saving task...")); LogStartUp(_T("Save default task")); protected_task_manager->task_save_default(); // Clear waypoint database LogStartUp(_T("Close waypoints")); way_points.clear(); ProgressGlue::Create(_("Shutdown, please wait...")); // Clear weather database LogStartUp(_T("CloseRASP")); RASP.Close(); // Clear terrain database LogStartUp(_T("CloseTerrain")); delete terrain; LogStartUp(_T("CloseTopography")); delete topography; delete marks; // Close any device connections devShutdown(); RawLoggerShutdown(); delete replay; // Save everything in the persistent memory file SaveCalculationsPersist(Basic(), Calculated(), *protected_task_manager, *glide_computer, logger); delete protected_task_manager; delete task_manager; // Kill windows LogStartUp(_T("Destroy Info Boxes")); InfoBoxManager::Destroy(); LogStartUp(_T("Destroy Button Labels")); ButtonLabel::Destroy(); // Close the progress dialog LogStartUp(_T("Close Progress Dialog")); ProgressGlue::Close(); // Clear the EGM96 database CloseGeoid(); delete glide_computer; // Clear airspace database LogStartUp(_T("Close airspace")); airspace_warnings->clear(); airspace_database.clear(); delete airspace_warnings; delete airspace_warning; // Destroy FlarmNet records FlarmNet::Destroy(); delete file_cache; LogStartUp(_T("Close Windows - main ")); main_window.reset(); CloseLanguageFile(); RestoreDisplayOrientation(); StartupLogFreeRamAndStorage(); LogStartUp(_T("Finished shutdown")); }
void XCSoarInterface::Shutdown(void) { CreateProgressDialog(gettext(TEXT("Shutdown, please wait..."))); StartHourglassCursor(); StartupStore(TEXT("Entering shutdown...\n")); StartupLogFreeRamAndStorage(); // turn off all displays globalRunningEvent.reset(); StartupStore(TEXT("dlgAirspaceWarningDeInit\n")); dlgAirspaceWarningDeInit(); CreateProgressDialog(gettext(TEXT("Shutdown, saving logs..."))); // stop logger logger.guiStopLogger(Basic(),true); CreateProgressDialog(gettext(TEXT("Shutdown, saving profile..."))); // Save settings Profile::StoreRegistry(); // Stop sound StartupStore(TEXT("SaveSoundSettings\n")); Profile::SaveSoundSettings(); #ifndef DISABLEAUDIOVARIO // VarioSound_EnableSound(false); // VarioSound_Close(); #endif // Stop drawing CreateProgressDialog(gettext(TEXT("Shutdown, please wait..."))); StartupStore(TEXT("CloseDrawingThread\n")); closeTriggerEvent.trigger(); calculation_thread->join(); StartupStore(TEXT("- calculation thread returned\n")); instrument_thread->join(); StartupStore(TEXT("- instrument thread returned\n")); draw_thread->join(); StartupStore(TEXT("- draw thread returned\n")); delete draw_thread; // Clear data CreateProgressDialog(gettext(TEXT("Shutdown, saving task..."))); StartupStore(TEXT("Resume abort task\n")); task.ResumeAbortTask(SettingsComputer(), -1); // turn off abort if it was on. StartupStore(TEXT("Save default task\n")); task.SaveDefaultTask(); StartupStore(TEXT("Clear task data\n")); task.ClearTask(); StartupStore(TEXT("Close airspace\n")); CloseAirspace(); StartupStore(TEXT("Close waypoints\n")); way_points.clear(); CreateProgressDialog(gettext(TEXT("Shutdown, please wait..."))); StartupStore(TEXT("CloseTerrainTopology\n")); RASP.Close(); terrain.CloseTerrain(); delete topology; delete marks; devShutdown(); SaveCalculationsPersist(Basic(),Calculated()); #if (EXPERIMENTAL > 0) // CalibrationSave(); #endif #if defined(GNAV) && !defined(PCGNAV) StartupStore(TEXT("Altair shutdown\n")); Sleep(2500); StopHourglassCursor(); InputEvents::eventDLLExecute(TEXT("altairplatform.dll SetShutdown 1")); while(1) { Sleep(100); // free time up for processor to perform shutdown } #endif CloseFLARMDetails(); // Kill windows StartupStore(TEXT("Destroy Info Boxes\n")); InfoBoxManager::Destroy(); StartupStore(TEXT("Destroy Button Labels\n")); ButtonLabel::Destroy(); StartupStore(TEXT("Delete Objects\n")); // Kill graphics objects DeleteFonts(); DeleteAirspace(); StartupStore(TEXT("Close Progress Dialog\n")); CloseProgressDialog(); CloseGeoid(); StartupStore(TEXT("Close Windows - main \n")); main_window.reset(); StartupStore(TEXT("Close Graphics\n")); MapGfx.Destroy(); #ifdef DEBUG_TRANSLATIONS StartupStore(TEXT("Writing missing translations\n")); WriteMissingTranslations(); #endif StartupLogFreeRamAndStorage(); StartupStore(TEXT("Finished shutdown\n")); StopHourglassCursor(); }
void Shutdown(void) { int i; // LKTOKEN _@M1219_ "Shutdown, please wait..." CreateProgressDialog(gettext(TEXT("_@M1219_"))); LKSound(_T("LK_DISCONNECT.WAV")); Poco::Thread::sleep(500); // real WAV length is 410+ms if (!GlobalRunning) { // shutdown on startup (before sim/fly or clicking on the window X) StartupStore(_T(". Quick shutdown requested before terminating startup%s"),NEWLINE); // force exit mode for the case of being in welcome screen: OnTimerNotify will catch it RUN_MODE=RUN_SHUTDOWN; CloseCalculations(); CloseGeoid(); DeInitCustomHardware(); LKRunStartEnd(false); return; } StartupStore(_T(". Entering shutdown %s%s"), WhatTimeIsIt(),NEWLINE); MapWindow::Event_Pan(0); // return from PAN restores the Task in case of Turnpoint moving #if TESTBENCH StartupLogFreeRamAndStorage(); #endif // turn off all displays GlobalRunning = false; // LKTOKEN _@M1220_ "Shutdown, saving logs..." CreateProgressDialog(gettext(TEXT("_@M1220_"))); // In case we quit while are still flying UpdateLogBook(false); // false=only log if still flying // stop logger guiStopLogger(true); // LKTOKEN _@M1221_ "Shutdown, saving profile..." CreateProgressDialog(gettext(TEXT("_@M1221_"))); extern void LKAircraftSave(const TCHAR *szFile); extern void LKPilotSave(const TCHAR *szFile); extern void LKDeviceSave(const TCHAR *szFile); LKPilotSave(defaultPilotFile); LKAircraftSave(defaultAircraftFile); LKProfileSave(defaultProfileFile); LKDeviceSave(defaultDeviceFile); #if TESTBENCH StartupStore(TEXT(". Save_Recent_WP_history%s"),NEWLINE); #endif SaveRecentList(); // Stop sound // Stop drawing // LKTOKEN _@M1219_ "Shutdown, please wait..." CreateProgressDialog(gettext(TEXT("_@M1219_"))); // 100526 this is creating problem in SIM mode when quit is called from X button, and we are in waypoint details // or probably in other menu related screens. However it cannot happen from real PNA or PDA because we don't have // that X button. MapWindow::CloseDrawingThread(); // Stop calculating too (wake up) dataTriggerEvent.set(); drawTriggerEvent.set(); // Clear data // LKTOKEN _@M1222_ "Shutdown, saving task..." CreateProgressDialog(gettext(TEXT("_@M1222_"))); #if TESTBENCH StartupStore(TEXT(".... Save default task%s"),NEWLINE); #endif SaveDefaultTask(); #if TESTBENCH StartupStore(TEXT(".... Clear task data%s"),NEWLINE); #endif LockTaskData(); Task[0].Index = -1; ActiveWayPoint = -1; AATEnabled = FALSE; CloseWayPoints(); UnlockTaskData(); // LKTOKEN _@M1219_ "Shutdown, please wait..." CreateProgressDialog(gettext(TEXT("_@M1219_"))); #if TESTBENCH StartupStore(TEXT(".... CloseTerrainTopology%s"),NEWLINE); #endif RasterTerrain::CloseTerrain(); CloseTopology(); #if USETOPOMARKS TopologyCloseMarks(); #endif CloseTerrainRenderer(); LiveTrackerShutdown(); #ifndef NO_DATARECORDER CloseFlightDataRecorder(); #endif // Stop COM devices StartupStore(TEXT(". Stop COM devices%s"),NEWLINE); devCloseAll(); CloseFLARMDetails(); ProgramStarted = psInitInProgress; // Kill windows #if TESTBENCH StartupStore(TEXT(".... Close Messages%s"),NEWLINE); #endif Message::Destroy(); #if TESTBENCH StartupStore(TEXT(".... Destroy Button Labels%s"),NEWLINE); #endif ButtonLabel::Destroy(); #if TESTBENCH StartupStore(TEXT(".... Delete Objects%s"),NEWLINE); #endif // Kill graphics objects #ifdef LXMINIMAP hBrushButtonHasFocus.Release(); #endif CAirspaceManager::Instance().CloseAirspaces(); #if TESTBENCH StartupStore(TEXT(".... Delete Critical Sections%s"),NEWLINE); #endif // Wait end of Calculation thread before deinit critical section. WaitThreadCalculation(); #if TESTBENCH StartupStore(TEXT(".... Close Progress Dialog%s"),NEWLINE); #endif CloseProgressDialog(); #if TESTBENCH StartupStore(TEXT(".... Close Calculations%s"),NEWLINE); #endif CloseCalculations(); CloseGeoid(); DeInitCustomHardware(); #if TESTBENCH StartupStore(TEXT(".... Close Windows%s"),NEWLINE); #endif #if TESTBENCH StartupLogFreeRamAndStorage(); #endif for (i=0;i<NUMDEV;i++) { if (ComPortStatus[i]!=0) { StartupStore(_T(". ComPort %d: status=%d Rx=%ld Tx=%ld ErrRx=%ld + ErrTx=%ld (==%ld)%s"), i, ComPortStatus[i], ComPortRx[i],ComPortTx[i], ComPortErrRx[i],ComPortErrTx[i],ComPortErrors[i],NEWLINE); } } StartupStore(_T(". Finished shutdown %s%s"), WhatTimeIsIt(),NEWLINE); LKRunStartEnd(false); #ifdef DEBUG TCHAR foop[80]; TASK_POINT wp; TASK_POINT *wpr = ℘ _stprintf(foop,TEXT(". Sizes %d %d %d%s"), sizeof(TASK_POINT), ((long)&wpr->AATTargetLocked)-((long)wpr), ((long)&wpr->Target)-((long)wpr), NEWLINE ); StartupStore(foop); #endif StartupStore(_T("Destroy MainWindow" NEWLINE)); MainWindow.Destroy(); }