mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Fix move semantics in Win32Thread and Win32Timer
I was sure that moving an `std::optional<T>` would reset the object you moved from, but apparently not.
This commit is contained in:
@@ -39,10 +39,13 @@ win32_thread_trampoline(fu2::unique_function<void()>* entry_point) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Win32Thread::Win32Thread(Win32Thread&& o) : handle(std::move(o.handle)) {}
|
||||
Win32Thread::Win32Thread(Win32Thread&& o) : handle(std::move(o.handle)) {
|
||||
o.handle.reset();
|
||||
}
|
||||
|
||||
Win32Thread& Win32Thread::operator=(Win32Thread&& o) {
|
||||
handle = std::move(o.handle);
|
||||
o.handle.reset();
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -71,11 +74,14 @@ Win32Timer::~Win32Timer() {
|
||||
}
|
||||
|
||||
Win32Timer::Win32Timer(Win32Timer&& o)
|
||||
: window_handle(o.window_handle), timer_id(std::move(o.timer_id)) {}
|
||||
: window_handle(o.window_handle), timer_id(std::move(o.timer_id)) {
|
||||
o.timer_id.reset();
|
||||
}
|
||||
|
||||
Win32Timer& Win32Timer::operator=(Win32Timer&& o) {
|
||||
window_handle = o.window_handle;
|
||||
timer_id = std::move(o.timer_id);
|
||||
o.timer_id.reset();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user