Menu: checkboxes and sliders keep their changes with any compiler

Store(value, v, ImGui::Checkbox(label, &v)) read v before the checkbox had
changed it on compilers that evaluate arguments left to right: C++ leaves the
order unspecified. GCC happens to call the widget first, so our builds worked;
clang lost every change. The widget now runs before Store.

From Supermedo/bloodborne_pc#19 (5c660f9).
This commit is contained in:
Jgamrot authored and ayozetr committed 2026-10-13 00:48:26 +01:00
1 parent 9e629d2efd
commit 542e9ada19
1 file changed
+4 -2
+4 -2
View File
@@ -162,12 +162,14 @@ void Store(std::atomic<T>& target, T value, bool changed) {
void Checkbox(const char* label, std::atomic<bool>& value) {
bool v = value;
Store(value, v, ImGui::Checkbox(label, &v));
const bool changed = ImGui::Checkbox(label, &v);
Store(value, v, changed);
}
void Slider(const char* label, std::atomic<float>& value, float lo, float hi) {
float v = value;
Store(value, v, ImGui::SliderFloat(label, &v, lo, hi, "%.2f"));
const bool changed = ImGui::SliderFloat(label, &v, lo, hi, "%.2f");
Store(value, v, changed);
}
void Hint(const char* text) {