From 21c0682e3f98ee8afacff7be90828b05bc6ccb60 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Wed, 14 May 2025 13:13:23 +1000 Subject: fix underflow on input clipboard allow state --- source/game/StarInput.cpp | 5 ++++- source/game/StarInput.hpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source/game') diff --git a/source/game/StarInput.cpp b/source/game/StarInput.cpp index d47045d..dec6705 100644 --- a/source/game/StarInput.cpp +++ b/source/game/StarInput.cpp @@ -688,7 +688,10 @@ unsigned Input::getTag(String const& tagName) const { Input::ClipboardUnlock::ClipboardUnlock(Input& input) : m_input(&input) { ++m_input->m_clipboardAllowed; }; -Input::ClipboardUnlock::~ClipboardUnlock() { --m_input->m_clipboardAllowed; }; +Input::ClipboardUnlock::ClipboardUnlock(ClipboardUnlock&& other) { m_input = take(other.m_input); }; + +Input::ClipboardUnlock::~ClipboardUnlock() { if (m_input) --m_input->m_clipboardAllowed; }; + Input::ClipboardUnlock Input::unlockClipboard() { return Input::ClipboardUnlock(*this); diff --git a/source/game/StarInput.hpp b/source/game/StarInput.hpp index 1746739..05b20eb 100644 --- a/source/game/StarInput.hpp +++ b/source/game/StarInput.hpp @@ -184,6 +184,7 @@ public: class ClipboardUnlock { public: ClipboardUnlock(Input& input); + ClipboardUnlock(ClipboardUnlock&&); ~ClipboardUnlock(); private: -- cgit v1.2.3