Author Topic: SlickC classes, Object lifetime and DialogInfo  (Read 1531 times)

jporkkahtc

  • Senior Community Member
  • Posts: 1660
  • Hero Points: 154
  • Text
SlickC classes, Object lifetime and DialogInfo
« on: June 01, 2015, 12:37:52 am »
So I'm trying to create a nifty dialog in SlickC.
I noticed some interesting code in "CheckboxTree.e", but I don't understand how it works.


When I try something similar, I get Slick to lock up, apparently due to a recursive object construction.


The real question I guess is class object instances / lifetimes.
From the meager documentation, there is no "new" or "delete", so there is no direct way to create heap instances of a class. If you have an instance as a local, it dies when the function dies.




So, what does this code  in CheckboxTree.e mean?

 
 
   public CheckboxTree(int wid = 0) { m_treeHandle = wid; // this needs to be the last thing done in the constructor, so we always have  // up to date data tieCheckboxToTree(wid); 
}
   [/color]protectedvoid tieCheckboxToTree(int wid) { _SetDialogInfoHt(CHECKBOXTREE, this, m_treeHandle, true); } 
[/color]When I try something similar in my code, I get infinite recursion because the call to "_SetDialogInfoHt" constructs a copy of my object.
[/color]Given the lack of new/delete, I guess this should be what I'd expect, but then that doesn't explain what CheckboxTree is trying to do here, and how it is avoiding my terrible fate.

jporkkahtc

  • Senior Community Member
  • Posts: 1660
  • Hero Points: 154
  • Text
Re: SlickC classes, Object lifetime and DialogInfo
« Reply #1 on: June 01, 2015, 01:14:51 am »
I found out that I was getting into trouble becuase I implemented: sc[/size].[/size]lang[/size].[/size]IAssignTo
With this implemented, Slick calls the constructor, then copy.
Without it implemented, Slick just copies the object (as-if it is calling some hidden copy constructor instead of the CTor+Copy methods).