Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get url & crash firefox

3 views
Skip to first unread message

Gailin

unread,
Oct 11, 2006, 6:58:38 AM10/11/06
to
Hello !

I'm developping an XPCOM component for firefox.
In my component, when I try to get the path and the prePath of the url
of the current page, firefox crashs ....

Code:

OnStateChange(nsIWebProgress* aWebProgress, nsIRequest*
aRequest,PRUint32 aStateFlags, nsresult aStatus)
{

[....]

nsCOMPtr<nsIDOMWindow> domWin;
nsresult rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWin));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocument> domDoc;
domWin->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc); //
the htmlDoc is valid

nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
nsCAutoString prePath, path;

doc->GetDocumentURI()->GetPrePath(prePath); //here firefox crash he
can't get the prePath
doc->GetDocumentURI()->GetPath(path);

[....]

}

It seems firefox can't get the nsIDocument from the nsIDOMDocument and
so when he attempts to get the path on the execution, he crashs..

Code:
/usr/bin/firefox: line 159: Segmentation fault $AOSS $MOZ_PROGRAM $@

I'm on Suse 10.1 installed on a VMware, but this component ( and this
code) works fine on Window .....
Anybody have clues or ideas for solve my problem ... ?

Michal Ceresna

unread,
Oct 11, 2006, 8:18:48 AM10/11/06
to dev-tec...@lists.mozilla.org
On Wednesday 11 October 2006 12:58, Gailin wrote:
Hello,

> doc->GetDocumentURI()->GetPrePath(prePath); //here firefox crash he

Most probably, the document uri will be null:

/**
* Return the URI for the document. May return null.
*/
nsIURI* GetDocumentURI() const

michal

Gailin

unread,
Oct 11, 2006, 9:36:36 AM10/11/06
to

Yes, yes, but in fact this code works on Windows, I can get the URI
(and the URL) correctly.
However, on Suse 10.1 it causes firefox crash and I want to know why
it's not working on Suse !

In addition, this is a basic code, that's why, i don't understand, why
this code isn't effective on linux !

Boris Zbarsky

unread,
Oct 11, 2006, 10:18:43 AM10/11/06
to
Gailin wrote:
> nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);

Do you get a non-null "doc"?

> doc->GetDocumentURI()->GetPrePath(prePath); //here firefox crash he

Which exact version of nsIDocument.h are you compiling against? Which exact
version of Firefox are you running against?

-Boris

Gailin

unread,
Oct 11, 2006, 10:56:14 AM10/11/06
to

Boris Zbarsky a écrit :

Ok Boris :

- No, I get a null "doc", but I get a valid (non-null) "htmlDoc" ....
strange !
- I'm running with the 1.5.0.3 version of firefox. This is the version
automatically installed with GNOME ( on Suse )
- I get the source from the CVS server with the appropriate commands
describes here :
http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS !
So I think I have the last version of nsIDocument.h.
But if you want to see the file :
http://membres.lycos.fr/gailin24px/ff/nsIDocument.h

Thx !

Boris Zbarsky

unread,
Oct 11, 2006, 11:10:10 AM10/11/06
to
Gailin wrote:
> - No, I get a null "doc", but I get a valid (non-null) "htmlDoc" ....
> strange !

Not at all, given the version skew.

> - I'm running with the 1.5.0.3 version of firefox. This is the version
> automatically installed with GNOME ( on Suse )

OK. So that's
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/content/base/public/nsIDocument.h&rev=MOZILLA_1_8_0_3_RELEASE
-- note the value of NS_IDOCUMENT_IID.

> - I get the source from the CVS server with the appropriate commands
> describes here :
> http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS !

Using the branch tag that matches your Firefox version?

> So I think I have the last version of nsIDocument.h.

Which is not compatible with Gecko 1.8.0.3.

> But if you want to see the file :
> http://membres.lycos.fr/gailin24px/ff/nsIDocument.h

Yes, that's the current trunk version. Notice the different value of
NS_IDOCUMENT_IID.

Sounds like things are working correctly -- you're asking a branch Firefox for a
trunk nsIDocument, and it doesn't have one. So it returns null.

I suggest developing against headers that match the branch you want to work with.

-Boris

Gailin

unread,
Oct 17, 2006, 8:41:24 AM10/17/06
to

Yeah !! it works fine now !!!! PERFECT !!

thx a lot boris ;)

0 new messages