Bug 715129 File picker can't pick applications on Vista or later r=jimm

This commit is contained in:
Neil Rashbrook 2012-01-04 20:30:57 +00:00
Родитель 251b52b924
Коммит 7094293673
2 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@ -1340,15 +1340,12 @@ nsFilePicker::IsDefaultPathHtml()
void
nsFilePicker::ComDlgFilterSpec::Append(const nsAString& aTitle, const nsAString& aFilter)
{
PRUint32 size = sizeof(COMDLG_FILTERSPEC);
PRUint32 hdrLen = size * (mLength + 1);
mSpecList = (COMDLG_FILTERSPEC*)realloc(mSpecList, hdrLen);
if (!mSpecList) {
COMDLG_FILTERSPEC* pSpecForward = mSpecList.AppendElement();
if (!pSpecForward) {
NS_WARNING("mSpecList realloc failed.");
return;
}
COMDLG_FILTERSPEC* pSpecForward = (COMDLG_FILTERSPEC*)(mSpecList + mLength);
memset(pSpecForward, 0, size);
memset(pSpecForward, 0, sizeof(*pSpecForward));
nsString* pStr = mStrings.AppendElement(aTitle);
if (!pStr) {
NS_WARNING("mStrings.AppendElement failed.");
@ -1360,6 +1357,12 @@ nsFilePicker::ComDlgFilterSpec::Append(const nsAString& aTitle, const nsAString&
NS_WARNING("mStrings.AppendElement failed.");
return;
}
if (aFilter.EqualsLiteral("..apps"))
pStr->AssignLiteral("*.exe;*.com");
else {
pStr->StripWhitespace();
if (pStr->EqualsLiteral("*"))
pStr->AppendLiteral(".*");
}
pSpecForward->pszSpec = pStr->get();
mLength++;
}

Просмотреть файл

@ -160,30 +160,25 @@ protected:
class ComDlgFilterSpec
{
public:
ComDlgFilterSpec() :
mSpecList(nsnull),
mLength(0) {}
~ComDlgFilterSpec() {
free(mSpecList);
}
ComDlgFilterSpec() {}
~ComDlgFilterSpec() {}
const PRUint32 Length() {
return mLength;
return mSpecList.Length();
}
const bool IsEmpty() {
return (mLength == 0);
return (mSpecList.Length() == 0);
}
const COMDLG_FILTERSPEC* get() {
return mSpecList;
return mSpecList.Elements();
}
void Append(const nsAString& aTitle, const nsAString& aFilter);
private:
COMDLG_FILTERSPEC* mSpecList;
nsAutoTArray<COMDLG_FILTERSPEC, 1> mSpecList;
nsAutoTArray<nsString, 2> mStrings;
PRUint32 mLength;
};
ComDlgFilterSpec mComFilterList;