diff --git a/cmd/launcher/CAdvancedOptions.cpp b/cmd/launcher/CAdvancedOptions.cpp index 6ffb37c4..bd4009b3 100644 --- a/cmd/launcher/CAdvancedOptions.cpp +++ b/cmd/launcher/CAdvancedOptions.cpp @@ -36,6 +36,7 @@ CAdvancedOptions::CAdvancedOptions(HWND parent, CConfig* config) : { assert(s_singleton == NULL); s_singleton = this; + init(); } CAdvancedOptions::~CAdvancedOptions() @@ -95,7 +96,7 @@ CAdvancedOptions::getCommandLine(bool isClient, const CString& serverName) const } void -CAdvancedOptions::init(HWND hwnd) +CAdvancedOptions::init() { // get values from registry HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath()); @@ -110,9 +111,6 @@ CAdvancedOptions::init(HWND hwnd) } CArchMiscWindows::closeKey(key); } - - // now set GUI - doInit(hwnd); } void @@ -194,7 +192,7 @@ CAdvancedOptions::doDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM) { switch (message) { case WM_INITDIALOG: - init(hwnd); + doInit(hwnd); return TRUE; case WM_COMMAND: diff --git a/cmd/launcher/CAdvancedOptions.h b/cmd/launcher/CAdvancedOptions.h index e4106f44..c86bf38a 100644 --- a/cmd/launcher/CAdvancedOptions.h +++ b/cmd/launcher/CAdvancedOptions.h @@ -54,7 +54,7 @@ public: //@} private: - void init(HWND hwnd); + void init(); void doInit(HWND hwnd); bool save(HWND hwnd); void setDefaults(HWND hwnd); diff --git a/cmd/synergyc/CMSWindowsClientTaskBarReceiver.cpp b/cmd/synergyc/CMSWindowsClientTaskBarReceiver.cpp index 47561edd..3bfd5816 100644 --- a/cmd/synergyc/CMSWindowsClientTaskBarReceiver.cpp +++ b/cmd/synergyc/CMSWindowsClientTaskBarReceiver.cpp @@ -190,7 +190,7 @@ CMSWindowsClientTaskBarReceiver::copyLog() const if (!data.empty()) { CMSWindowsClipboard clipboard(m_window); clipboard.open(0); - clipboard.empty(); + clipboard.emptyUnowned(); clipboard.add(IClipboard::kText, data); clipboard.close(); } diff --git a/cmd/synergys/CMSWindowsServerTaskBarReceiver.cpp b/cmd/synergys/CMSWindowsServerTaskBarReceiver.cpp index 87f3d298..ca6525ef 100644 --- a/cmd/synergys/CMSWindowsServerTaskBarReceiver.cpp +++ b/cmd/synergys/CMSWindowsServerTaskBarReceiver.cpp @@ -210,7 +210,7 @@ CMSWindowsServerTaskBarReceiver::copyLog() const if (!data.empty()) { CMSWindowsClipboard clipboard(m_window); clipboard.open(0); - clipboard.empty(); + clipboard.emptyUnowned(); clipboard.add(IClipboard::kText, data); clipboard.close(); } diff --git a/lib/arch/CArchLogWindows.cpp b/lib/arch/CArchLogWindows.cpp index 6c7ebbc4..6d21d6ba 100644 --- a/lib/arch/CArchLogWindows.cpp +++ b/lib/arch/CArchLogWindows.cpp @@ -20,7 +20,7 @@ // CArchLogWindows // -CArchLogWindows::CArchLogWindows() +CArchLogWindows::CArchLogWindows() : m_eventLog(NULL) { // do nothing } @@ -33,7 +33,7 @@ CArchLogWindows::~CArchLogWindows() void CArchLogWindows::openLog(const char* name) { - if (!CArchMiscWindows::isWindows95Family()) { + if (m_eventLog == NULL && !CArchMiscWindows::isWindows95Family()) { m_eventLog = RegisterEventSource(NULL, name); } } diff --git a/lib/platform/CMSWindowsClipboard.cpp b/lib/platform/CMSWindowsClipboard.cpp index 1f3fd408..5f4c7675 100644 --- a/lib/platform/CMSWindowsClipboard.cpp +++ b/lib/platform/CMSWindowsClipboard.cpp @@ -43,7 +43,7 @@ CMSWindowsClipboard::~CMSWindowsClipboard() } bool -CMSWindowsClipboard::empty() +CMSWindowsClipboard::emptyUnowned() { LOG((CLOG_DEBUG "empty clipboard")); @@ -53,6 +53,16 @@ CMSWindowsClipboard::empty() return false; } + return true; +} + +bool +CMSWindowsClipboard::empty() +{ + if (!emptyUnowned()) { + return false; + } + // mark clipboard as being owned by synergy HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1); SetClipboardData(getOwnershipFormat(), data); diff --git a/lib/platform/CMSWindowsClipboard.h b/lib/platform/CMSWindowsClipboard.h index ce7ba724..e9b59fb9 100644 --- a/lib/platform/CMSWindowsClipboard.h +++ b/lib/platform/CMSWindowsClipboard.h @@ -28,6 +28,21 @@ public: CMSWindowsClipboard(HWND window); virtual ~CMSWindowsClipboard(); + //! Empty clipboard without ownership + /*! + Take ownership of the clipboard and clear all data from it. + This must be called between a successful open() and close(). + Return false if the clipboard ownership could not be taken; + the clipboard should not be emptied in this case. Unlike + empty(), isOwnedBySynergy() will return false when emptied + this way. This is useful when synergy wants to put data on + clipboard but pretend (to itself) that some other app did it. + When using empty(), synergy assumes the data came from the + server and doesn't need to be sent back. emptyUnowned() + makes synergy send the data to the server. + */ + bool emptyUnowned(); + //! Test if clipboard is owned by synergy static bool isOwnedBySynergy();