VirtualBox

Changeset 73903 in vbox for trunk


Ignore:
Timestamp:
Aug 27, 2018 8:23:53 AM (6 years ago)
Author:
vboxsync
Message:

bugref:9152. Fixed try-catch logic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r73901 r73903  
    814814                             BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()),
    815815                             (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3);
     816        if (FAILED(rc))
     817            return rc;
    816818
    817819        /* Initialize our worker task */
     
    823825        catch(...)
    824826        {
    825             delete task;
    826827            throw rc = setError(VBOX_E_OBJECT_NOT_FOUND,
    827828                                tr("Could not create TaskOVF object for for writing out the OVF to disk"));
     
    882883                             BstrFmt(tr("Export appliance to Cloud '%s'"), aLocInfo.strPath.c_str()),
    883884                             mode);
     885        if (FAILED(rc))
     886            return rc;
    884887
    885888        // Initialize our worker task
     
    891894        catch(...)
    892895        {
    893             delete task;
    894896            throw rc = setError(VBOX_E_OBJECT_NOT_FOUND,
    895897                                tr("Could not create TaskOCI object for exporting to OCI"));
     
    912914    HRESULT rc;
    913915    RT_NOREF(aFormat);
    914     try /** @todo r=bird: This try..catch(HRESULT) stuff here totally messes up anyones
    915          * understanding of what i_setUpProgress and createThread() might throw.  You really
    916          * think that they must throw some 'HRESULT' stuff too, right. Otherwise, why would
    917          * anyone put their invocations inside these try..catch statements?  But the, WTF
    918          * do they return status codes?  ARRRRRRRRRRRRRRG!
    919          *
    920          * Please rewrite this and all similar places to use nested if (SUCCEEDED(hrc)) rather
    921          * than unmaintainable code like this.
    922          */
     916    try
    923917    {
    924918        rc = i_setUpProgress(aProgress,
    925919                             BstrFmt(tr("Export appliance '%s'"), aLocInfo.strPath.c_str()),
    926920                             (aLocInfo.storageType == VFSType_File) ? WriteFile : WriteS3);
    927 /** @todo r=bird: You ignore the status code here... You can simply return if this fails, because
    928  * you don't have any state to clean up. */
     921        if (FAILED(rc))
     922            return rc;
    929923
    930924        /* Initialize our worker task */
     
    936930        catch(...)
    937931        {
    938 /** @todo r=bird: Task will always be NULL here.  Why? Because the assignment of 'task' is
    939  * the very last thing that happens above.  Traditionally, when you 'delete (TaskOPC *)NULL'
    940  * the CRT kills your process.  (On windows, though, this may differ depending on whether we're
    941  * executing this in a COM worker thread or a IPRT/main worker thread.  We may survive in the
    942  * former, but not the latter.)
    943  *
    944  * P.S. Please make your editor strip trailing spaces on lines you've modified.
    945  */
    946             delete task;
    947932            throw rc = setError(VBOX_E_OBJECT_NOT_FOUND,
    948933                                tr("Could not create TaskOPC object for for writing out the OPC to disk"));
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