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.

64 lines
1.1KB

  1. #include <context.hpp>
  2. #include <window/Window.hpp>
  3. #include <patch.hpp>
  4. #include <engine/Engine.hpp>
  5. #include <app/Scene.hpp>
  6. #include <history.hpp>
  7. #include <midiloopback.hpp>
  8. namespace rack {
  9. Context::~Context() {
  10. // Deleting NULL is safe in C++.
  11. // Set pointers to NULL so other objects will segfault when attempting to access them
  12. INFO("Deleting window");
  13. delete window;
  14. window = NULL;
  15. INFO("Deleting patch manager");
  16. delete patch;
  17. patch = NULL;
  18. INFO("Deleting scene");
  19. delete scene;
  20. scene = NULL;
  21. INFO("Deleting event state");
  22. delete event;
  23. event = NULL;
  24. INFO("Deleting history state");
  25. delete history;
  26. history = NULL;
  27. INFO("Deleting engine");
  28. delete engine;
  29. engine = NULL;
  30. INFO("Deleting MIDI loopback");
  31. delete midiLoopbackContext;
  32. midiLoopbackContext = NULL;
  33. }
  34. static thread_local Context* threadContext = NULL;
  35. Context* contextGet() {
  36. return threadContext;
  37. }
  38. // Apple's clang incorrectly compiles this function when -O2 or higher is enabled.
  39. #ifdef ARCH_MAC
  40. __attribute__((optnone))
  41. #endif
  42. void contextSet(Context* context) {
  43. threadContext = context;
  44. }
  45. } // namespace rack