Added Ctrl-C handling for issue 479

This commit is contained in:
Nick Bolton 2010-06-01 22:22:58 +00:00
parent 60a428443e
commit 7842596748
8 changed files with 36 additions and 1 deletions

View File

@ -58,6 +58,12 @@ CMSWindowsClientTaskBarReceiver::CMSWindowsClientTaskBarReceiver(
}
CMSWindowsClientTaskBarReceiver::~CMSWindowsClientTaskBarReceiver()
{
cleanup();
}
void
CMSWindowsClientTaskBarReceiver::cleanup()
{
ARCH->removeReceiver(this);
for (UInt32 i = 0; i < kMaxState; ++i) {

View File

@ -33,6 +33,7 @@ public:
virtual void runMenu(int x, int y);
virtual void primaryAction();
virtual const Icon getIcon() const;
void cleanup();
protected:
void copyLog() const;

View File

@ -57,7 +57,8 @@ CMSWindowsServerTaskBarReceiver::CMSWindowsServerTaskBarReceiver(
ARCH->addReceiver(this);
}
CMSWindowsServerTaskBarReceiver::~CMSWindowsServerTaskBarReceiver()
void
CMSWindowsServerTaskBarReceiver::cleanup()
{
ARCH->removeReceiver(this);
for (UInt32 i = 0; i < kMaxState; ++i) {
@ -67,6 +68,11 @@ CMSWindowsServerTaskBarReceiver::~CMSWindowsServerTaskBarReceiver()
destroyWindow();
}
CMSWindowsServerTaskBarReceiver::~CMSWindowsServerTaskBarReceiver()
{
cleanup();
}
void
CMSWindowsServerTaskBarReceiver::showStatus()
{

View File

@ -33,6 +33,7 @@ public:
virtual void runMenu(int x, int y);
virtual void primaryAction();
virtual const Icon getIcon() const;
void cleanup();
protected:
void copyLog() const;

View File

@ -21,6 +21,7 @@
#include "LogOutputters.h"
#include "CMSWindowsScreen.h"
#include "XSynergy.h"
#include "IArchTaskBarReceiver.h"
#include <sstream>
#include <iostream>
@ -29,12 +30,27 @@
CArchAppUtilWindows::CArchAppUtilWindows() :
m_exitMode(kExitModeNormal)
{
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE)
{
throw XArchEvalWindows();
}
}
CArchAppUtilWindows::~CArchAppUtilWindows()
{
}
BOOL WINAPI CArchAppUtilWindows::consoleHandler(DWORD CEvent)
{
// HACK: it would be nice to delete the s_taskBarReceiver object, but
// this is best done by the CApp destructor; however i don't feel like
// opening up that can of worms today... i need sleep.
instance().app().s_taskBarReceiver->cleanup();
ExitProcess(kExitTerminated);
return TRUE;
}
bool
CArchAppUtilWindows::parseArg(const int& argc, const char* const* argv, int& i)
{

View File

@ -17,6 +17,7 @@
#include "CArchAppUtil.h"
#include "CString.h"
#define WIN32_LEAN_AND_MEAN
#include "Windows.h"
#define ARCH_APPUTIL CArchAppUtilWindows
@ -65,4 +66,5 @@ public:
private:
AppExitMode m_exitMode;
static BOOL WINAPI consoleHandler(DWORD CEvent);
};

View File

@ -89,6 +89,8 @@ public:
virtual void updateStatus(INode*, const CString& errorMsg) = 0;
virtual void cleanup() {}
//@}
};

View File

@ -47,6 +47,7 @@ public:
virtual void unlock() const;
virtual const Icon getIcon() const = 0;
virtual std::string getToolTip() const;
virtual void cleanup() {}
protected:
enum EState {