You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.9KB

  1. #include "util/common.hpp"
  2. #include "engine.hpp"
  3. #include "window.hpp"
  4. #include "app.hpp"
  5. #include "plugin.hpp"
  6. #include "settings.hpp"
  7. #include "asset.hpp"
  8. #include "bridge.hpp"
  9. #include "osdialog.h"
  10. #include <unistd.h>
  11. using namespace rack;
  12. int main(int argc, char* argv[]) {
  13. randomInit();
  14. loggerInit();
  15. debug("Hello world!");
  16. info("Hello world!");
  17. warn("Hello world!");
  18. fatal("Hello world!");
  19. info("Rack %s", gApplicationVersion.c_str());
  20. {
  21. char *cwd = getcwd(NULL, 0);
  22. info("Current working directory: %s", cwd);
  23. free(cwd);
  24. std::string globalDir = assetGlobal("");
  25. std::string localDir = assetLocal("");
  26. info("Global directory: %s", globalDir.c_str());
  27. info("Local directory: %s", localDir.c_str());
  28. }
  29. pluginInit();
  30. engineInit();
  31. bridgeInit();
  32. windowInit();
  33. appInit();
  34. settingsLoad(assetLocal("settings.json"));
  35. std::string oldLastPath = gRackWidget->lastPath;
  36. // To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded.
  37. bool oldSkipAutosaveOnLaunch = skipAutosaveOnLaunch;
  38. skipAutosaveOnLaunch = true;
  39. settingsSave(assetLocal("settings.json"));
  40. skipAutosaveOnLaunch = false;
  41. if (oldSkipAutosaveOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Would you like to clear your patch and start over?")) {
  42. // Do nothing. Empty patch is already loaded.
  43. }
  44. else {
  45. gRackWidget->loadPatch(assetLocal("autosave.vcv"));
  46. }
  47. gRackWidget->lastPath = oldLastPath;
  48. engineStart();
  49. windowRun();
  50. engineStop();
  51. gRackWidget->savePatch(assetLocal("autosave.vcv"));
  52. settingsSave(assetLocal("settings.json"));
  53. appDestroy();
  54. windowDestroy();
  55. bridgeDestroy();
  56. engineDestroy();
  57. pluginDestroy();
  58. loggerDestroy();
  59. return 0;
  60. }