예제 #1
0
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();

}
예제 #2
0
static void
ReadAirspace(AirspaceDatabase &airspace_database, ZZIP_FILE *fp)
{
  StartupStore(TEXT("ReadAirspace\n"));
  int	Tock = 0;
  DWORD	dwStep;
  DWORD	dwPos;
  DWORD	dwOldPos = 0L;
  int	nLineType;

  unsigned NumberOfAirspacePointsPass[2] = { 0, 0 };
  unsigned NumberOfAirspaceAreasPass[2] = { 0, 0 };
  unsigned NumberOfAirspaceCirclesPass[2] = { 0, 0 };

  LineCount = 0;

  airspace_database.SetQNH(QNH);

  XCSoarInterface::CreateProgressDialog(gettext(TEXT("Loading Airspace File...")));
  // Need step size finer than default 10
  XCSoarInterface::SetProgressStepSize(5);
  dwStep = zzip_file_size(fp) / 10L;

  TempArea.FirstPoint = airspace_database.NumberOfAirspacePoints;

  bFillMode = false;
  bWaiting = true;
  XCSoarInterface::StepProgressDialog();
  while((nLineType = GetNextLine(fp, TempString)) >= 0) {
    Tock++;
    Tock %= 50;
    if (Tock == 0) {
      dwPos = zzip_tell(fp);
      if ((dwPos - dwOldPos) >= dwStep) {
        XCSoarInterface::StepProgressDialog();
        dwOldPos = dwPos;
      }
    }

    if (!ParseLine(airspace_database, nLineType, NumberOfAirspacePointsPass[0],
                   NumberOfAirspaceAreasPass[0],
                   NumberOfAirspaceCirclesPass[0])) {
      CloseAirspace(airspace_database);
      return;
    }
  }

  // Process final area (if any). bFillMode is false.  JG 10-Nov-2005
  if (!bWaiting)
    NumberOfAirspaceAreasPass[0]++; // ????

  // allocate new memory
  size_t screen_point_size = (airspace_database.NumberOfAirspacePoints +
                              NumberOfAirspacePointsPass[0]) *
    sizeof(AirspaceScreenPoint[0]);
  POINT *new_points = AirspaceScreenPoint == NULL
    ? (POINT *)LocalAlloc(LMEM_FIXED, screen_point_size)
    : (POINT *)LocalReAlloc(AirspaceScreenPoint, LMEM_FIXED,
                            screen_point_size);
  if (new_points != NULL)
    AirspaceScreenPoint = new_points;

  if ((screen_point_size > 0 && new_points == NULL) ||
      !airspace_database.GrowPoints(NumberOfAirspacePointsPass[0]) ||
      !airspace_database.GrowAreas(NumberOfAirspaceAreasPass[0]) ||
      !airspace_database.GrowCircles(NumberOfAirspaceCirclesPass[0])) {
    // can't allocate memory, so delete everything
    airspace_database.Clear();

    if (AirspaceScreenPoint != NULL) {
      LocalFree((HLOCAL)AirspaceScreenPoint);
      AirspaceScreenPoint = NULL;
    }

    return;
  }

  // ok, start the read
  TempArea.FirstPoint = airspace_database.NumberOfAirspacePoints;
  zzip_seek(fp, 0, SEEK_SET );
  LineCount = -1;

  bFillMode = true;
  bWaiting = true;
  dwOldPos = 0L;
  XCSoarInterface::StepProgressDialog();
  CenterY = CenterX = 0;
  Rotation = 1;

  while((nLineType = GetNextLine(fp, TempString)) >= 0) {
    Tock++;
    Tock %= 50;

    if (Tock == 0) {
      dwPos = zzip_tell(fp);
      if ((dwPos - dwOldPos) >= dwStep) {
        XCSoarInterface::StepProgressDialog();
        dwOldPos = dwPos;
      }
    }

    ParseLine(airspace_database, nLineType, NumberOfAirspacePointsPass[1],
              NumberOfAirspaceAreasPass[1],
              NumberOfAirspaceCirclesPass[1]);
  }

  // Process final area (if any). bFillMode is true.  JG 10-Nov-2005
  if (!bWaiting)
    AddArea(airspace_database, &TempArea, NumberOfAirspaceAreasPass[1]);

  if (NumberOfAirspacePointsPass[0] != NumberOfAirspacePointsPass[1]
      || NumberOfAirspaceAreasPass[0] != NumberOfAirspaceAreasPass[1]
      || NumberOfAirspaceCirclesPass[0] != NumberOfAirspaceCirclesPass[1]){

    if (MessageBoxX(gettext(TEXT("Internal Airspace Parser Error!\r\nPlease send this Airspacefile to Support")),
                    gettext(TEXT("Airspace")), MB_OKCANCEL) == IDCANCEL) {
    }

  }

#ifndef NDEBUG
  // only do this if debugging
  DumpAirspaceFile(airspace_database);
#endif

//  if(AirspacePoint != NULL)  LocalFree((HLOCAL)AirspacePoint);

}