THIS is why the contract-based document constructors need to die
Boris Zbarsky <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
They make it way too easy to create an improperly initialized document in the wrong place (non-main thread in this guy's case) and shoot yourself in the foot with it.... -------- Original Message -------- Subject: DOM operation in thread? Date: Thu, 13 Aug 2009 02:37:40 -0700 (PDT) From: DDD <[email protected]> Organization: http://groups.google.com Newsgroups: mozilla.dev.tech.xpcom Hi, I met a special question. The following statements are in a thread. Sometimes it will crash here. ... nsCOMPtr<nsIDOMDocument> doc = nsnull; doc = do_CreateInstance("@mozilla.org/xul/xul-document;1"); nsCOMPtr<nsIDOMText> messageText = nsnull; nsString wStrMessage; rv = doc->CreateTextNode(wStrMessage, getter_AddRefs(messageText)); nsCOMPtr<nsIDOMSerializer> serialize = nsnull; serialize = do_CreateInstance("@mozilla.org/xmlextras/xmlserializer; 1"); nsString xmlStr; rv = serialize->SerializeToString(messageText, xmlStr); ... And here I just wanna convert some special character like <, > to < > etc. These dom operations will not affect any GUI DOM. Any suggestions? Thank you in advance.