- Timestamp:
- Nov 8, 2010 1:41:37 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r33766 r33839 69 69 } 70 70 71 72 71 /** 73 * Print out progress on the console 72 * Print out progress on the console. 73 * 74 * This runs the main event queue every now and then to prevent piling up 75 * unhandled things (which doesn't cause real problems, just makes things 76 * react a little slower than in the ideal case). 74 77 */ 75 78 HRESULT showProgress(ComPtr<IProgress> progress) … … 77 80 using namespace com; 78 81 79 BOOL fCompleted ;80 ULONG ulCurrentPercent ;82 BOOL fCompleted = FALSE; 83 ULONG ulCurrentPercent = 0; 81 84 ULONG ulLastPercent = 0; 82 85 83 ULONG ulCurrentOperationPercent;84 86 ULONG ulLastOperationPercent = (ULONG)-1; 85 87 … … 87 89 Bstr bstrOperationDescription; 88 90 89 ULONG cOperations; 90 progress->COMGETTER(OperationCount)(&cOperations); 91 EventQueue::getMainEventQueue()->processEventQueue(0); 92 93 ULONG cOperations = 1; 94 HRESULT hrc = progress->COMGETTER(OperationCount)(&cOperations); 95 if (FAILED(hrc)) 96 { 97 RTStrmPrintf(g_pStdErr, "Progress object failure: %Rhrc\n", hrc); 98 RTStrmFlush(g_pStdErr); 99 return hrc; 100 } 91 101 92 102 if (!g_fDetailedProgress) … … 99 109 bool fCanceledAlready = false; 100 110 BOOL fCancelable; 101 HRESULThrc = progress->COMGETTER(Cancelable)(&fCancelable);111 hrc = progress->COMGETTER(Cancelable)(&fCancelable); 102 112 if (FAILED(hrc)) 103 113 fCancelable = FALSE; … … 110 120 } 111 121 112 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))) 113 { 114 ULONG ulOperation; 115 progress->COMGETTER(Operation)(&ulOperation); 116 122 hrc = progress->COMGETTER(Completed(&fCompleted)); 123 while (SUCCEEDED(hrc)) 124 { 117 125 progress->COMGETTER(Percent(&ulCurrentPercent)); 118 progress->COMGETTER(OperationPercent(&ulCurrentOperationPercent));119 126 120 127 if (g_fDetailedProgress) 121 128 { 129 ULONG ulOperation = 1; 130 hrc = progress->COMGETTER(Operation)(&ulOperation); 131 if (FAILED(hrc)) 132 break; 133 ULONG ulCurrentOperationPercent = 0; 134 hrc = progress->COMGETTER(OperationPercent(&ulCurrentOperationPercent)); 135 if (FAILED(hrc)) 136 break; 137 122 138 if (ulLastOperation != ulOperation) 123 139 { 124 progress->COMGETTER(OperationDescription(bstrOperationDescription.asOutParam())); 140 hrc = progress->COMGETTER(OperationDescription(bstrOperationDescription.asOutParam())); 141 if (FAILED(hrc)) 142 break; 125 143 ulLastPercent = (ULONG)-1; // force print 126 144 ulLastOperation = ulOperation; … … 131 149 ) 132 150 { 133 LONG lSecsRem ;151 LONG lSecsRem = 0; 134 152 progress->COMGETTER(TimeRemaining)(&lSecsRem); 135 153 … … 171 189 /* make sure the loop is not too tight */ 172 190 progress->WaitForCompletion(100); 191 192 EventQueue::getMainEventQueue()->processEventQueue(0); 193 hrc = progress->COMGETTER(Completed(&fCompleted)); 173 194 } 174 195 … … 184 205 /* complete the line. */ 185 206 LONG iRc = E_FAIL; 186 if (SUCCEEDED(progress->COMGETTER(ResultCode)(&iRc))) 207 hrc = progress->COMGETTER(ResultCode)(&iRc); 208 if (SUCCEEDED(hrc)) 187 209 { 188 210 if (SUCCEEDED(iRc)) … … 191 213 RTStrmPrintf(g_pStdErr, "CANCELED\n"); 192 214 else 193 RTStrmPrintf(g_pStdErr, "FAILED\n"); 215 { 216 if (!g_fDetailedProgress) 217 RTStrmPrintf(g_pStdErr, "\n"); 218 RTStrmPrintf(g_pStdErr, "Progress state: %Rhrc\n", iRc); 219 } 220 hrc = iRc; 194 221 } 195 222 else 196 RTStrmPrintf(g_pStdErr, "\n"); 223 { 224 if (!g_fDetailedProgress) 225 RTStrmPrintf(g_pStdErr, "\n"); 226 RTStrmPrintf(g_pStdErr, "Progress object failure: %Rhrc\n", hrc); 227 } 197 228 RTStrmFlush(g_pStdErr); 198 return iRc;229 return hrc; 199 230 } 200 231
Note:
See TracChangeset
for help on using the changeset viewer.