]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix signal handling of transfinite interpolation once cleared. 6227/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 12 Apr 2018 08:10:46 +0000 (10:10 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 12 Apr 2018 08:17:29 +0000 (10:17 +0200)
include/deal.II/grid/manifold_lib.h
source/grid/manifold_lib.cc

index a81d837c074f1ee363de2b4e65a2683882e87ce5..e2679fa140a482e5e807c22ebabfd859cff5c217 100644 (file)
@@ -831,6 +831,11 @@ public:
    */
   TransfiniteInterpolationManifold();
 
+  /**
+   * Destructor.
+   */
+  ~TransfiniteInterpolationManifold();
+
   /**
    * Make a clone of this Manifold object.
    */
@@ -996,6 +1001,12 @@ private:
    * use a FlatManifold description.
    */
   FlatManifold<dim> chart_manifold;
+
+  /**
+   * The connection to Triangulation::signals::clear that must be reset once
+   * this class goes out of scope.
+   */
+  boost::signals2::connection clear_signal;
 };
 
 DEAL_II_NAMESPACE_CLOSE
index ea5f129b645ea3a78efe712a467bc5d097f7295a..ab2178a4736ff6ddc9ec1aec034ed9e65574d3fa 100644 (file)
@@ -1347,6 +1347,15 @@ TransfiniteInterpolationManifold<dim,spacedim>::TransfiniteInterpolationManifold
 
 
 
+template <int dim, int spacedim>
+TransfiniteInterpolationManifold<dim,spacedim>::~TransfiniteInterpolationManifold()
+{
+  if (clear_signal.connected())
+    clear_signal.disconnect();
+}
+
+
+
 template<int dim, int spacedim>
 std::unique_ptr<Manifold<dim, spacedim> >
 TransfiniteInterpolationManifold<dim,spacedim>::clone() const
@@ -1366,8 +1375,8 @@ TransfiniteInterpolationManifold<dim,spacedim>
 {
   this->triangulation = &triangulation;
   // in case the triangulatoin is cleared, remove the pointers by a signal
-  triangulation.signals.clear.connect
-  ([&]() -> void {this->triangulation = nullptr; this->level_coarse = -1;});
+  clear_signal = triangulation.signals.clear.connect
+                 ([&]() -> void {this->triangulation = nullptr; this->level_coarse = -1;});
   level_coarse = triangulation.last()->level();
   coarse_cell_is_flat.resize(triangulation.n_cells(level_coarse), false);
   typename Triangulation<dim,spacedim>::active_cell_iterator

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.