зеркало из https://github.com/mozilla/pjs.git
Changes for qnx/photon platform only. They should not affect building/runtime other platforms.
Bug 240827 Fixed the fd( pipe ) leakeage related to event queues, due to improper handling in nsAppShell for our platform. Also changes for nsFilePicker and nsSound due to changes to nsIFilePicker, nsISound.
This commit is contained in:
Родитель
d31c7d4cba
Коммит
2640e02d30
|
@ -186,8 +186,7 @@ NS_METHOD nsAppShell::Spinup()
|
|||
}
|
||||
|
||||
//Get the event queue for the thread.
|
||||
//rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &mEventQueue);
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
|
||||
// If we got an event queue, use it.
|
||||
if (mEventQueue)
|
||||
|
@ -201,8 +200,7 @@ NS_METHOD nsAppShell::Spinup()
|
|||
}
|
||||
|
||||
// Ask again nicely for the event queue now that we have created one.
|
||||
//rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &mEventQueue);
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||
|
||||
// XXX shouldn't this be automatic?
|
||||
done:
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
static PRBool gExitMainLoop;
|
||||
|
||||
private:
|
||||
nsIEventQueue* mEventQueue;
|
||||
nsCOMPtr<nsIEventQueue> mEventQueue;
|
||||
int mFD;
|
||||
static PRBool mPtInited;
|
||||
|
||||
|
|
|
@ -121,9 +121,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
char *title = ConvertToFileSystemCharset(mTitle.get());
|
||||
if (nsnull == title)
|
||||
title = ToNewCString(mTitle);
|
||||
char *title = ToNewUTF8String( mTitle );
|
||||
|
||||
nsCAutoString initialDir;
|
||||
mDisplayDirectory->GetNativePath(initialDir);
|
||||
|
@ -140,7 +138,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
|||
|
||||
char extensionBuffer[MAX_EXTENSION_LENGTH+1] = "*";
|
||||
if( !mFilterList.IsEmpty() ) {
|
||||
char *text = ConvertToFileSystemCharset( mFilterList.get( ) );
|
||||
char *text = ToNewUTF8String( mFilterList );
|
||||
if( text ) {
|
||||
extensionBuffer[0] = 0;
|
||||
|
||||
|
@ -160,7 +158,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
|||
}
|
||||
else if (!mDefaultExtension.IsEmpty()) {
|
||||
// Someone was cool and told us what to do
|
||||
char *convertedExt = ConvertToFileSystemCharset(mDefaultExtension.get());
|
||||
char *convertedExt = ToNewUTF8String( mDefaultExtension );
|
||||
if (!convertedExt) {
|
||||
mDefaultExtension.ToCString(extensionBuffer, MAX_EXTENSION_LENGTH);
|
||||
}
|
||||
|
@ -353,107 +351,6 @@ nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
|
|||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void nsFilePicker::GetFileSystemCharset(nsCString & fileSystemCharset)
|
||||
{
|
||||
static nsCAutoString aCharset;
|
||||
nsresult rv;
|
||||
|
||||
if (aCharset.Length() < 1) {
|
||||
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aCharset);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error getting platform charset");
|
||||
if (NS_FAILED(rv))
|
||||
aCharset.Assign(NS_LITERAL_CSTRING("windows-1252"));
|
||||
}
|
||||
fileSystemCharset = aCharset;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
char * nsFilePicker::ConvertToFileSystemCharset(const nsAString& inString)
|
||||
{
|
||||
char *outString = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// get file system charset and create a unicode encoder
|
||||
if (nsnull == mUnicodeEncoder) {
|
||||
nsCAutoString fileSystemCharset;
|
||||
GetFileSystemCharset(fileSystemCharset);
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(kCharsetConverterManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = ccm->GetUnicodeEncoderRaw(fileSystemCharset.get(), &mUnicodeEncoder);
|
||||
}
|
||||
}
|
||||
|
||||
// converts from unicode to the file system charset
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 inLength = inString.Length();
|
||||
|
||||
const nsAFlatString& flatInString = PromiseFlatString(inString);
|
||||
|
||||
PRInt32 outLength;
|
||||
rv = mUnicodeEncoder->GetMaxLength(flatInString.get(), inLength,
|
||||
&outLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
outString = NS_STATIC_CAST( char*, nsMemory::Alloc( outLength+1 ) );
|
||||
if (nsnull == outString) {
|
||||
return nsnull;
|
||||
}
|
||||
rv = mUnicodeEncoder->Convert(flatInString.get(), &inLength, outString,
|
||||
&outLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
outString[outLength] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_SUCCEEDED(rv) ? outString : nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
PRUnichar * nsFilePicker::ConvertFromFileSystemCharset(const char *inString)
|
||||
{
|
||||
PRUnichar *outString = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// get file system charset and create a unicode encoder
|
||||
if (nsnull == mUnicodeDecoder) {
|
||||
nsCAutoString fileSystemCharset;
|
||||
GetFileSystemCharset(fileSystemCharset);
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(kCharsetConverterManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = ccm->GetUnicodeDecoderRaw(fileSystemCharset.get(), &mUnicodeDecoder);
|
||||
}
|
||||
}
|
||||
|
||||
// converts from the file system charset to unicode
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 inLength = strlen(inString);
|
||||
PRInt32 outLength;
|
||||
rv = mUnicodeDecoder->GetMaxLength(inString, inLength, &outLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
outString = NS_STATIC_CAST( PRUnichar*, nsMemory::Alloc( (outLength+1) * sizeof( PRUnichar ) ) );
|
||||
if (nsnull == outString) {
|
||||
return nsnull;
|
||||
}
|
||||
rv = mUnicodeDecoder->Convert(inString, &inLength, outString, &outLength);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
outString[outLength] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "error charset conversion");
|
||||
return NS_SUCCEEDED(rv) ? outString : nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Set the filter index
|
||||
|
|
|
@ -82,9 +82,6 @@ protected:
|
|||
|
||||
|
||||
void GetFilterListArray(nsString& aFilterList);
|
||||
static void GetFileSystemCharset(nsCString & fileSystemCharset);
|
||||
char * ConvertToFileSystemCharset(const nsAString& inString);
|
||||
PRUnichar * ConvertFromFileSystemCharset(const char *inString);
|
||||
|
||||
PtWidget_t *mParentWidget;
|
||||
nsString mTitle;
|
||||
|
|
|
@ -90,7 +90,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
|
|||
nsISupports *context,
|
||||
nsresult aStatus,
|
||||
PRUint32 stringLen,
|
||||
const char *stringData)
|
||||
const PRUint8 *stringData)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче