How do I properly dispose of Constraints?

Hi All,

I’m having some trouble using a ConstraintLayout. The Constraints are sometimes (seemingly randomly) not deallocated properly, which leads to them getting leaked, producing a series of

(gtk_test:1297898): GLib-CRITICAL **: 22:41:25.671: g_ref_count_dec: assertion 'rrc < 0' failed

I presume the issue is in dispose; I’ve tried both the default and a custom implementation, but neither seems to work. What do I need to do to the ConstraintLayout to get it to deallocate all its Constraints properly? I’ve tried

  let mmanager  : Option<ConstraintLayout> = {
    obj.layout_manager().and_then(|m| m.downcast().ok())
  };
  obj.set_layout_manager(None as Option<ConstraintLayout>);
  if let Some(manager) = mmanager {
    manager.remove_all_constraints();
  }

in dispose, but this doesn’t seem to fix the problem.

My example code is here, if you want to take a look.

Also, I’m getting a

malloc_consolidate(): unaligned fastbin chunk detected
Aborted

on a larger example, but I couldn’t replicate this on the smaller extract. This appears to be the same issue, because when I don’t add the Constraints it goes away.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.