firefox addon - Why destructor of an extended binding is not called when extending binding is removed? -



firefox addon - Why destructor of an extended binding is not called when extending binding is removed? -

creating xulrunner application windows found if binding b extends binding a. , b beingness removed, destructor of b called, not followed phone call of a's destructor.

is there wrong code, or xulrunner bug (i haven't find matching bug in bugzilla)?

here illustration tested on xulrunner 23 , 35:

main.xul:

<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window id="main" title="my app" width="500" height="300" sizemode="normal" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> <script><![cdata[ function print(astring) { document.getelementbyid("log_msg").value += astring + "\n"; } function removeelementbyid(aid) { document.getelementbyid(aid).remove(); }; function callf(aid) { document.getelementbyid(aid).f(); } ]]></script> <vbox flex="1"> <label onclick="removeelementbyid('a')">remove a</label> <label onclick="removeelementbyid('b')">remove b</label> <label onclick="callf('a')">call a.f()</label> <label onclick="callf('b')">call b.f()</label> <!--<binding-a id="a" style="-moz-binding: url('binding.xml#binding-a')"/>--> <binding-b id="b" style="-moz-binding: url('binding.xml#binding-b')"/> <textbox id="log_msg" label="text" placeholder="placeholder" multiline="true" rows="6"/> </vbox> </window>

binding.xml:

<?xml version="1.0"?> <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <binding id="binding-a"> <content> <xul:label anonid="label" value="binding a"/> </content> <implementation> <constructor><![cdata[ var label = document.getanonymouselementbyattribute(this, "anonid", "label"); label.value = label.value + " a.constructor"; window.print("a.constructor"); ]]></constructor> <destructor><![cdata[ window.print("a.destructor"); ]]></destructor> <method name="f"> <body><![cdata[ window.print("a.f"); ]]></body> </method> </implementation> </binding> <binding id="binding-b" extends="#binding-a"> <content> <xul:label anonid="label" value="binding b"/> </content> <implementation> <constructor><![cdata[ window.print("b.constructor"); ]]></constructor> <destructor><![cdata[ window.print("b.destructor"); ]]></destructor> </implementation> </binding> </bindings>

here solution problem:

bindings.xml:

<?xml version="1.0"?> <bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <binding id="binding-a"> <content> <xul:label anonid="label" value="binding a"/> </content> <implementation> <constructor><![cdata[ var label = document.getanonymouselementbyattribute(this, "anonid", "label"); label.value = label.value + " a.constructor"; window.print("a.constructor"); ]]></constructor> <destructor><![cdata[ this.destruct(); ]]></destructor> <method name="f"> <body><![cdata[ window.print("a.f"); ]]></body> </method> <method name="destruct"> <body><![cdata[ window.print("a.destructor"); ]]></body> </method> </implementation> </binding> <binding id="binding-b" extends="#binding-a"> <content> <xul:label anonid="label" value="binding b"/> </content> <implementation> <constructor><![cdata[ window.print("b.constructor"); ]]></constructor> <destructor><![cdata[ this.destruct(); ]]></destructor> <method name="destruct"> <body><![cdata[ this.__proto__.__proto__.destruct.call(this); window.print("b.destructor"); ]]></body> </method> </implementation> </binding> </bindings>

bindings.css:

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); binding-a { -moz-binding: url("bindings.xml#binding-a"); } binding-b { -moz-binding: url("bindings.xml#binding-b"); }

main.xul:

<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <?xml-stylesheet href="bindings.css" type="text/css"?> <window id="main" title="my app" width="500" height="300" sizemode="normal" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"> <script><![cdata[ function print(astring) { document.getelementbyid("log_msg").value += astring + "\n"; } function removeelementbyid(aid) { document.getelementbyid(aid).remove(); }; function callf(aid) { document.getelementbyid(aid).f(); } ]]></script> <vbox flex="1"> <label onclick="removeelementbyid('a')">remove a</label> <label onclick="removeelementbyid('b')">remove b</label> <label onclick="callf('a')">call a.f()</label> <label onclick="callf('b')">call b.f()</label> <binding-a id="a"/> <binding-b id="b"/> <textbox id="log_msg" label="text" placeholder="placeholder" multiline="true" rows="6"/> </vbox> </window>

i know hack in fact works.

firefox-addon xul mozilla gecko xulrunner

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -