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() CMSWindowsClientTaskBarReceiver::~CMSWindowsClientTaskBarReceiver()
{
cleanup();
}
void
CMSWindowsClientTaskBarReceiver::cleanup()
{ {
ARCH->removeReceiver(this); ARCH->removeReceiver(this);
for (UInt32 i = 0; i < kMaxState; ++i) { for (UInt32 i = 0; i < kMaxState; ++i) {

View File

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

View File

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

View File

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

View File

@ -21,6 +21,7 @@
#include "LogOutputters.h" #include "LogOutputters.h"
#include "CMSWindowsScreen.h" #include "CMSWindowsScreen.h"
#include "XSynergy.h" #include "XSynergy.h"
#include "IArchTaskBarReceiver.h"
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
@ -29,12 +30,27 @@
CArchAppUtilWindows::CArchAppUtilWindows() : CArchAppUtilWindows::CArchAppUtilWindows() :
m_exitMode(kExitModeNormal) m_exitMode(kExitModeNormal)
{ {
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE) == FALSE)
{
throw XArchEvalWindows();
}
} }
CArchAppUtilWindows::~CArchAppUtilWindows() 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 bool
CArchAppUtilWindows::parseArg(const int& argc, const char* const* argv, int& i) CArchAppUtilWindows::parseArg(const int& argc, const char* const* argv, int& i)
{ {

View File

@ -17,6 +17,7 @@
#include "CArchAppUtil.h" #include "CArchAppUtil.h"
#include "CString.h" #include "CString.h"
#define WIN32_LEAN_AND_MEAN
#include "Windows.h" #include "Windows.h"
#define ARCH_APPUTIL CArchAppUtilWindows #define ARCH_APPUTIL CArchAppUtilWindows
@ -65,4 +66,5 @@ public:
private: private:
AppExitMode m_exitMode; 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 updateStatus(INode*, const CString& errorMsg) = 0;
virtual void cleanup() {}
//@} //@}
}; };

View File

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