Changeset 78743 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- May 25, 2019 1:39:09 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130830
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r78666 r78743 727 727 return setError(E_INVALIDARG, tr("No destination specified")); 728 728 729 /* Create a task and return the progress obejct for it. */ 730 GuestSessionTaskCopyFrom *pTask = NULL; 729 731 try 730 732 { 731 GuestSessionTaskCopyFrom *pTask = NULL; 732 ComObjPtr<Progress> pProgressObj; 733 try 734 { 735 pTask = new GuestSessionTaskCopyFrom(this /* GuestSession */, SourceSet, strDestination); 736 } 737 catch(...) 738 { 739 hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to create SessionTaskCopyFrom object")); 740 throw; 741 } 742 733 pTask = new GuestSessionTaskCopyFrom(this /* GuestSession */, SourceSet, strDestination); 734 } 735 catch (std::bad_alloc &) 736 { 737 return setError(E_OUTOFMEMORY, tr("Failed to create GuestSessionTaskCopyFrom object")); 738 } 739 740 try 741 { 743 742 hrc = pTask->Init(Utf8StrFmt(tr("Copying to \"%s\" on the host"), strDestination.c_str())); 744 if (FAILED(hrc)) 745 { 746 delete pTask; 747 hrc = setError(VBOX_E_IPRT_ERROR, 748 tr("Creating progress object for SessionTaskCopyFrom object failed")); 749 throw hrc; 750 } 751 743 } 744 catch (std::bad_alloc &) 745 { 746 hrc = E_OUTOFMEMORY; 747 } 748 if (SUCCEEDED(hrc)) 749 { 750 ComObjPtr<Progress> ptrProgressObj = pTask->GetProgressObject(); 751 752 /* Kick off the worker thread. Note! Consumes pTask. */ 752 753 hrc = pTask->createThreadWithType(RTTHREADTYPE_MAIN_HEAVY_WORKER); 754 pTask = NULL; 753 755 if (SUCCEEDED(hrc)) 754 { 755 /* Return progress to the caller. */ 756 pProgressObj = pTask->GetProgressObject(); 757 hrc = pProgressObj.queryInterfaceTo(pProgress.asOutParam()); 758 } 756 hrc = ptrProgressObj.queryInterfaceTo(pProgress.asOutParam()); 759 757 else 760 hrc = setError(hrc, tr("Starting thread for copying from guest to \"%s\" on the host failed"), strDestination.c_str()); 761 762 } 763 catch (std::bad_alloc &) 764 { 765 hrc = E_OUTOFMEMORY; 766 } 767 catch (HRESULT eHR) 768 { 769 hrc = eHR; 758 hrc = setError(hrc, tr("Starting thread for copying from guest to the host failed")); 759 } 760 else 761 { 762 hrc = setError(hrc, tr("Initializing GuestSessionTaskCopyFrom object failed")); 763 delete pTask; 770 764 } 771 765 … … 803 797 return setError(E_INVALIDARG, tr("No destination specified")); 804 798 799 /* Create a task and return the progress obejct for it. */ 800 GuestSessionTaskCopyTo *pTask = NULL; 805 801 try 806 802 { 807 GuestSessionTaskCopyTo *pTask = NULL; 808 ComObjPtr<Progress> pProgressObj; 809 try 810 { 811 pTask = new GuestSessionTaskCopyTo(this /* GuestSession */, SourceSet, strDestination); 812 } 813 catch(...) 814 { 815 hrc = setError(VBOX_E_IPRT_ERROR, tr("Failed to create SessionTaskCopyTo object")); 816 throw; 817 } 818 803 pTask = new GuestSessionTaskCopyTo(this /* GuestSession */, SourceSet, strDestination); 804 } 805 catch (std::bad_alloc &) 806 { 807 return setError(E_OUTOFMEMORY, tr("Failed to create GuestSessionTaskCopyTo object")); 808 } 809 810 try 811 { 819 812 hrc = pTask->Init(Utf8StrFmt(tr("Copying to \"%s\" on the guest"), strDestination.c_str())); 820 if (FAILED(hrc)) 821 { 822 delete pTask; 823 hrc = setError(VBOX_E_IPRT_ERROR, 824 tr("Creating progress object for SessionTaskCopyTo object failed")); 825 throw hrc; 826 } 827 813 } 814 catch (std::bad_alloc &) 815 { 816 hrc = E_OUTOFMEMORY; 817 } 818 if (SUCCEEDED(hrc)) 819 { 820 ComObjPtr<Progress> ptrProgressObj = pTask->GetProgressObject(); 821 822 /* Kick off the worker thread. Note! Consumes pTask. */ 828 823 hrc = pTask->createThreadWithType(RTTHREADTYPE_MAIN_HEAVY_WORKER); 824 pTask = NULL; 829 825 if (SUCCEEDED(hrc)) 830 { 831 /* Return progress to the caller. */ 832 pProgressObj = pTask->GetProgressObject(); 833 hrc = pProgressObj.queryInterfaceTo(pProgress.asOutParam()); 834 } 826 hrc = ptrProgressObj.queryInterfaceTo(pProgress.asOutParam()); 835 827 else 836 hrc = setError(hrc, tr("Starting thread for copying from host to \"%s\" on the guest failed"), strDestination.c_str()); 837 838 } 839 catch (std::bad_alloc &) 840 { 841 hrc = E_OUTOFMEMORY; 842 } 843 catch (HRESULT eHR) 844 { 845 hrc = eHR; 828 hrc = setError(hrc, tr("Starting thread for copying from host to the guest failed")); 829 } 830 else 831 { 832 hrc = setError(hrc, tr("Initializing GuestSessionTaskCopyTo object failed")); 833 delete pTask; 846 834 } 847 835
Note:
See TracChangeset
for help on using the changeset viewer.