зеркало из https://github.com/mozilla/pjs.git
work around crash when starting a download if download folder not specified in IC preferences (e.g. a fresh user account) b=265903 sr=pinkerton
This commit is contained in:
Родитель
e88f57fc42
Коммит
d08ce10f76
|
@ -889,13 +889,31 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
|
|||
err = ::ICStart(&icInstance, 'XPCM');
|
||||
if (err == noErr)
|
||||
{
|
||||
ICAttr attrs;
|
||||
ICFileSpec icFileSpec;
|
||||
long size = kICFileSpecHeaderSize;
|
||||
err = ::ICGetPref(icInstance, kICDownloadFolder, &attrs, &icFileSpec, &size);
|
||||
if (err == noErr || (err == icTruncatedErr && size >= kICFileSpecHeaderSize))
|
||||
// ICGetPref() crashes when getting the download directory if the download
|
||||
// directory has never been specified (e.g. a new user account), bug 265903.
|
||||
// To work around this we enumerate through the IC prefs to see if the
|
||||
// download directory has been specified before trying to obtain it.
|
||||
long numPrefs = 0;
|
||||
err = ::ICCountPref(icInstance, &numPrefs);
|
||||
if (err == noErr)
|
||||
{
|
||||
rv = localMacFile->InitWithFSSpec(&icFileSpec.fss);
|
||||
for ( long i = 0; i < numPrefs; ++i )
|
||||
{
|
||||
Str255 key;
|
||||
err = ::ICGetIndPref(icInstance, i, key);
|
||||
if ( err == noErr && ( PLstrcmp( key, kICDownloadFolder ) == 0 ) )
|
||||
{
|
||||
ICAttr attrs;
|
||||
ICFileSpec icFileSpec;
|
||||
long size = kICFileSpecHeaderSize;
|
||||
err = ::ICGetPref(icInstance, kICDownloadFolder, &attrs, &icFileSpec, &size);
|
||||
if (err == noErr || (err == icTruncatedErr && size >= kICFileSpecHeaderSize))
|
||||
{
|
||||
rv = localMacFile->InitWithFSSpec(&icFileSpec.fss);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
::ICStop(icInstance);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче