diff options
Diffstat (limited to 'cpp/src/slice2docbook/Gen.cpp')
-rw-r--r-- | cpp/src/slice2docbook/Gen.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp index 926c4f4e434..3f634dbef1f 100644 --- a/cpp/src/slice2docbook/Gen.cpp +++ b/cpp/src/slice2docbook/Gen.cpp @@ -9,6 +9,7 @@ #include <IceUtil/DisableWarnings.h> #include <IceUtil/Functional.h> +#include <Slice/SignalHandler.h> #include <Gen.h> #ifdef __BCPLUSPLUS__ @@ -20,12 +21,28 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; +// +// Callback for Crtl-C signal handling +// +static Gen* _gen = 0; + +static void closeCallback() +{ + if(_gen != 0) + { + _gen->closeOutput(); + } +} + Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool chapter, bool noIndex, bool sortFields) : _standAlone(standAlone), _noIndex(noIndex), _sortFields(sortFields) { + _gen = this; + SignalHandler::setCallback(closeCallback); + if(chapter) { _chapter = "chapter"; @@ -45,6 +62,7 @@ Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool ch Slice::Gen::~Gen() { + SignalHandler::setCallback(0); } bool @@ -67,6 +85,12 @@ Slice::Gen::generate(const UnitPtr& p) p->visit(this, false); } +void +Slice::Gen::closeOutput() +{ + O.close(); +} + bool Slice::Gen::visitUnitStart(const UnitPtr& p) { |