VirtualBox

Changeset 78758 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
May 26, 2019 3:07:17 AM (6 years ago)
Author:
vboxsync
Message:

Main/GuestSession::i_startSessionAsync: Simplified the code a little. bugref:9320

File:
1 edited

Legend:

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

    r78743 r78758  
    20082008    LogFlowThisFuncEnter();
    20092009
    2010     int vrc;
    2011     GuestSessionTaskInternalStart* pTask = NULL;
     2010    /* Create task: */
     2011    GuestSessionTaskInternalStart *pTask = NULL;
    20122012    try
    20132013    {
    20142014        pTask = new GuestSessionTaskInternalStart(this);
    2015         if (!pTask->isOk())
    2016         {
    2017             delete pTask;
    2018             LogFlow(("GuestSession: Could not create GuestSessionTaskInternalStart object\n"));
    2019             throw VERR_MEMOBJ_INIT_FAILED;
    2020         }
    2021 
    2022         /* Asynchronously open the session on the guest by kicking off a worker thread. */
    2023         /* Note: This function deletes pTask in case of exceptions, so there is no need in the call of delete operator. */
     2015    }
     2016    catch (std::bad_alloc &)
     2017    {
     2018        return VERR_NO_MEMORY;
     2019    }
     2020    if (pTask->isOk())
     2021    {
     2022        /* Kick off the thread: */
    20242023        HRESULT hrc = pTask->createThread();
    2025         vrc = Global::vboxStatusCodeFromCOM(hrc);
    2026     }
    2027     catch(std::bad_alloc &)
    2028     {
    2029         vrc = VERR_NO_MEMORY;
    2030     }
    2031     catch(int eVRC)
    2032     {
    2033         vrc = eVRC;
    2034         LogFlow(("GuestSession: Could not create thread for GuestSessionTaskInternalOpen task %Rrc\n", vrc));
    2035     }
    2036 
    2037     LogFlowFuncLeaveRC(vrc);
    2038     return vrc;
     2024        pTask = NULL; /* Not valid anymore, not even on failure! */
     2025        if (SUCCEEDED(hrc))
     2026        {
     2027            LogFlowFuncLeaveRC(VINF_SUCCESS);
     2028            return VINF_SUCCESS;
     2029        }
     2030        LogFlow(("GuestSession: Failed to create thread for GuestSessionTaskInternalOpen task.\n"));
     2031    }
     2032    else
     2033        LogFlow(("GuestSession: GuestSessionTaskInternalStart creation failed: %Rhrc.\n", pTask->rc()));
     2034    LogFlowFuncLeaveRC(VERR_GENERAL_FAILURE);
     2035    return VERR_GENERAL_FAILURE;
    20392036}
    20402037
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