ecere:Stacker; extras:SelectorBar: Further fixes to Stacker and SelectorBar addressin...
authorJerome St-Louis <jerome@ecere.com>
Mon, 17 Oct 2011 06:34:45 +0000 (02:34 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 17 Oct 2011 06:34:45 +0000 (02:34 -0400)
* We needed to add a buttons holder to SelectorBar because the Stacker only keeps track of created controls
* Took out the 'delete child' from the Stacker's DestroyChildren(), because all the dereferencing that
was required to match the incref's within the Stacker was done by the controls.Free()
* These fixes are related to the problems http://ecere.com/mantis/view.php?id=656 and http://ecere.com/mantis/view.php?id=657
that led to a revert of the FlipStacker code: https://github.com/ecere/sdk/commit/28a771133cb578c040cf7f6e06588400eb3103ec

ecere/src/gui/controls/Stacker.ec
extras/gui/controls/SelectorBar.ec

index aa228bc..ef18651 100644 (file)
@@ -345,7 +345,7 @@ private:
          {
             child.Destroy(0);
             child.parent = null;
-            delete child;
+            // delete child;
          }
       }
    }
index ee45e63..71e1664 100644 (file)
@@ -26,6 +26,8 @@ static void DrawStipple(Surface surface, Size clientSize)
 
 public class SelectorBar : Stacker
 {
+   // We need this because Stacker incref's only when created
+   Array<SelectorButton> buttonsHolder { };
    direction = horizontal;
    background = activeBorder;
    //tabCycle = true;
@@ -54,8 +56,8 @@ public:
          SelectorButton button = (SelectorButton)it.data;
          button.visible = false;
          button.Destroy(0);
-         delete button;
       }
+      buttonsHolder.Free();
       OnResize(clientSize.w, clientSize.h);
    }
 
@@ -70,6 +72,7 @@ public:
    void AddButton(SelectorButton button)
    {
       incref button;
+      buttonsHolder.Add(button);
       if(created)
       {
          button.Create();
@@ -81,6 +84,7 @@ public:
    void RemoveButton(SelectorButton button)
    {
       Iterator<Window> it { controls };
+      buttonsHolder.TakeOut(button);
       while(it.Next())
       {
          if(button == (SelectorButton)it.data)
@@ -155,6 +159,10 @@ public:
       }
    }
 
+   ~SelectorBar()
+   {
+      Clear();
+   }
 };
 
 public class SelectorButton : Button