diff options
Diffstat (limited to 'cpp/src/slice2cs/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 8cd18659005..ac5f55098d0 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -39,6 +39,19 @@ using IceUtilInternal::eb; using IceUtilInternal::spar; using IceUtilInternal::epar; +// +// Callback for Crtl-C signal handling +// +static Gen* _gen = 0; + +static void closeCallback() +{ + if(_gen != 0) + { + _gen->closeOutput(); + } +} + static string // Should be an anonymous namespace, but VC++ 6 can't handle that. sliceModeToIceMode(Operation::Mode opMode) { @@ -1059,6 +1072,9 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in : _includePaths(includePaths), _stream(stream) { + _gen = this; + SignalHandler::setCloseCallback(closeCallback); + string fileBase = base; string::size_type pos = base.find_last_of("/\\"); if(pos != string::npos) @@ -1073,9 +1089,8 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in file = dir + '/' + file; fileImpl = dir + '/' + fileImpl; } - SignalHandler::addFile(file); - SignalHandler::addFile(fileImpl); + SignalHandler::addFileForCleanup(file); _out.open(file.c_str()); if(!_out) { @@ -1111,6 +1126,8 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl; return; } + + SignalHandler::addFileForCleanup(fileImpl); _impl.open(fileImpl.c_str()); if(!_impl) { @@ -1130,6 +1147,8 @@ Slice::Gen::~Gen() { _impl << '\n'; } + + SignalHandler::setCloseCallback(0); } bool |