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.

52 lines
837B

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