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:
Robbert van der Helm
2021-04-28 12:56:49 +02:00
parent 160c6acb85
commit 23f94b35d0
+8 -2
View File
@@ -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;
}