summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cppe/Gen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cppe/Gen.cpp')
-rw-r--r--cpp/src/slice2cppe/Gen.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp
index c9e77de1445..8455816dbbc 100644
--- a/cpp/src/slice2cppe/Gen.cpp
+++ b/cpp/src/slice2cppe/Gen.cpp
@@ -2078,6 +2078,17 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
}
+ //
+ // We add a protected destructor to force heap instantiation of the class.
+ //
+ if(!p->isAbstract())
+ {
+ H.dec();
+ H << sp << nl << "protected:";
+ H.inc();
+ H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
+ }
+
H << eb << ';';
if(!p->isLocal())