Changeset 50561 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Feb 24, 2014 9:07:22 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.cpp
r50508 r50561 231 231 if (mStatus == Dropped) 232 232 { 233 #ifdef VBOX_DND_DEBUG_FORMATS234 233 LogFlowFunc(("cfFormat=%RI16, sFormat=%s, tyMed=%RU32, dwAspect=%RU32\n", 235 234 pThisFormat->cfFormat, UIDnDDataObject::ClipboardFormatToString(pFormatEtc->cfFormat), … … 237 236 LogFlowFunc(("Got strFormat=%s, pvData=%p, cbData=%RU32\n", 238 237 mstrFormat.toAscii().constData(), mpvData, mcbData)); 239 #endif 238 240 239 QVariant::Type vaType; 241 240 QString strMIMEType; … … 256 255 vaType = QVariant::StringList; 257 256 } 258 #if 0 257 #if 0 /* More formats; not needed right now. */ 259 258 else if ( (pFormatEtc->tymed & TYMED_ISTREAM) 260 259 && (pFormatEtc->dwAspect == DVASPECT_CONTENT) … … 285 284 strMIMEType.toAscii().constData(), vaType)); 286 285 287 QVariant va; 288 int rc = mpParent->RetrieveData(strMIMEType, vaType, va); 286 int rc; 287 if (!mVaData.isValid()) 288 rc = mpParent->RetrieveData(strMIMEType, vaType, mVaData); 289 else 290 rc = VINF_SUCCESS; /* Data already retrieved. */ 291 289 292 if (RT_SUCCESS(rc)) 290 293 { 291 294 if ( strMIMEType.startsWith("text/uri-list") 292 295 /* One item. */ 293 && ( va.canConvert(QVariant::String)296 && ( mVaData.canConvert(QVariant::String) 294 297 /* Multiple items. */ 295 || va.canConvert(QVariant::StringList))298 || mVaData.canConvert(QVariant::StringList)) 296 299 ) 297 300 { 298 QStringList lstFilesURI = va.toStringList();301 QStringList lstFilesURI = mVaData.toStringList(); 299 302 QStringList lstFiles; 300 303 for (size_t i = 0; i < lstFilesURI.size(); i++) … … 326 329 327 330 size_t cbBuf = sizeof(DROPFILES) + ((cchFiles + 1) * sizeof(RTUTF16)); 328 DROPFILES *p Buf= (DROPFILES *)RTMemAllocZ(cbBuf);329 if (p Buf)331 DROPFILES *pDropFiles = (DROPFILES *)RTMemAllocZ(cbBuf); 332 if (pDropFiles) 330 333 { 331 p Buf->pFiles = sizeof(DROPFILES);332 p Buf->fWide = 1; /* We use unicode. Always. */333 334 uint8_t *pCurFile = (uint8_t *)p Buf + pBuf->pFiles;334 pDropFiles->pFiles = sizeof(DROPFILES); 335 pDropFiles->fWide = 1; /* We use unicode. Always. */ 336 337 uint8_t *pCurFile = (uint8_t *)pDropFiles + pDropFiles->pFiles; 335 338 AssertPtr(pCurFile); 336 339 … … 368 371 if (pMedium->hGlobal) 369 372 { 370 LPVOID p Mem = GlobalLock(pMedium->hGlobal);371 if (p Mem)373 LPVOID pvMem = GlobalLock(pMedium->hGlobal); 374 if (pvMem) 372 375 { 373 memcpy(p Mem, pBuf, cbBuf);376 memcpy(pvMem, pDropFiles, cbBuf); 374 377 GlobalUnlock(pMedium->hGlobal); 375 378 … … 383 386 } 384 387 385 RTMemFree(p Buf);388 RTMemFree(pDropFiles); 386 389 } 387 390 } 388 391 else if ( strMIMEType.startsWith("text/plain") 389 && va.canConvert(QVariant::String))392 && mVaData.canConvert(QVariant::String)) 390 393 { 391 394 bool fUnicode = pFormatEtc->cfFormat == CF_UNICODETEXT; 392 int cb ch = fUnicode395 int cbCh = fUnicode 393 396 ? sizeof(WCHAR) : sizeof(char); 394 397 395 QString strText = va.toString();396 size_t cbSrc = (strText.length() + 1) * cbch;398 QString strText = mVaData.toString(); 399 size_t cbSrc = strText.length() * cbCh; 397 400 Assert(cbSrc); 398 401 LPCVOID pvSrc = fUnicode … … 400 403 : (void *)strText.toAscii().constData(); 401 404 AssertPtr(pvSrc); 402 #ifdef DEBUG_andy 405 403 406 LogFlowFunc(("pvSrc=0x%p, cbSrc=%zu, cbch=%d, fUnicode=%RTbool\n", 404 pvSrc, cbSrc, cb ch, fUnicode));405 #endif 407 pvSrc, cbSrc, cbCh, fUnicode)); 408 406 409 pMedium->tymed = TYMED_HGLOBAL; 407 410 pMedium->pUnkForRelease = NULL; 408 411 pMedium->hGlobal = GlobalAlloc( GMEM_ZEROINIT 409 412 | GMEM_MOVEABLE 410 | GMEM_DDESHARE, cbSrc); 413 | GMEM_DDESHARE, 414 cbSrc); 411 415 if (pMedium->hGlobal) 412 416 { … … 423 427 } 424 428 else 425 hr = E_OUTOFMEMORY;429 hr = VERR_NO_MEMORY; 426 430 } 427 431 else … … 445 449 case TYMED_HGLOBAL: 446 450 pMedium->hGlobal = (HGLOBAL)OleDuplicateData(pThisMedium->hGlobal, 447 pThisFormat->cfFormat, NULL); 451 pThisFormat->cfFormat, 452 0 /* Flags */); 448 453 break; 449 454 … … 452 457 } 453 458 454 pMedium->tymed = p ThisFormat->tymed;459 pMedium->tymed = pFormatEtc->tymed; 455 460 pMedium->pUnkForRelease = NULL; 456 461 } 457 462 458 LogFlowFunc((" hr=%Rhrc\n", hr));463 LogFlowFunc(("Returning hr=%Rhrc\n", hr)); 459 464 return hr; 460 465 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDataObject_win.h
r50460 r50561 25 25 #include <QString> 26 26 #include <QStringList> 27 #include <QVariant> 27 28 28 29 /* Forward declarations: */ … … 92 93 QStringList mlstFormats; 93 94 QString mstrFormat; 95 /** The retrieved data as a QVariant. Needed 96 * for buffering in case a second format needs 97 * the same data, e.g. CF_TEXT and CF_UNICODETEXT. */ 98 QVariant mVaData; 99 /** The retrieved data as a raw buffer. */ 94 100 void *mpvData; 101 /** Raw buffer size (in bytes). */ 95 102 uint32_t mcbData; 96 103 }; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDDrag.cpp
r50460 r50561 89 89 HRESULT hr = ::DoDragDrop(pDataObject, pDropSource, 90 90 dwOKEffects, &dwEffect); 91 LogFlowThisFunc(("hr=%Rhrc, dwEffect=%RI32\n", hr, dwEffect)); 91 LogFlowThisFunc(("DoDragDrop ended with hr=%Rhrc, dwEffect=%RI32\n", 92 hr, dwEffect)); 92 93 93 94 if (pDropSource) … … 150 151 { 151 152 msgCenter().showModalProgressDialog(progress, 152 tr("Retrieving metadata ..."), ":/progress_dnd_gh_90px.png",153 tr("Retrieving data ..."), ":/progress_dnd_gh_90px.png", 153 154 m_pParent); 154 155 if (!progress.GetCanceled()) … … 161 162 { 162 163 /* After the data successfully arrived from the guest, we query it from Main. */ 163 QVector<uint8_t> data = guest.DragGHGetData();164 if (! data.isEmpty())164 QVector<uint8_t> vecData = guest.DragGHGetData(); 165 if (!vecData.isEmpty()) 165 166 { 166 167 switch (vaType) … … 168 169 case QVariant::String: 169 170 { 170 vaData = QVariant(QString(reinterpret_cast<const char*>( data.data())));171 vaData = QVariant(QString(reinterpret_cast<const char*>(vecData.constData()))); 171 172 break; 172 173 } … … 174 175 case QVariant::ByteArray: 175 176 { 176 QByteArray ba(reinterpret_cast<const char*>( data.constData()), data.size());177 QByteArray ba(reinterpret_cast<const char*>(vecData.constData()), vecData.size()); 177 178 vaData = QVariant(ba); 178 179 break; … … 181 182 case QVariant::StringList: 182 183 { 183 QString strData = QString(reinterpret_cast<const char*>( data.data()));184 QString strData = QString(reinterpret_cast<const char*>(vecData.constData())); 184 185 QStringList lstString = strData.split("\r\n", QString::SkipEmptyParts); 185 186
Note:
See TracChangeset
for help on using the changeset viewer.