Page 1 of 1

How to free a subclass of a gadget ?

Posted: Fri Nov 29, 2019 1:57 pm
by Wolfram
I use the following code to build a subclass for two gadgets.
If I close the window and reopen it the program crashes.
I think I have to free the class on closing the window, but I don't know how?

Code: Select all

Procedure SubclassGadget(gadget.i, newClassName.s)
  Protected gadgetClass.i = CocoaMessage(0, GadgetID(gadget), "class")
  Protected newGadgetClass.i

  newGadgetClass = objc_allocateClassPair_(GadgetClass, newClassName, 0)
   objc_registerClassPair_(newGadgetClass)
  object_setClass_(GadgetID(gadget), newGadgetClass)

  ProcedureReturn newGadgetClass
EndProcedure

Re: How to free a subclass of a gadget ?

Posted: Fri Nov 29, 2019 5:26 pm
by mk-soft
Don't forget set to old class!

Code: Select all

  ImportC ""
    objc_disposeClassPair(*Class)
  EndImport
Link: Class-Helper viewtopic.php?f=19&t=72642