mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 214026 addressbook crashes sorting empty values r=smontagu sr=bienvenu
This commit is contained in:
parent
bdee623d7e
commit
d5636b503e
@ -762,46 +762,6 @@ nsresult nsAbView::GenerateCollationKeysForCard(const PRUnichar *colID, AbCard *
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsXPIDLString value;
|
nsXPIDLString value;
|
||||||
|
|
||||||
rv = GetCardValue(abcard->card, colID, getter_Copies(value));
|
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
|
||||||
|
|
||||||
// XXX todo
|
|
||||||
// be smarter about the allocation, use an arena?
|
|
||||||
if (abcard->primaryCollationKey)
|
|
||||||
nsMemory::Free(abcard->primaryCollationKey);
|
|
||||||
rv = CreateCollationKey(value, &(abcard->primaryCollationKey), &(abcard->primaryCollationKeyLen));
|
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
|
||||||
|
|
||||||
// XXX todo
|
|
||||||
// fix me, do this with a const getter, to avoid the strcpy
|
|
||||||
|
|
||||||
// hardcode email to be our secondary key
|
|
||||||
rv = GetCardValue(abcard->card, NS_LITERAL_STRING(kPriEmailColumn).get(), getter_Copies(value));
|
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
|
||||||
|
|
||||||
// XXX todo
|
|
||||||
// be smarter about the allocation, use an arena?
|
|
||||||
if (abcard->secondaryCollationKey)
|
|
||||||
nsMemory::Free(abcard->secondaryCollationKey);
|
|
||||||
rv = CreateCollationKey(value, &(abcard->secondaryCollationKey), &(abcard->secondaryCollationKeyLen));
|
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsAbView::CreateCollationKey(const PRUnichar *aSource, PRUint8 **aKey, PRUint32 *aKeyLen)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aKey);
|
|
||||||
NS_ENSURE_ARG_POINTER(aKeyLen);
|
|
||||||
|
|
||||||
if (!*aSource)
|
|
||||||
{
|
|
||||||
// no string, so no key.
|
|
||||||
*aKey = nsnull;
|
|
||||||
*aKeyLen = 0;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult rv;
|
|
||||||
if (!mCollationKeyGenerator)
|
if (!mCollationKeyGenerator)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsILocaleService> localeSvc = do_GetService(NS_LOCALESERVICE_CONTRACTID,&rv);
|
nsCOMPtr<nsILocaleService> localeSvc = do_GetService(NS_LOCALESERVICE_CONTRACTID,&rv);
|
||||||
@ -818,11 +778,26 @@ nsresult nsAbView::CreateCollationKey(const PRUnichar *aSource, PRUint8 **aKey,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX can we avoid this copy?
|
rv = GetCardValue(abcard->card, colID, getter_Copies(value));
|
||||||
nsAutoString sourceString(aSource);
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
rv = mCollationKeyGenerator->AllocateRawSortKey(kCollationCaseInSensitive, sourceString, aKey, aKeyLen);
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to generate a raw sort key, see bug #121868");
|
PR_FREEIF(abcard->primaryCollationKey);
|
||||||
return NS_OK;
|
rv = mCollationKeyGenerator->AllocateRawSortKey(kCollationCaseInSensitive,
|
||||||
|
value, &(abcard->primaryCollationKey), &(abcard->primaryCollationKeyLen));
|
||||||
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
|
||||||
|
// XXX todo
|
||||||
|
// fix me, do this with a const getter, to avoid the strcpy
|
||||||
|
|
||||||
|
// hardcode email to be our secondary key
|
||||||
|
rv = GetCardValue(abcard->card, NS_LITERAL_STRING(kPriEmailColumn).get(), getter_Copies(value));
|
||||||
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
|
||||||
|
PR_FREEIF(abcard->secondaryCollationKey);
|
||||||
|
rv = mCollationKeyGenerator->AllocateRawSortKey(kCollationCaseInSensitive,
|
||||||
|
value, &(abcard->secondaryCollationKey), &(abcard->secondaryCollationKeyLen));
|
||||||
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbView::OnItemAdded(nsISupports *parentDir, nsISupports *item)
|
NS_IMETHODIMP nsAbView::OnItemAdded(nsISupports *parentDir, nsISupports *item)
|
||||||
|
@ -80,7 +80,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
nsCOMPtr<nsITreeBoxObject> mTree;
|
nsCOMPtr<nsITreeBoxObject> mTree;
|
||||||
nsCOMPtr<nsITreeSelection> mTreeSelection;
|
nsCOMPtr<nsITreeSelection> mTreeSelection;
|
||||||
nsresult CreateCollationKey(const PRUnichar *aSource, PRUint8 **aKey, PRUint32 *aKenLen);
|
|
||||||
PRInt32 FindIndexForInsert(AbCard *abcard);
|
PRInt32 FindIndexForInsert(AbCard *abcard);
|
||||||
PRInt32 FindIndexForCard(nsIAbCard *card);
|
PRInt32 FindIndexForCard(nsIAbCard *card);
|
||||||
nsresult GenerateCollationKeysForCard(const PRUnichar *colID, AbCard *abcard);
|
nsresult GenerateCollationKeysForCard(const PRUnichar *colID, AbCard *abcard);
|
||||||
|
Loading…
Reference in New Issue
Block a user