Custom Object with Reactors

Custom Object with Reactors

Anonymous
Not applicable
398 Views
2 Replies
Message 1 of 3

Custom Object with Reactors

Anonymous
Not applicable
Hi...
Im quite new to objectARX, so dont laugh if this is a very stupid question... (+;+)

I created a dbx project via the ObjectARX Wizard 2005.
I added my custom object that implements AcDbPoint object...
I want my object to update a certain textfile when it is modified, so I've created a reactor class...
I instantiated the reactor class in the acrxEntryPoint module (In th load event) and attached it to my object in the default constructor of my object (via myObject::addReactor).. I detached it in the deconstructor and delete my reactor pointer in the unload event in the acrxEntryPoint module.
Is this the right approach? cause whenever I create my custom object via arx and unload my dbx I always get an Internal error which causes autocad to crash...
By the way Im using VS.NET 2002 and AutocadMap 2004...

Tnx in advance...


Paul June A. Domag
Solutions Developer
nth geographics and geometrics
0 Likes
399 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Hi, I guess you implemented a transient reactor class rather than a persistent reactor class. To avoid the problem you are having, here is the right approach. - When the application loads, create an instance of the reactor, - Find all instance of the custom class, and attach the reactor to them, - When unloading the application, detach the reactor from all custom class instances you attached the reactor to before. - Delete the reactor instance, Do you really need to detach the reactor from the custom object class destructor? Not really since the subject/reactor link is a one way link. Meaning that a reactor has no clue about its subjects (attached objects) So when your custom object instance is deleted, the link is also destroyed. Your problem with your approach is either: 1- the destructor of your custom object class is called after you deleted the reactor instance 2- the destructor is never called, but you deleted the reactor instance. So the object still tries to notify your reactor which is not there anymore. So you are calling an object which does not exist anymore, and you address an invalid memory address. Since your object is a custom object, you do not need to work with a reactor. You could have implemented the subOpen()/subClose() methods of your class to intercept successful write operation. Doing this will simplify a lot your code and will avoid any problem like the one you had. Also this method will implement a persistent like reactor since it is implemented in the object itself, therefore always active as long the dbx is loaded. And no worry about attaching and releasing code :-) cheers cyrille "nthgg" wrote in message news:8952911.1091812219066.JavaMail.jive@jiveforum2.autodesk.com... > Hi... > Im quite new to objectARX, so dont laugh if this is a very stupid question... (+;+) > > I created a dbx project via the ObjectARX Wizard 2005. > I added my custom object that implements AcDbPoint object... > I want my object to update a certain textfile when it is modified, so I've created a reactor class... > I instantiated the reactor class in the acrxEntryPoint module (In th load event) and attached it to my object in the default constructor of my object (via myObject::addReactor).. I detached it in the deconstructor and delete my reactor pointer in the unload event in the acrxEntryPoint module. > Is this the right approach? cause whenever I create my custom object via arx and unload my dbx I always get an Internal error which causes autocad to crash... > By the way Im using VS.NET 2002 and AutocadMap 2004... > > Tnx in advance... > > > Paul June A. Domag > Solutions Developer > nth geographics and geometrics
0 Likes
Message 3 of 3

Anonymous
Not applicable
Wow, I never realized that...
A million thanks to you Cyrille..
You really made my life easier... Hehehe

Cheers...


Paul June A. Domag
nth geographics and geometrics
Message was edited by: nthgg
0 Likes