зеркало из 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.
|
//Get the event queue for the thread.
|
||||||
//rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(mEventQueue));
|
||||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &mEventQueue);
|
|
||||||
|
|
||||||
// If we got an event queue, use it.
|
// If we got an event queue, use it.
|
||||||
if (mEventQueue)
|
if (mEventQueue)
|
||||||
|
@ -201,8 +200,7 @@ NS_METHOD nsAppShell::Spinup()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask again nicely for the event queue now that we have created one.
|
// 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, getter_AddRefs(mEventQueue));
|
||||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &mEventQueue);
|
|
||||||
|
|
||||||
// XXX shouldn't this be automatic?
|
// XXX shouldn't this be automatic?
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
static PRBool gExitMainLoop;
|
static PRBool gExitMainLoop;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsIEventQueue* mEventQueue;
|
nsCOMPtr<nsIEventQueue> mEventQueue;
|
||||||
int mFD;
|
int mFD;
|
||||||
static PRBool mPtInited;
|
static PRBool mPtInited;
|
||||||
|
|
||||||
|
|
|
@ -121,9 +121,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *title = ConvertToFileSystemCharset(mTitle.get());
|
char *title = ToNewUTF8String( mTitle );
|
||||||
if (nsnull == title)
|
|
||||||
title = ToNewCString(mTitle);
|
|
||||||
|
|
||||||
nsCAutoString initialDir;
|
nsCAutoString initialDir;
|
||||||
mDisplayDirectory->GetNativePath(initialDir);
|
mDisplayDirectory->GetNativePath(initialDir);
|
||||||
|
@ -140,7 +138,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
|
|
||||||
char extensionBuffer[MAX_EXTENSION_LENGTH+1] = "*";
|
char extensionBuffer[MAX_EXTENSION_LENGTH+1] = "*";
|
||||||
if( !mFilterList.IsEmpty() ) {
|
if( !mFilterList.IsEmpty() ) {
|
||||||
char *text = ConvertToFileSystemCharset( mFilterList.get( ) );
|
char *text = ToNewUTF8String( mFilterList );
|
||||||
if( text ) {
|
if( text ) {
|
||||||
extensionBuffer[0] = 0;
|
extensionBuffer[0] = 0;
|
||||||
|
|
||||||
|
@ -160,7 +158,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
}
|
}
|
||||||
else if (!mDefaultExtension.IsEmpty()) {
|
else if (!mDefaultExtension.IsEmpty()) {
|
||||||
// Someone was cool and told us what to do
|
// Someone was cool and told us what to do
|
||||||
char *convertedExt = ConvertToFileSystemCharset(mDefaultExtension.get());
|
char *convertedExt = ToNewUTF8String( mDefaultExtension );
|
||||||
if (!convertedExt) {
|
if (!convertedExt) {
|
||||||
mDefaultExtension.ToCString(extensionBuffer, MAX_EXTENSION_LENGTH);
|
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
|
// Set the filter index
|
||||||
|
|
|
@ -82,9 +82,6 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
void GetFilterListArray(nsString& aFilterList);
|
void GetFilterListArray(nsString& aFilterList);
|
||||||
static void GetFileSystemCharset(nsCString & fileSystemCharset);
|
|
||||||
char * ConvertToFileSystemCharset(const nsAString& inString);
|
|
||||||
PRUnichar * ConvertFromFileSystemCharset(const char *inString);
|
|
||||||
|
|
||||||
PtWidget_t *mParentWidget;
|
PtWidget_t *mParentWidget;
|
||||||
nsString mTitle;
|
nsString mTitle;
|
||||||
|
|
|
@ -90,7 +90,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
|
||||||
nsISupports *context,
|
nsISupports *context,
|
||||||
nsresult aStatus,
|
nsresult aStatus,
|
||||||
PRUint32 stringLen,
|
PRUint32 stringLen,
|
||||||
const char *stringData)
|
const PRUint8 *stringData)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче