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.

55 lines
873B

  1. #include "app.hpp"
  2. #include "event.hpp"
  3. #include "window.hpp"
  4. #include "patch.hpp"
  5. #include "engine/Engine.hpp"
  6. #include "app/Scene.hpp"
  7. #include "history.hpp"
  8. namespace rack {
  9. namespace app {
  10. App::App() {
  11. event = new event::State;
  12. history = new history::State;
  13. window = new Window;
  14. engine = new engine::Engine;
  15. patch = new PatchManager;
  16. scene = new Scene;
  17. event->rootWidget = scene;
  18. }
  19. App::~App() {
  20. // Set pointers to NULL so other objects will segfault when attempting to access them
  21. delete scene; scene = NULL;
  22. delete patch; patch = NULL;
  23. delete event; event = NULL;
  24. delete history; history = NULL;
  25. delete engine; engine = NULL;
  26. delete window; window = NULL;
  27. }
  28. static App *c = NULL;
  29. void init() {
  30. assert(!c);
  31. c = new App;
  32. }
  33. void destroy() {
  34. assert(c);
  35. delete c;
  36. c = NULL;
  37. }
  38. App *get() {
  39. return c;
  40. }
  41. } // namespace app
  42. } // namespace rack