refactor: Use mutex to protect m_time in MSWindowsClipboard
This commit is contained in:
parent
698ebc30b3
commit
161b72e43d
2 changed files with 4 additions and 0 deletions
|
|
@ -125,6 +125,7 @@ bool MSWindowsClipboard::open(Time time) const
|
|||
|
||||
for (int i = 0; i < kMaxRetries; ++i) {
|
||||
if (OpenClipboard(m_window)) {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
m_time = time;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -147,6 +148,7 @@ void MSWindowsClipboard::close() const
|
|||
|
||||
IClipboard::Time MSWindowsClipboard::getTime() const
|
||||
{
|
||||
std::scoped_lock lock{m_mutex};
|
||||
return m_time;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "deskflow/IClipboard.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
|
@ -68,6 +69,7 @@ private:
|
|||
using ConverterList = std::vector<IMSWindowsClipboardConverter *>;
|
||||
|
||||
HWND m_window;
|
||||
mutable std::mutex m_mutex;
|
||||
mutable Time m_time;
|
||||
ConverterList m_converters;
|
||||
static UINT s_ownershipFormat;
|
||||
|
|
|
|||
Loading…
Reference in a new issue