I want to edit the label of a button (XUL-Element) from a XPCOM component.
But if I try to do this, my Mozilla (1.7.11) crashes. Here's my code:
nsresult res;
nsCOMPtr<nsIWindowMediator> mediator;
nsCID cid = NS_WINDOWMEDIATOR_CID;
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
nsCOMPtr<nsIDOMWindowInternal> mrw;
nsCOMPtr<nsIDOMWindow> ContentWnd;
nsCOMPtr<nsIDOMDocument> xuldocument;
nsCOMPtr<nsIDOMElement> xulelement;
mediator = do_GetService(cid, &res);
if (NS_OK != res)
return res;
res = mediator->GetMostRecentWindow(nsnull, getter_AddRefs(mrw));
if (mrw)
{
res = mrw->GetContent(getter_AddRefs(ContentWnd));
if (ContentWnd)
{
nsCOMPtr<nsIDOMWindowInternal> wnd(do_QueryInterface(ContentWnd));
nsCOMPtr<nsIDOMDocument> xuldoc(do_QueryInterface(xuldocument));
const PRUnichar id[] = {'b','t','n','\0'};
nsEmbedString btn(id);
xuldoc->GetElementById(btn, getter_AddRefs(xulelement));
const PRUnichar str_attribute[] = {'l','a','b','e','l','\0'};
nsEmbedString attribute(str_attribute);
const PRUnichar str_value[] = {'2','0','0','\0'};
nsEmbedString value(str_value);
xulelement->SetAttribute(attribute, value);
}
}
return NS_OK;
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom