diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2008-11-19 11:06:31 -0330 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2008-11-19 11:06:31 -0330 |
commit | 7f24f7fd2361ff5d43775e4523bc78ffdb108306 (patch) | |
tree | 62d26962d53259163ee997a7172af5a8fb550a1d /cpp/src/Slice/JavaUtil.cpp | |
parent | Bug 3541 - Slice signal handling unsafe (diff) | |
download | ice-7f24f7fd2361ff5d43775e4523bc78ffdb108306.tar.bz2 ice-7f24f7fd2361ff5d43775e4523bc78ffdb108306.tar.xz ice-7f24f7fd2361ff5d43775e4523bc78ffdb108306.zip |
Added use of CtrlChandler to slice compilers
Diffstat (limited to 'cpp/src/Slice/JavaUtil.cpp')
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 3179c3df7c5..2a2aac1ca0d 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -27,6 +27,19 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; +// +// Callback for Crtl-C signal handling +// +static Slice::JavaGenerator* _javaGen = 0; + +static void closeCallback() +{ + if(_javaGen != 0) + { + _javaGen->close(); + } +} + Slice::JavaOutput::JavaOutput() { } @@ -110,7 +123,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) path += "/"; } path += file; - SignalHandler::addFile(path); + SignalHandler::addFileForCleanup(path); open(path.c_str()); if(isOpen()) @@ -160,7 +173,7 @@ Slice::JavaGenerator::JavaGenerator(const string& dir) : _dir(dir), _out(0) { - //SignalHandler::setCallback(closeCallback); + SignalHandler::setCloseCallback(closeCallback); } Slice::JavaGenerator::JavaGenerator(const string& dir, Slice::FeatureProfile profile) : @@ -173,6 +186,8 @@ Slice::JavaGenerator::JavaGenerator(const string& dir, Slice::FeatureProfile pro Slice::JavaGenerator::~JavaGenerator() { assert(_out == 0); + + SignalHandler::setCloseCallback(0); } bool @@ -184,6 +199,7 @@ Slice::JavaGenerator::open(const string& absolute) if(out->openClass(absolute, _dir)) { _out = out; + _javaGen = this; // For Ctrl-C handling } else { @@ -198,6 +214,7 @@ Slice::JavaGenerator::close() { assert(_out != 0); *_out << nl; + _javaGen = this; // For Ctrl-C handling delete _out; _out = 0; } |