RTC Forums
November 23, 2024, 10:39:44 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: TRtcObject.Kill method removed  (Read 6314 times)
GeirBerg
RTC License+
****
Posts: 13


« on: April 19, 2017, 03:42:32 PM »

Hi,

We just upgraded to version 7.78 and got a lot of "E2137 Method 'Kill' not found in base class" errors. After searching the forums I've found the changelog for version 7.53 that mentions the removal of the method due to ARC related changes.

My question then is what changes you recommend to our code to resolve this. Should we simply move all the "Kill" code to the destructors, or am I missing something?

Regards.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: April 19, 2017, 03:56:22 PM »

If you download the latest update (v8.00 rc12), you will find out that the TRtcObject class has been removed entirely, because it became obsolete after moving the SingleUse method (introduced with the removal of the Kill method in v7.52) up to the TRtcJob class and changing the TRtcInfo (and with this also the TRtcSession) class by replacing its Obj property (which was used for storing custom objects and relied on the Kill method on objects extending TRtcObject /and later the SingleUse method/ to decide if the object should be freed with the container or not) with a new asObj property (now used to store objects which have to be auto-freed by the container) and a new asPtr property (now used to store pointers to objects which should NOT be auto-freed with the container, because they are managed externally).

To save yourself the hassle of making changes now to compile your code with v7.78 which you will have to change again when you update to v8.00 (which is pretty close to the final release), I'd recommend you to update to the latest v8.00 release candidate and skip anything in-between. Starting with v8.00 rc5, the TRtcObject class no longer exists - because it is no longer needed. If you were extending the TRtcObject class, you will have to update your code based on the rules explained below ...

A) All assignments to "Obj" properties on "TRtcInfo/TRtcSession" containers should be changed to "asObj" or "asPtr", depending on the Object being assigned:
    
   -> "asObj" has to be used for Objects which have to be managed by the object container and destroyed with the "TRtcInfo/TRtcSession" object container. Previously, this was the case with all "TRtcValueObject" descendants and all "TRtcObject" descendants using the default implementation of the "SingleUse" method (returning TRUE), so make sure to check how the Object which was previously assigned to "Obj[]" was implemented. The ONLY exception to this rule are "TRtcDelayedCall" objects, which have previously been declared as "TRtcObject" and are being destroyed by the connection component in case of a disconnect, but should now ONLY be assigned to the new "asPtr" property in all user code, or the Object could now be destroyed twice and result in Access Violations!

   -> "asPtr" has to be used for Components and Objects managed externally, which should NOT be destroyed by the "TRtcInfo/TRtcSession" container. Previously, this was the case for ALL Objects which were NOT direct or indirect descendant of the "TRtcObject" class (TComponent, TObject, ...) Now, this is also the case for "TRtcDelayedCall" objects (see above).
    
B) All classes extending "TRtcObject" should now be updated to extend "TObject" (or any other class, but not "TRtcObject", since it does not exist anymore).

And ... if you were extending the TRtcJob class (which was based on the TRtcObject class before) to post custom jobs to RTC threads, you should move all your code from the "Kill" method to the destructor. If you were using a single TRtcJob instance to post multiple jobs, you should also implement the "SingleUse" method to return FALSE, which would prevent the object from being destroyed. This is similar to leaving the "Kill" method empty (no code).

PS. When updating to the latest version, I recommend reading at least the change summary, because a few things have changed recently which might affect your Projects behavior, even if they don't result in compile errors.

Best Regards,
Danijel Tkalcec
Logged
GeirBerg
RTC License+
****
Posts: 13


« Reply #2 on: April 20, 2017, 08:18:40 AM »

Wow! I guess we'll have to downgrade to the latest non-breaking version then. This sounds like a major rewrite for us which we do not have the time or resources to do right now Sad

But thanks for the explanation anyway.

Regards.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: April 20, 2017, 08:44:52 AM »

If you could provide more informaiton about the way you were using the TRtcObject class, I might be able to provide a solution which wouldn't require too many changes in your code. Since it took me less than 30 minutes to update all RTC SDK and RTC Portal components and Demos to work correctly with the latest v8.00 release, I most definitely didn't expect anyone would have to go through a major rewrite of their code because of these changes in the RTC SDK.

Best Regards,
Danijel Tkalcec
Logged
GeirBerg
RTC License+
****
Posts: 13


« Reply #4 on: April 20, 2017, 09:04:22 AM »

Ok, maybe you are right about it not being a major rewrite. It just sounded like a lot of changes to me at first which I'm not used to when it comes to RTC Wink

But we do use TRtcObject, Obj[], Kill, etc. quite heavily in our project related to (extended) session management, so we don't like to do major changes to it without having the time and resources to properly re-test it afterwards.

We'll stick with a non-breaking version for the time being, but hopefully you are right in that the changes required in the future will be minimal.

Regards.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #5 on: April 20, 2017, 09:48:01 AM »

I'm working on an update now to re-introduce the "TRtcObject" class and the "Obj" property on the "TRtcInfo" and "TRtcSession" classes, which should allow you to compile your Projects using the latest RTC SDK update without making any changes to your code. The only requirement for you will be to add a RTC_OBJECT_CLASS compiler define to your Project(s).

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: April 20, 2017, 12:52:48 PM »

If you download RTC SDK v8.00 rc14 (just released) and declare the compiler define RTC_OBJECT_CLASS in your Project, it should compile and work using this latest update without any manual changes in your code.

Best Regards,
Danijel Tkalcec
Logged
GeirBerg
RTC License+
****
Posts: 13


« Reply #7 on: April 20, 2017, 01:28:50 PM »

Excellent! Thank you very much Smiley

I'm not able to test it right now, but I'll try it out as soon as possible.

PS! Does this mean we can continue to use the code unchanged in future releases, or is this simply meant as a temporary stopgap?

Regards.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #8 on: April 20, 2017, 01:42:54 PM »

Even though I would recommend phasing out any code that relies on the "TRtcObject" class (especially the "Kill" method) and the "Obj" property on "TRtcInfo" and "TRtcSession" classes, if your Applications are only for Windows and you have no intentions on porting them to mobile platforms with ARC (like iOS or Android), you can continue using your code as-is.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.027 seconds with 17 queries.