]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix disconnect of listener. 4054/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 8 Mar 2017 21:21:16 +0000 (22:21 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 9 Mar 2017 10:07:14 +0000 (11:07 +0100)
include/deal.II/fe/fe_values.h
source/fe/fe_values.cc

index ce8da006e4eb7d8101ee2eda83430aff94ce90d1..e34675f2f1279bec961ba83be2036beda1338392 100644 (file)
@@ -2628,12 +2628,21 @@ protected:
 
   /**
    * A signal connection we use to ensure we get informed whenever the
-   * triangulation changes. We need to know about that because it invalidates
-   * all cell iterators and, as part of that, the 'present_cell' iterator we
-   * keep around between subsequent calls to reinit() in order to compute the
-   * cell similarity.
+   * triangulation changes by refinement. We need to know about that because
+   * it invalidates all cell iterators and, as part of that, the
+   * 'present_cell' iterator we keep around between subsequent calls to
+   * reinit() in order to compute the cell similarity.
    */
-  boost::signals2::connection tria_listener;
+  boost::signals2::connection tria_listener_refinement;
+
+  /**
+   * A signal connection we use to ensure we get informed whenever the
+   * triangulation changes by mesh transformations. We need to know about that
+   * because it invalidates all cell iterators and, as part of that, the
+   * 'present_cell' iterator we keep around between subsequent calls to
+   * reinit() in order to compute the cell similarity.
+   */
+  boost::signals2::connection tria_listener_mesh_transform;
 
   /**
    * A function that is connected to the triangulation in order to reset the
index f94e2cc1067934ca2feaefc96a228b9053689d55..964b81365f947e10e42979fa6ac52c07540756ed 100644 (file)
@@ -2275,7 +2275,8 @@ FEValuesBase<dim,spacedim>::FEValuesBase (const unsigned int n_q_points,
 template <int dim, int spacedim>
 FEValuesBase<dim,spacedim>::~FEValuesBase ()
 {
-  tria_listener.disconnect ();
+  tria_listener_refinement.disconnect ();
+  tria_listener_mesh_transform.disconnect ();
 }
 
 
@@ -3458,7 +3459,8 @@ FEValuesBase< dim, spacedim >::invalidate_present_cell ()
   // so delete the present cell and
   // disconnect from the signal we have with
   // it
-  tria_listener.disconnect ();
+  tria_listener_refinement.disconnect ();
+  tria_listener_mesh_transform.disconnect ();
   present_cell.reset ();
 }
 
@@ -3479,12 +3481,15 @@ maybe_invalidate_previous_present_cell (const typename Triangulation<dim,spacedi
           // connect to the current one; also invalidate the previous
           // cell because we shouldn't be comparing cells from different
           // triangulations
-          tria_listener.disconnect ();
           invalidate_present_cell();
-          tria_listener =
+          tria_listener_refinement =
             cell->get_triangulation().signals.any_change.connect
             (std_cxx11::bind (&FEValuesBase<dim,spacedim>::invalidate_present_cell,
                               std_cxx11::ref(static_cast<FEValuesBase<dim,spacedim>&>(*this))));
+          tria_listener_mesh_transform =
+            cell->get_triangulation().signals.mesh_movement.connect
+            (std_cxx11::bind (&FEValuesBase<dim,spacedim>::invalidate_present_cell,
+                              std_cxx11::ref(static_cast<FEValuesBase<dim,spacedim>&>(*this))));
         }
     }
   else
@@ -3492,12 +3497,12 @@ maybe_invalidate_previous_present_cell (const typename Triangulation<dim,spacedi
       // if this FEValues has never been set to any cell at all, then
       // at least subscribe to the triangulation to get notified of
       // changes
-      tria_listener =
-        cell->get_triangulation().signals.mesh_movement.connect
+      tria_listener_refinement =
+        cell->get_triangulation().signals.post_refinement.connect
         (std_cxx11::bind (&FEValuesBase<dim,spacedim>::invalidate_present_cell,
                           std_cxx11::ref(static_cast<FEValuesBase<dim,spacedim>&>(*this))));
-      tria_listener =
-        cell->get_triangulation().signals.post_refinement.connect
+      tria_listener_mesh_transform =
+        cell->get_triangulation().signals.mesh_movement.connect
         (std_cxx11::bind (&FEValuesBase<dim,spacedim>::invalidate_present_cell,
                           std_cxx11::ref(static_cast<FEValuesBase<dim,spacedim>&>(*this))));
     }

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.