-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Howdy :-)

The problem here is discussed in the |nsCOMPtr| user's manual at 

<http://www.mozilla.org/projects/xpcom/nsCOMPtr.html#ref_assert_NoQuery
Needed>

In this case, there are two possible |nsIStreamObserver| interface
pointers present in an |nsFtpControlConnection|.  Querying must always
return the same one (that's an axiom of COM).  Any |nsCOMPtr| (except
an |nsCOMPtr<nsISupports>|) that holds a |nsIStreamObserver| reference
must hold the COM-correct one, i.e., the one that would be returned by
|QueryInterface|.  That's an invariant of |nsCOMPtr|.

Your casts select which |nsIStreamObserver| interface you are trying
to stuff into the |nsCOMPtr|.  The one that happens to select the same
one |QueryInterface| would return succeeds.  The other one fails (at
run-time).

Here's what you need to know: avoid casts, particularly old-style
casts.  If you think you needed to cast, you probably _really_ needed
to query.  You can't rely on the relationship of the C++ types to the
COM types.  Your assignments should read:

  nsCOMPtr<nsISupports> sup1 = NS_STATIC_CAST(nsIStreamListener*,
fcc);
  nsCOMPtr<nsISupports> sup2 = NS_STATIC_CAST(nsIStreamProvider*,
fcc);
  nsCOMPtr<nsIStreamObserver> obs1 = do_QueryInterface(fcc);

Hope this helps,
______________________________________________________________________
Scott Collins                               <http://ScottCollins.net/>





-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.2
Comment: get my key at <http://ScottCollins.net/#key>

iQA/AwUBOnXNv/GmojMuVn+fEQItDACgpUI2Bq3NNr6zu/BleIbXZcEAJ3cAmwXR
N18QHNd3LyQdflhsI4fG+87g
=JGe5
-----END PGP SIGNATURE-----

Reply via email to