From 1ebf77ee7946dd4b83bd1a903b4e4801d17329fb Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Wed, 16 Jun 1999 00:00:55 +0000 Subject: [PATCH] Bug #8221 fix memory problems with nsCOMPtr & using do_QI around methods. We were also making a com ptr out of a non interface so I added a dirty hack to fix that. git-svn-id: svn://10.0.0.236/trunk@35554 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/mailnews/compose/src/nsMsgQuote.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mozilla/mailnews/compose/src/nsMsgQuote.cpp b/mozilla/mailnews/compose/src/nsMsgQuote.cpp index 4a026158ee0..5b05a42ac10 100644 --- a/mozilla/mailnews/compose/src/nsMsgQuote.cpp +++ b/mozilla/mailnews/compose/src/nsMsgQuote.cpp @@ -230,15 +230,22 @@ SaveQuoteMessageCompleteCallback(nsIURL *aURL, nsresult aExitCode, void *tagData // This is the producer stream that will deliver data from the disk file... // ...someday, we'll just get streams from Necko. - nsCOMPtr in = do_QueryInterface(new FileInputStreamImpl()); - if (!in) + // mscott --> the type for a nsCOMPtr needs to be an interface. + // but this class (which is only temporary anyway) is mixing and matching + // interface calls and implementation calls....so you really can't use a + // com ptr. to get around it, I'm using fileStream to make calls on the + // methods that aren't supported by the nsIInputStream and "in" for + // methods that are supported as part of the interface... + FileInputStreamImpl * fileStream = new FileInputStreamImpl(); + nsCOMPtr in = do_QueryInterface(fileStream); + if (!in || !fileStream) { NS_RELEASE(ptr); printf("Failed to create nsIInputStream\n"); return NS_ERROR_FAILURE; } - if (NS_FAILED(in->OpenDiskFile(*(ptr->mTmpFileSpec)))) + if (NS_FAILED(fileStream->OpenDiskFile(*(ptr->mTmpFileSpec)))) { NS_RELEASE(ptr); printf("Unable to open input file\n"); @@ -257,7 +264,7 @@ SaveQuoteMessageCompleteCallback(nsIURL *aURL, nsresult aExitCode, void *tagData mimeParser->OnStartBinding(aURL, MESSAGE_RFC822); // Just pump all of the data from the file into libmime... - while (NS_SUCCEEDED(in->PumpFileStream())) + while (NS_SUCCEEDED(fileStream->PumpFileStream())) { PRUint32 len; in->GetLength(&len);