VirtualBox

Ignore:
Timestamp:
Nov 9, 2022 6:01:39 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154499
Message:

Guest Control/Main: More eye candy for (single file) progress descriptions. bugref:10286

File:
1 edited

Legend:

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

    r97481 r97485  
    14601460     */
    14611461
    1462     if (mDest.isEmpty())
     1462    if (mSources.empty())
     1463    {
     1464        strErrorInfo.printf(tr("No guest sources specified"));
     1465        vrc = VERR_INVALID_PARAMETER;
     1466    }
     1467    else if (mDest.isEmpty())
    14631468    {
    14641469        strErrorInfo.printf(tr("Host destination must not be empty"));
     
    15781583    }
    15791584
    1580     if (cOperations) /* Use the first element as description (if available). */
    1581     {
    1582         Assert(mVecLists.size());
    1583         Assert(mVecLists[0]->mVecEntries.size());
    1584 
    1585         Utf8Str const &strFirstOp = mVecLists[0]->mVecEntries[0]->strPath;
     1585    if (RT_SUCCESS(vrc))
     1586    {
     1587        /* When there are no entries in the first source list, this means the source only contains a single file
     1588         * (see \a mSrcRootAbs of FsList). So use \a mSrcRootAbs directly. */
     1589        Utf8Str const &strFirstOp = mVecLists[0]->mVecEntries.size() > 0
     1590                                  ? mVecLists[0]->mVecEntries[0]->strPath : mVecLists[0]->mSrcRootAbs;
    15861591
    15871592        /* Now that we know how many objects we're handling, tweak the progress description so that it
     
    15981603                              TRUE /* aCancelable */, cOperations + 1 /* Number of operations */, Bstr(strFirstOp).raw());
    15991604    }
    1600     else /* If no operations have been defined, go with an "empty" progress object when will be used for error handling. */
     1605    else /* On error we go with an "empty" progress object when will be used for error handling. */
    16011606        hrc = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(),
    16021607                              TRUE /* aCancelable */, 1 /* cOperations */, Bstr(mDesc).raw());
    16031608
     1609    if (FAILED(hrc)) /* Progress object creation failed -- we're doomed. */
     1610        return hrc;
     1611
    16041612    if (RT_FAILURE(vrc))
    16051613    {
    16061614        if (strErrorInfo.isEmpty())
    16071615            strErrorInfo.printf(tr("Failed with %Rrc"), vrc);
    1608         setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo);
     1616        hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo);
    16091617    }
    16101618
     
    19161924     */
    19171925
    1918     if (mDest.isEmpty())
     1926    if (mSources.empty())
     1927    {
     1928        strErrorInfo.printf(tr("No host sources specified"));
     1929        vrc = VERR_INVALID_PARAMETER;
     1930    }
     1931    else if (mDest.isEmpty())
    19191932    {
    19201933        strErrorInfo.printf(tr("Guest destination must not be empty"));
     
    19932006                            vrc = pFsList->AddDirFromHost(strSrc /* strPath */, "" /* strSubDir */,
    19942007                                                          szPathReal, sizeof(szPathReal), &DirEntry);
     2008                            break;
    19952009                        }
    19962010
     
    20312045    }
    20322046
    2033     if (cOperations) /* Use the first element as description (if available). */
    2034     {
    2035         Assert(mVecLists.size());
    2036         Assert(mVecLists[0]->mVecEntries.size());
    2037 
    2038         Utf8Str const &strFirstOp = mVecLists[0]->mVecEntries[0]->strPath;
     2047    if (RT_SUCCESS(vrc))
     2048    {
     2049        /* When there are no entries in the first source list, this means the source only contains a single file
     2050         * (see \a mSrcRootAbs of FsList). So use \a mSrcRootAbs directly. */
     2051        Utf8Str const &strFirstOp = mVecLists[0]->mVecEntries.size() > 0
     2052                                  ? mVecLists[0]->mVecEntries[0]->strPath : mVecLists[0]->mSrcRootAbs;
    20392053
    20402054        /* Now that we know how many objects we're handling, tweak the progress description so that it
     
    20492063
    20502064        hrc = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(),
    2051                               TRUE /* aCancelable */, cOperations + 1 /* Number of operations */,
     2065                              TRUE /* aCancelable */, cOperations + 1/* Number of operations */,
    20522066                              Bstr(strFirstOp).raw());
    20532067    }
    2054     else /* If no operations have been defined, go with an "empty" progress object when will be used for error handling. */
     2068    else /* On error we go with an "empty" progress object when will be used for error handling. */
    20552069        hrc = pProgress->init(static_cast<IGuestSession*>(mSession), Bstr(mDesc).raw(),
    20562070                              TRUE /* aCancelable */, 1 /* cOperations */, Bstr(mDesc).raw());
    20572071
     2072    if (FAILED(hrc)) /* Progress object creation failed -- we're doomed. */
     2073        return hrc;
     2074
    20582075    if (RT_FAILURE(vrc))
    20592076    {
    20602077        if (strErrorInfo.isEmpty())
    20612078            strErrorInfo.printf(tr("Failed with %Rrc"), vrc);
    2062         setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo);
     2079        hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo);
    20632080    }
    20642081
Note: See TracChangeset for help on using the changeset viewer.

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