User classes are no longer Node's so they do not support the destroy method. It should be sufficient to delete them, as Robert has suggested. Unloading of a dynamic library has always been a little sketchy, so maybe there is some cleanup to be done to make it work again now that user classes are actual classes.

You could try using the memory tracing tools around loading/unloading to see if you can figure out why the dynamic class is being kept.

On 2008-07-14, at 09:12 EDT, Cary Clark wrote:

Robert Yeager suggested that I try:
      if (global[classname] != null) delete global[classname];
      if (lz[classname] != null) delete lz[classname];

While I don't get an error when these execute as I did when using the destroy() method, I do get the same warnings/info message when I load() the library again about the classes already being defined. Any other suggestions?

Thanks,
Cary


Cary Clark wrote:
I've put some optional code of my app into a dynamic library. When an instance of one of the classes is needed, I do a load on the library and create the instance after the onload() handler. I've been reading the Software Engineer's Guide, aka Developer's Guide, in 15.5 "Deleting Imported Libraries". It's pretty short, so I'll include it here:


  5. Deleting Imported Libraries

To 'unload' an imported library, three things have to be done:

 1.

    Destroy all the instances that were created by the library. This
    is done by calling |iii.destroy();| for each instance |iii|. Note
that if you have created references to the instance outside of the
    library, you must delete those references.

 2.

Destroy all classes that were created by the snippet. This is done by calling |ccc.destroy();| for each class |ccc|. Note that if you
    have created references to the class outside of the library, you
    must delete those references.

 3.

    Unload the library. This is done by calling |sss.unload()`| where
    |sss| is the name of the library (in the import tag).

-----------------------------------------
I have run destroy() on the instances of the classes from the imported library.

I'm not being successful on step 2. I'm running OL 4.0.12 and tried lz['employeeMaintenanceWindow'].destroy() but get the dreaded "ERROR @vr.lzx#600: call to undefined method 'destroy'". I can write to the debug console the class name and reference:

global class employeeMaintenanceWindow is «¡¿Class?!#12| lz.employeeMaintenanceWindow».

I am able to do step 3 and run the unload() of the library using the name from the import. However, when I run code that needs a class from the library and I load() it again, I get these warnings:

snippetLoaded loadmc= «LoadObj#2| undefined (loading)» «LzLibraryLoader#18| undefined (loading)» WARNING: Redefining tag employeeMaintenanceWindow from lz.employeeMaintenanceWindow to employeeMaintenanceWindow INFO: The global `employeeMaintenanceWindow` is already defined. To dynamically create a <employeeMaintenanceWindow> element, you will have to use `lz.employeeMaintenanceWindow`.

What's the syntax that I should use to remove the global class definition? Or is it still a requirement to do that?...or am I just misunderstanding something...

Thanks,
Cary




Reply via email to