VirtualBox

Changeset 97724 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Dec 1, 2022 1:45:13 PM (2 years ago)
Author:
vboxsync
Message:

DnD/Main: Also be a bit more informative wrt error reporting to the API client for the other H-> G APIs in IDnDTargetImpl, fixed some HRESULT vs. IPRT rc mixups with adjustScreenCoordinates().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r97720 r97724  
    318318    Assert(m_lstFmtOffered.size());
    319319
    320     HRESULT hrc = S_OK;
    321 
    322320    /* Adjust the coordinates in a multi-monitor setup. */
    323     int vrc = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
    324     if (RT_SUCCESS(vrc))
     321    HRESULT hrc = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
     322    if (SUCCEEDED(hrc))
    325323    {
    326324        GuestDnDMsg Msg;
     
    336334        Msg.appendUInt32(cbFormats);
    337335
    338         LogRel2(("DnD: Host enters the VM window at %RU32,%RU32 (screen %u, default action is '%s')\n",
    339                  aX, aY, aScreenId, DnDActionToStr(dndActionDefault)));
    340 
    341         vrc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms());
     336        int vrc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms());
    342337        if (RT_SUCCESS(vrc))
    343338        {
    344             if (RT_SUCCESS(m_pState->waitForGuestResponse()))
     339            GuestDnDState *pState = GuestDnDInst()->getState();
     340            if (pState && RT_SUCCESS(vrc = pState->waitForGuestResponse()))
     341            {
    345342                resAction = GuestDnD::toMainAction(m_pState->getActionDefault());
    346         }
    347     }
    348 
    349     if (RT_FAILURE(vrc))
    350         hrc = VBOX_E_DND_ERROR;
     343
     344                LogRel2(("DnD: Host enters the VM window at %RU32,%RU32 (screen %u, default action is '%s') -> guest reported back action '%s'\n",
     345                         aX, aY, aScreenId, DnDActionToStr(dndActionDefault), DnDActionToStr(resAction)));
     346            }
     347            else
     348                hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Waiting for response of enter event failed (%Rrc)"), vrc);
     349        }
     350        else
     351            hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Sending enter event to guest failed (%Rrc)"), vrc);
     352    }
    351353
    352354    if (SUCCEEDED(hrc))
     
    399401    const uint32_t cbFormats = (uint32_t)strFormats.length() + 1; /* Include terminating zero. */
    400402
    401     HRESULT hrc = S_OK;
    402 
    403     int vrc = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
    404     if (RT_SUCCESS(vrc))
     403    HRESULT hrc = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
     404    if (SUCCEEDED(hrc))
    405405    {
    406406        GuestDnDMsg Msg;
     
    416416        Msg.appendUInt32(cbFormats);
    417417
    418         vrc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms());
     418        int vrc = GuestDnDInst()->hostCall(Msg.getType(), Msg.getCount(), Msg.getParms());
    419419        if (RT_SUCCESS(vrc))
    420420        {
    421421            GuestDnDState *pState = GuestDnDInst()->getState();
    422             if (pState && RT_SUCCESS(pState->waitForGuestResponse()))
     422            if (pState && RT_SUCCESS(vrc = pState->waitForGuestResponse()))
     423            {
    423424                resAction = GuestDnD::toMainAction(pState->getActionDefault());
    424425
    425             LogRel2(("DnD: Host moved to %RU32,%RU32 in VM window (screen %u, default action is '%s') -> guest reported back action '%s'\n",
    426                      aX, aY, aScreenId, DnDActionToStr(dndActionDefault), DnDActionToStr(resAction)));
    427         }
    428     }
    429 
    430     if (RT_FAILURE(vrc))
    431         hrc = VBOX_E_DND_ERROR;
     426                LogRel2(("DnD: Host moved to %RU32,%RU32 in VM window (screen %u, default action is '%s') -> guest reported back action '%s'\n",
     427                         aX, aY, aScreenId, DnDActionToStr(dndActionDefault), DnDActionToStr(resAction)));
     428            }
     429            else
     430                hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Waiting for response of move event failed (%Rrc)"), vrc);
     431        }
     432        else
     433            hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Sending move event to guest failed (%Rrc)"), vrc);
     434    }
     435    else
     436        hrc = setError(hrc, tr("Retrieving move coordinates failed"));
    432437
    433438    if (SUCCEEDED(hrc))
     
    465470    {
    466471        GuestDnDState *pState = GuestDnDInst()->getState();
    467         if (pState)
    468             pState->waitForGuestResponse();
    469     }
    470 
    471     if (RT_FAILURE(vrc))
    472         hrc = VBOX_E_DND_ERROR;
     472        if (pState && RT_SUCCESS(vrc = pState->waitForGuestResponse()))
     473        {
     474            /* Nothing to do here. */
     475        }
     476        else
     477            hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Waiting for response of leave event failed (%Rrc)"), vrc);
     478    }
     479    else
     480        hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Sending leave event to guest failed (%Rrc)"), vrc);
    473481
    474482    LogFlowFunc(("hrc=%Rhrc\n", hrc));
     
    529537
    530538    /* Adjust the coordinates in a multi-monitor setup. */
    531     HRESULT hr = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
    532     if (SUCCEEDED(hr))
     539    HRESULT hrc = GuestDnDInst()->adjustScreenCoordinates(aScreenId, &aX, &aY);
     540    if (SUCCEEDED(hrc))
    533541    {
    534542        GuestDnDMsg Msg;
     
    564572                    {
    565573                        if (lstFormats.size() == 0)
    566                             hr = setError(VBOX_E_DND_ERROR, tr("Guest accepted drop, but did not specify the format"));
     574                            hrc = setError(VBOX_E_DND_ERROR, tr("Guest accepted drop, but did not specify the format"));
    567575                        else
    568                             hr = setError(VBOX_E_DND_ERROR, tr("Guest accepted drop, but returned more than one drop format (%zu formats)"),
     576                            hrc = setError(VBOX_E_DND_ERROR, tr("Guest accepted drop, but returned more than one drop format (%zu formats)"),
    569577                                          lstFormats.size());
    570578                    }
     
    575583            }
    576584            else
    577                 hr = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Waiting for response of dropped event failed (%Rrc)"), vrc);
     585                hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Waiting for response of dropped event failed (%Rrc)"), vrc);
    578586        }
    579587        else
    580             hr = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Sending dropped event to guest failed (%Rrc)"), vrc);
     588            hrc = setErrorBoth(VBOX_E_DND_ERROR, vrc, tr("Sending dropped event to guest failed (%Rrc)"), vrc);
    581589    }
    582590    else
    583         hr = setError(hr, tr("Retrieving drop coordinates failed"));
    584 
    585     if (SUCCEEDED(hr))
     591        hrc = setError(hrc, tr("Retrieving drop coordinates failed"));
     592
     593    if (SUCCEEDED(hrc))
    586594    {
    587595        aFormat = resFmt;
     
    590598    }
    591599
    592     return hr;
     600    return hrc;
    593601#endif /* VBOX_WITH_DRAG_AND_DROP */
    594602}
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