From cc5b781de12b86a3a868ddc9c2124b2f565b290b Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 1 Jan 2024 02:33:33 -0800 Subject: [PATCH] OpenXR: Fix persistent custom bindings not working --- src/mods/vr/runtimes/OpenXR.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mods/vr/runtimes/OpenXR.cpp b/src/mods/vr/runtimes/OpenXR.cpp index a237c43..41a4d24 100644 --- a/src/mods/vr/runtimes/OpenXR.cpp +++ b/src/mods/vr/runtimes/OpenXR.cpp @@ -571,10 +571,10 @@ void OpenXR::destroy() { xrDestroySession(this->session); } - /*if (this->instance != nullptr) { + if (this->instance != nullptr && this->ever_submitted) { xrDestroyInstance(this->instance); this->instance = nullptr; - }*/ + } this->session = nullptr; this->session_ready = false; @@ -1284,9 +1284,11 @@ void OpenXR::display_bindings_editor() { // replace the slashes with underscores std::replace(filename.begin(), filename.end(), '/', '_'); - if (std::filesystem::exists(filename)) { + const auto persistent_filename = (Framework::get_persistent_dir() / filename).string(); + + if (std::filesystem::exists(persistent_filename)) { // Delete the file - std::filesystem::remove(filename); + std::filesystem::remove(persistent_filename); this->wants_reinitialize = true; } } @@ -1543,7 +1545,9 @@ void OpenXR::save_bindings() { // replace the slashes with underscores std::replace(filename.begin(), filename.end(), '/', '_'); - std::ofstream(filename) << j.dump(4); + const auto persistent_filename = (Framework::get_persistent_dir() / filename).string(); + + std::ofstream(persistent_filename) << j.dump(4); this->wants_reinitialize = true; }