VirtualBox

Ignore:
Timestamp:
Apr 2, 2015 12:32:40 PM (10 years ago)
Author:
vboxsync
Message:

VBoxTray/VBoxDnD: Fixed a crash + format detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp

    r51924 r55091  
    7878    RT_ZERO(startupInfo);
    7979
     80    LogFlowFunc(("Supported formats:\n"));
    8081    const RTCString arrEntries[] = { VBOX_DND_FORMATS_DEFAULT };
    8182    for (size_t i = 0; i < RT_ELEMENTS(arrEntries); i++)
     83    {
     84        LogFlowFunc(("\t%s\n", arrEntries[i].c_str()));
    8285        this->lstAllowedFormats.append(arrEntries[i]);
     86    }
    8387}
    8488
     
    755759    for (size_t i = 0; i < lstFormats.size(); i++)
    756760    {
    757         bool fSupported = this->lstAllowedFormats.contains(lstFormats.at(i));
    758         if (fSupported)
    759             this->lstFormats.append(lstFormats.at(i));
     761        bool fSupported = false;
     762        for (size_t a = 0; a < this->lstAllowedFormats.size(); a++)
     763        {
     764            LogFlowThisFunc(("\t\"%s\" <=> \"%s\"\n", this->lstAllowedFormats.at(a).c_str(), lstFormats.at(i).c_str()));
     765            fSupported = RTStrICmp(this->lstAllowedFormats.at(a).c_str(), lstFormats.at(i).c_str()) == 0;
     766            if (fSupported)
     767            {
     768                this->lstFormats.append(lstFormats.at(i));
     769                break;
     770            }
     771        }
     772
    760773        LogFlowThisFunc(("\t%s: %RTbool\n", lstFormats.at(i).c_str(), fSupported));
    761774    }
     775
     776    /*
     777     * Warn in the log if this guest does not accept anything.
     778     */
     779    if (!this->lstFormats.size())
     780        LogRel(("DnD: Warning: No supported drag'n drop formats on the guest found!\n"));
    762781
    763782    /*
     
    767786    try
    768787    {
    769         /* Translate our drop actions into
    770          * allowed Windows drop effects. */
     788        /* Translate our drop actions into allowed Windows drop effects. */
    771789        startupInfo.dwOKEffects = DROPEFFECT_NONE;
    772790        if (uAllActions)
     
    886904    if (mState == Dragging)
    887905    {
    888         Assert(lstFormats.size() >= 1);
    889 
    890         /** @todo What to do when multiple formats are available? */
    891         mFormatRequested = lstFormats.at(0);
    892 
    893         rc = RTCritSectEnter(&mCritSect);
    894         if (RT_SUCCESS(rc))
    895         {
    896             if (startupInfo.pDataObject)
    897                 startupInfo.pDataObject->SetStatus(VBoxDnDDataObject::Dropping);
    898             else
    899                 rc = VERR_NOT_FOUND;
    900 
    901             RTCritSectLeave(&mCritSect);
    902         }
    903 
    904         if (RT_SUCCESS(rc))
    905         {
    906             LogRel(("DnD: Requesting data as '%s' ...\n", mFormatRequested.c_str()));
    907             rc = VbglR3DnDHGRequestData(mClientID, mFormatRequested.c_str());
    908             if (RT_FAILURE(rc))
    909                 LogFlowThisFunc(("Requesting data failed with rc=%Rrc\n", rc));
    910         }
     906        if (lstFormats.size() >= 1)
     907        {
     908            /** @todo What to do when multiple formats are available? */
     909            mFormatRequested = lstFormats.at(0);
     910
     911            rc = RTCritSectEnter(&mCritSect);
     912            if (RT_SUCCESS(rc))
     913            {
     914                if (startupInfo.pDataObject)
     915                    startupInfo.pDataObject->SetStatus(VBoxDnDDataObject::Dropping);
     916                else
     917                    rc = VERR_NOT_FOUND;
     918
     919                RTCritSectLeave(&mCritSect);
     920            }
     921
     922            if (RT_SUCCESS(rc))
     923            {
     924                LogRel(("DnD: Requesting data as '%s' ...\n", mFormatRequested.c_str()));
     925                rc = VbglR3DnDHGRequestData(mClientID, mFormatRequested.c_str());
     926                if (RT_FAILURE(rc))
     927                    LogFlowThisFunc(("Requesting data failed with rc=%Rrc\n", rc));
     928            }
     929        }
     930        else /* Should never happen. */
     931            LogRel(("DnD: Error: Host did not specify a data format for drop data\n"));
    911932    }
    912933
     
    14041425                     mMode, mState));
    14051426
    1406     lstAllowedFormats.clear();
    1407     lstFormats.clear();
    1408     uAllActions = DND_IGNORE_ACTION;
     1427    /*
     1428     * Note: Don't clear this->lstAllowedFormats at the moment, as this value is initialized
     1429     *       on class creation. We might later want to modify the allowed formats in runtime,
     1430     *       so keep this in mind when implementing this.
     1431     */
     1432
     1433    this->lstFormats.clear();
     1434    this->uAllActions = DND_IGNORE_ACTION;
    14091435
    14101436    int rc2 = setMode(Unknown);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette