Bug 428876: ondrop gets wrong results when dragging multiple files, patch by Michael Ventnor <ventnor.bugzilla@yahoo.com.au>, r+sr=roc, a=beltzner

This commit is contained in:
gavin%gavinsharp.com 2008-04-16 20:29:06 +00:00
Родитель dd5729063b
Коммит 843a05e5d7
1 изменённых файлов: 21 добавлений и 14 удалений

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

@ -466,22 +466,29 @@ nsDragService::GetData(nsITransferable * aTransferable,
GetTargetDragData(gdkFlavor);
if (mTargetDragData) {
const char* text = static_cast<char*>(mTargetDragData);
NS_ConvertUTF8toUTF16 fileUrl = NS_ConvertUTF8toUTF16(text);
if (StringBeginsWith(fileUrl, NS_LITERAL_STRING("file://")))
fileUrl.Cut(0, strlen("file://"));
PRUnichar* convertedText = nsnull;
PRInt32 convertedTextLen = 0;
// Sometimes there are linebreaks in the file URLs. Yes, linebreaks in the file URLs.
fileUrl.StripChars("\r\n");
GetTextUriListItem(text, mTargetDragDataLen, aItemIndex,
&convertedText, &convertedTextLen);
nsCOMPtr<nsILocalFile> file;
nsresult rv = NS_NewLocalFile(fileUrl, PR_TRUE, getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
// The common wrapping code at the end of this function assumes the data is text
// and calls text-specific operations.
// Make a secret hideout here for nsILocalFile objects and return early.
aTransferable->SetTransferData(flavorStr, file,
fileUrl.Length() * sizeof(PRUnichar));
return NS_OK;
if (convertedText) {
nsDependentString fileUrl = nsDependentString(convertedText);
if (StringBeginsWith(fileUrl, NS_LITERAL_STRING("file://")))
fileUrl.Cut(0, strlen("file://"));
nsCOMPtr<nsILocalFile> file;
nsresult rv = NS_NewLocalFile(fileUrl, PR_TRUE, getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
// The common wrapping code at the end of this function assumes the data is text
// and calls text-specific operations.
// Make a secret hideout here for nsILocalFile objects and return early.
aTransferable->SetTransferData(flavorStr, file,
fileUrl.Length() * sizeof(PRUnichar));
g_free(convertedText);
return NS_OK;
}
g_free(convertedText);
}
continue;
}