Closed Bug 376847 Opened 17 years ago Closed 6 years ago

Can't QueryInterface for some interfaces from a pyxpcom component until the same object is "touched" by javascript

Categories

(Other Applications Graveyard :: PyXPCOM, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: glandium, Unassigned)

Details

This has been filed as debian bug #416114.

The testcase is basically a xulrunner application with the following chrome
>>>>>>>>> xultest.xul :
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="mainWindow" 
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
orient="vertical" title="window1">
   <textbox id="TheTextBox" flex="1" readonly="true" value="Hello XUL" />
   <script type="application/x-javascript">
     var thing = 
Components.classes['@heaven.is/myXulTest;1'].createInstance(Components.interfaces.myXulTest);
     thing.setDocument(document);
   </script>
</window>

And following component
 >>>>>>>> myXulTest.idl :
#include "nsIDOMDocument.idl"
[scriptable, uuid(ad7f063b-40ee-46ae-87b4-6ed6b56695a0)]
interface myXulTest : nsISupports
{
   void setDocument( in nsIDOMDocument document );
};

 >>>>>>> myXulTest.py :
from xpcom import components

class myXulTest:
     _com_interfaces_ = components.interfaces.myXulTest
     _reg_clsid_ = "{ad7f063b-40ee-46ae-87b4-6ed6b56695a0}"
     _reg_contractid_ = "@heaven.is/myXulTest;1"

     def setDocument(self,document) :
         pyelement = 
document.getElementById('TheTextBox').QueryInterface(components.interfaces.nsIDOMXULTextBoxElement)
         pyelement.value = 'Hello pyelement'

Running this application, an exception is thrown by the QueryInterface in the python code:

xulrunner application.ini
** Unhandled exception calling 'int8 setDocument(in nsISomething);'
Traceback (most recent call last):
   File "/var/lib/python-support/python2.4/xpcom/server/policy.py", line 
272, in _CallMethod_
     return 0, func(*params)
   File "/tmp/xultest/components/myXulTest.py", line 9, in setDocument
     pyelement = 
document.getElementById('TheTextBox').QueryInterface(components.interfaces.nsIDOMXULTextBoxElement)
   File "/var/lib/python-support/python2.4/xpcom/client/__init__.py", 
line 300, in QueryInterface
     ret = self._comobj_.QueryInterface(iid, 0)
Exception: 0x-7fffbffe (NS_ERROR_NO_INTERFACE)
** Returning nsresult of NS_ERROR_FAILURE

Adding a 'document.getElementById("TheTextBox");' before the 'thing.setDocument(document);' in the xul file makes it work.
still applies on trunk
Version: 1.8 Branch → Trunk
Component: XPCOM → PyXPCOM
Product: Core → Other Applications
QA Contact: xpcom → pyxpcom
Version: Trunk → unspecified
Component is obsolete so resolving bugs as INCOMPLETE[B
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INCOMPLETE
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.