History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-1071
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: -- --
Assignee: Unassigned
Reporter: John Sundman
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

how to delete an imported library

Created: 28/Nov/05 04:08 AM   Updated: 10/May/07 02:40 PM
Component/s: Documentation
Affects Version/s: 3.1 (aka Denver)
Fix Version/s: 4.0.2

Time Tracking:
Not Specified

Severity: Minor
Runtime: N/A


 Description  « Hide
Sorry, I forgot to attach the code. Here it is.

Marcos
<canvas width="100%" height="100%" debug="true">
    <debug x="10" y="300" width="800" height="300" />

    <import name="form_tenforty_snippet"
            href="1040/form_tenforty.lzx" stage="defer"
            onload="mybutt.handleTenFortyLoad()" />

    <button name="mybutt">Load 1040 now
        <!-- The instance of the form -->
        <attribute name="f" value="null" />
        <attribute name="is_tenforty_loaded" value="false" />
        <method event="onclick">
            if ( this.is_tenforty_loaded ) {
                instantiateTenForty();
            } else {
                form_tenforty_snippet.load();
            }
        </method>

        <method name="handleTenFortyLoad">
            this.is_tenforty_loaded = true;
            instantiateTenForty();
        </method>

        <method name="instantiateTenForty">
            //this.f = new form_tenforty( canvas, {x:40,y:40});
            this.f = new form_tenforty( this, {x:40,y:40});
        </method>
    </button>

    <button x="130">Remove 1040 now
        <method event="onclick">
             mybutt.f.destroy();
             mybutt.setAttribute("f", null);
             delete mybutt.f;
delete form_tenforty_snippet;
             //mybutt.f = null;
             //canvas.f.destroy();
             //canvas.f = null;
        </method>
    </button>

    <button x="280">markObjects
<method event="onclick">
__LzDebug.markObjects();
</method>
    </button>


    <button x="390">findNewObjects
<method event="onclick">
__LzDebug.findNewObjects();
</method>
    </button>


    <button x="520">whyAlive
<method event="onclick">
var foo = __LzDebug.whyAlive();
//foo.toString();
Debug.write("Why Alive: ", foo, foo.toString());
</method>
    </button>

<!--
    <button x="610">backtrace
<method event="onclick">
Debug.backtrace();
</method>
    </button>
-->
</canvas>
_____________

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
John Sundman - 28/Nov/05 06:32 AM

    To 'unload' a snippet, three things have to be done:

    1. Destroy all the instances that were created by the snippet.
    This is done by calling `iii.destroy();` for each instance
    iii. Note that if you have created references to the instance
    outside of the snippet, 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 snippet, you must `delete` those references.

    3. Unload the snippet. This is done by calling
    `sss.unload()`, where sss is the name of the snippet (in the
    import tag).

    At this point, you can re-load the snippet by calling
    `sss.load()`. If you know you will never use the snippet
    again, you can call `sss.destroy();` to remove the snippet
    from your application altogether.

John Sundman - 17/Jan/07 11:29 AM
I'm pretty sure I fixed this a while ago. Please see if you can find it in the Developer's Guide. It should be in the chapter where we explain how to import libraries.

Frisco Del Rosario - 17/Jan/07 04:38 PM
docs/guide/program-structure.html has nothing about deleting imported libraries or unloading snippets.

John Sundman - 20/Apr/07 07:52 AM
Added comments from this bug to the "Structure" chapter.

Mamye Kratt - 10/May/07 02:40 PM
(branches 4.0 build 4954)
Fixed.