Closed Bug 396592 Opened 17 years ago Closed 17 years ago

Drag and drop images from the content area fail

Categories

(Core :: Widget: Win32, defect)

x86
Windows Vista
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.9beta1

People

(Reporter: jimm, Assigned: jimm)

Details

Attachments

(1 file, 3 obsolete files)

Vista only, I checked XP and it's working fine. Dragging an image from the content area to the desktop or some other folder you have permissions in fails to copy the image over. The file copy dialog will show, but the file never shows up.
Assignee: nobody → jmathies
Status: NEW → ASSIGNED
Appears to be caused by our half hearted implementation of IStream in widget/src/windows/nsDataObj.cpp.
Yep, that's it. Stat and Seek need to return valid information.
Attached patch vista drag image patch v.1 (obsolete) — Splinter Review
Attachment #281555 - Flags: review?(emaijala)
Comment on attachment 281555 [details] [diff] [review]
vista drag image patch v.1

Sorry, I can't test Vista yet (I'll try to get it installed in the next week or two...).
Attachment #281555 - Flags: review?(emaijala) → review?
Comment on attachment 281555 [details] [diff] [review]
vista drag image patch v.1

+    PRUint32 nMaxNameLength = (wideFileName.Length()*2) + 2;
+    void * retBuf = CoTaskMemAlloc(nMaxNameLength); // freed by caller
+    if (!retBuf) 
+      return STG_E_INSUFFICIENTMEMORY;
+
+    ZeroMemory(retBuf, nMaxNameLength);
+    wcsncpy(statstg->pwcsName, wideFileName.get(), nMaxNameLength);

This is wrong, retBuf is allocated but wcsncpy's destination is statstg->pwcsName. Why ZeroMemory as you're allocating just what's needed?

+  if (!mChannel)
+    return E_NOTIMPL;
.
.
.
+  if (mChannel)
+    mChannel->GetContentLength(&nLength);

Which one did you mean? Return error if !mChannel or return what's possible. I'd go for the latter. 

Also, wouldn't E_FAIL be the correct return value instead of E_NOTIMPL in the error cases?
Attachment #281555 - Flags: review? → review-
>This is wrong, retBuf is allocated but wcsncpy's destination is
>statstg->pwcsName. Why ZeroMemory as you're allocating just what's needed?

I'm adding a character on the end, and zeroing out the entire buffer to null terminate it. There's really no harm in that afaict. I'll fix the buffer issue and repost here in a sec.

Attached patch vista drag image patch v.2 (obsolete) — Splinter Review
This addresses the missing buffer asignment. I've also changed the not implemented returns to E_FAIL.
Attachment #281555 - Attachment is obsolete: true
Attachment #284002 - Flags: review?(emaijala)
Comment on attachment 284002 [details] [diff] [review]
vista drag image patch v.2

r=emaijala
Attachment #284002 - Flags: review?(emaijala) → review+
Flags: blocking-firefox3?
Attachment #284002 - Flags: superreview?(roc)
Flags: blocking-firefox3? → blocking-firefox3+
+  if (nMove.LowPart == 0 && 
+      nNewPos && 
+      (dwOrigin == STREAM_SEEK_SET || dwOrigin == STREAM_SEEK_CUR)) { 
+    nNewPos->LowPart = NULL;
+    nNewPos->HighPart = NULL;
+    return S_OK;
+  }

Shouldn't we test nMove.HighPart == 0 as well?

Shouldn't we return S_OK even when nNewPos is null? (or should we return some other error in that case?)

And shouldn't those NULLs be 0s?

+    wcsncpy((wchar_t *)retBuf, wideFileName.get(), wideFileName.Length());

Can't we just use memcpy here?

+  SystemTimeToFileTime((const SYSTEMTIME*)&st, (LPFILETIME)&statstg->ctime);
+  SystemTimeToFileTime((const SYSTEMTIME*)&st, (LPFILETIME)&statstg->atime);

Can't these just be "*statstg->ctime = *statstg->atime = *statstg->mtime;"?
Attached patch vista drag image patch v.3 (obsolete) — Splinter Review
>Shouldn't we test nMove.HighPart

updated.

>Shouldn't we return S_OK even when nNewPos is null?

msdn suggested we use STG_E_INVALIDPOINTER.

>Can't we just use memcpy here?

updated.

>"*statstg->ctime = *statstg->atime = *statstg->mtime;"?

updated (without the dreferences which weren't needed).
Attachment #285235 - Flags: superreview?(roc)
Attachment #284002 - Flags: superreview?(roc)
sorry, minor touch up, removed the unneeded nNewPos check in the if statement.
Attachment #285235 - Flags: superreview?(roc) → superreview+
Attachment #284002 - Attachment is obsolete: true
Attachment #285235 - Attachment is obsolete: true
Keywords: checkin-needed
Component: OS Integration → Widget: Win32
Flags: blocking-firefox3+
Product: Firefox → Core
QA Contact: os.integration → win32
Target Milestone: --- → mozilla1.9 M9
Restoring awol blocker flag.
Flags: blocking1.9+
Checking in widget/src/windows/nsDataObj.cpp;
/cvsroot/mozilla/widget/src/windows/nsDataObj.cpp,v  <--  nsDataObj.cpp
new revision: 1.85; previous revision: 1.84
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
I tested:

* email addresses (shortcut created was a mailto:)
* links (shortcut created was a hyperlink)
* images (the raw image was copied to the desktop, to where I dragged it)

Verified FIXED using Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9a9pre) Gecko/2007102407 Minefield/3.0a9pre
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: