Changeset 105578 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 2, 2024 1:01:58 PM (6 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.cpp
r103538 r105578 50 50 #ifdefs, we still have to include the definition of the class. 51 51 very silly. */ 52 # if !defined (Q_OS_MAC) && !defined(Q_OS_OS2)52 # if !defined(Q_OS_MAC) && !defined(Q_OS_OS2) 53 53 XPCOMEventQSocketListener *COMBase::sSocketListener = 0; 54 54 … … 65 65 public: 66 66 67 XPCOMEventQSocketListener 67 XPCOMEventQSocketListener(nsIEventQueue *eq) 68 68 { 69 69 mEventQ = eq; 70 mNotifier = new QSocketNotifier (mEventQ->GetEventQueueSelectFD(), 71 QSocketNotifier::Read, this); 72 QObject::connect (mNotifier, SIGNAL (activated (int)), 73 this, SLOT (processEvents())); 70 mNotifier = new QSocketNotifier(mEventQ->GetEventQueueSelectFD(), QSocketNotifier::Read, this); 71 QObject::connect(mNotifier, SIGNAL(activated (int)), this, SLOT(processEvents())); 74 72 } 75 73 … … 86 84 87 85 QSocketNotifier *mNotifier; 88 nsCOMPtr 86 nsCOMPtr<nsIEventQueue> mEventQ; 89 87 }; 90 88 91 #endif /* !defined(VBOX_WITH_XPCOM) */89 #endif /* defined(VBOX_WITH_XPCOM) */ 92 90 93 91 /** … … 100 98 HRESULT rc = com::Initialize(fGui ? VBOX_COM_INIT_F_DEFAULT | VBOX_COM_INIT_F_GUI : VBOX_COM_INIT_F_DEFAULT); 101 99 102 #if defined 103 104 # if !defined (RT_OS_DARWIN) && !defined(RT_OS_OS2)105 106 if (NS_SUCCEEDED 107 { 108 nsCOMPtr 109 rc = NS_GetMainEventQ (getter_AddRefs(eventQ));110 if (NS_SUCCEEDED 100 #if defined(VBOX_WITH_XPCOM) 101 102 # if !defined(RT_OS_DARWIN) && !defined(RT_OS_OS2) 103 104 if (NS_SUCCEEDED(rc)) 105 { 106 nsCOMPtr<nsIEventQueue> eventQ; 107 rc = NS_GetMainEventQ(getter_AddRefs(eventQ)); 108 if (NS_SUCCEEDED(rc)) 111 109 { 112 110 # ifdef DEBUG 113 111 BOOL isNative = FALSE; 114 eventQ->IsQueueNative 115 AssertMsg 112 eventQ->IsQueueNative(&isNative); 113 AssertMsg(isNative, ("The event queue must be native")); 116 114 # endif 117 115 BOOL isOnMainThread = FALSE; 118 rc = eventQ->IsOnCurrentThread 119 if (NS_SUCCEEDED 116 rc = eventQ->IsOnCurrentThread(&isOnMainThread); 117 if (NS_SUCCEEDED(rc) && isOnMainThread) 120 118 { 121 sSocketListener = new XPCOMEventQSocketListener 119 sSocketListener = new XPCOMEventQSocketListener(eventQ); 122 120 } 123 121 } 124 122 } 125 123 126 # endif /* !defined (RT_OS_DARWIN) && !defined(RT_OS_OS) */127 128 #endif /* defined 129 130 if (FAILED 124 # endif /* !defined(RT_OS_DARWIN) && !defined(RT_OS_OS) */ 125 126 #endif /* defined(VBOX_WITH_XPCOM) */ 127 128 if (FAILED(rc)) 131 129 CleanupCOM(); 132 130 133 AssertComRC 134 135 LogFlowFunc 131 AssertComRC(rc); 132 133 LogFlowFunc(("rc=%08X\n", rc)); 136 134 LogFlowFuncLeave(); 137 135 return rc; … … 148 146 HRESULT rc = S_OK; 149 147 150 #if defined 148 #if defined(VBOX_WITH_XPCOM) 151 149 152 150 /* scope the code to make smart references are released before calling 153 151 * com::Shutdown() */ 154 152 { 155 nsCOMPtr 156 rc = NS_GetMainEventQ (getter_AddRefs(eventQ));157 if (NS_SUCCEEDED 153 nsCOMPtr<nsIEventQueue> eventQ; 154 rc = NS_GetMainEventQ(getter_AddRefs(eventQ)); 155 if (NS_SUCCEEDED(rc)) 158 156 { 159 157 BOOL isOnMainThread = FALSE; 160 rc = eventQ->IsOnCurrentThread 161 if (NS_SUCCEEDED 158 rc = eventQ->IsOnCurrentThread(&isOnMainThread); 159 if (NS_SUCCEEDED(rc) && isOnMainThread) 162 160 { 163 # if !defined (RT_OS_DARWIN) && !defined(RT_OS_OS2)161 # if !defined(RT_OS_DARWIN) && !defined(RT_OS_OS2) 164 162 if (sSocketListener) 165 163 { … … 172 170 } 173 171 174 #endif /* defined 172 #endif /* defined(VBOX_WITH_XPCOM) */ 175 173 176 174 HRESULT rc2 = com::Shutdown(); 177 if (SUCCEEDED 175 if (SUCCEEDED(rc)) 178 176 rc = rc2; 179 177 180 AssertComRC 181 182 LogFlowFunc 178 AssertComRC(rc); 179 180 LogFlowFunc(("rc=%08X\n", rc)); 183 181 LogFlowFuncLeave(); 184 182 return rc; … … 186 184 187 185 /* static */ 188 void COMBase::ToSafeArray (const QVector <QString> &aVec, 189 com::SafeArray <BSTR> &aArr) 190 { 191 aArr.reset (aVec.size()); 192 for (int i = 0; i < aVec.size(); ++ i) 193 aArr [i] = SysAllocString ((const OLECHAR *) 194 (aVec.at (i).isNull() ? 0 : aVec.at (i).utf16())); 195 } 196 197 /* static */ 198 void COMBase::FromSafeArray (const com::SafeArray <BSTR> &aArr, 199 QVector <QString> &aVec) 186 void COMBase::ToSafeArray(const QVector<QString> &aVec, 187 com::SafeArray<BSTR> &aArr) 188 { 189 aArr.reset(aVec.size()); 190 for (int i = 0; i < aVec.size(); ++ i) 191 aArr [i] = SysAllocString((const OLECHAR *)(aVec.at(i).isNull() ? 0 : aVec.at(i).utf16())); 192 } 193 194 /* static */ 195 void COMBase::FromSafeArray(const com::SafeArray<BSTR> &aArr, 196 QVector<QString> &aVec) 200 197 { 201 198 AssertCompile(sizeof(aArr[0][0]) == sizeof(ushort)); 202 aVec.resize (static_cast <int>(aArr.size()));203 for (int i = 0; i < aVec.size(); ++ i) 204 aVec [i] = QString::fromUtf16 ((const char16_t *)aArr[i]);205 } 206 207 /* static */ 208 void COMBase::ToSafeArray 209 210 { 211 AssertCompileSize (GUID, sizeof(QUuid));212 aArr.reset 213 for (int i = 0; i < aVec.size(); ++ i) 214 aArr [i] = *(GUID*) &aVec[i];215 } 216 217 /* static */ 218 void COMBase::FromSafeArray 219 QVector<QUuid> &aVec)220 { 221 AssertCompileSize (GUID, sizeof(QUuid));222 aVec.resize (static_cast <int>(aArr.size()));199 aVec.resize(static_cast<int>(aArr.size())); 200 for (int i = 0; i < aVec.size(); ++ i) 201 aVec[i] = QString::fromUtf16((const char16_t *)aArr[i]); 202 } 203 204 /* static */ 205 void COMBase::ToSafeArray(const QVector <QUuid> &aVec, 206 com::SafeGUIDArray &aArr) 207 { 208 AssertCompileSize(GUID, sizeof(QUuid)); 209 aArr.reset(aVec.size()); 210 for (int i = 0; i < aVec.size(); ++ i) 211 aArr[i] = *(GUID *)&aVec[i]; 212 } 213 214 /* static */ 215 void COMBase::FromSafeArray(const com::SafeGUIDArray &aArr, 216 QVector<QUuid> &aVec) 217 { 218 AssertCompileSize(GUID, sizeof(QUuid)); 219 aVec.resize (static_cast<int>(aArr.size())); 223 220 for (int i = 0; i < aVec.size(); ++ i) 224 221 { 225 222 #ifdef VBOX_WITH_XPCOM 226 aVec [i] = *(QUuid*) &aArr[i];223 aVec[i] = *(QUuid *)&aArr[i]; 227 224 #else 228 225 /* No by-reference accessor, only by-value. So spell it out to avoid warnings. */ … … 234 231 235 232 /* static */ 236 void COMBase::ToSafeArray (const QVector <QUuid> &aVec, 237 com::SafeArray <BSTR> &aArr) 238 { 239 aArr.reset (aVec.size()); 240 for (int i = 0; i < aVec.size(); ++ i) 241 aArr [i] = SysAllocString ((const OLECHAR *) 242 (aVec.at (i).isNull() ? 0 : aVec.at(i).toString().utf16())); 243 } 244 245 /* static */ 246 void COMBase::FromSafeArray (const com::SafeArray <BSTR> &aArr, 247 QVector <QUuid> &aVec) 233 void COMBase::ToSafeArray(const QVector<QUuid> &aVec, 234 com::SafeArray<BSTR> &aArr) 235 { 236 aArr.reset(aVec.size()); 237 for (int i = 0; i < aVec.size(); ++ i) 238 aArr[i] = SysAllocString((const OLECHAR *)(aVec.at(i).isNull() ? 0 : aVec.at(i).toString().utf16())); 239 } 240 241 /* static */ 242 void COMBase::FromSafeArray(const com::SafeArray<BSTR> &aArr, 243 QVector<QUuid> &aVec) 248 244 { 249 245 AssertCompile(sizeof(aArr[0][0]) == sizeof(ushort)); 250 aVec.resize (static_cast <int>(aArr.size()));251 for (int i = 0; i < aVec.size(); ++ i) 252 aVec [i] = QUuid(QString::fromUtf16 ((const char16_t *)aArr[i]));246 aVec.resize(static_cast<int>(aArr.size())); 247 for (int i = 0; i < aVec.size(); ++ i) 248 aVec[i] = QUuid(QString::fromUtf16((const char16_t *)aArr[i])); 253 249 } 254 250 … … 263 259 mIsFullAvailable = false; 264 260 mResultCode = S_OK; 261 mResultDetail = 0; 265 262 m_pNext = NULL; 266 263 AssertMsgFailedReturnVoid(("error info is NULL!\n")); … … 274 271 gotAll &= info.isOk(); 275 272 273 mResultDetail = info.GetResultDetail(); 274 gotSomething |= info.isOk(); 275 gotAll &= info.isOk(); 276 276 277 mInterfaceID = info.GetInterfaceID(); 277 278 gotSomething |= info.isOk(); 278 279 gotAll &= info.isOk(); 279 280 if (info.isOk()) 280 mInterfaceName = getInterfaceNameFromIID 281 mInterfaceName = getInterfaceNameFromIID(mInterfaceID); 281 282 282 283 mComponent = info.GetComponent(); … … 305 306 mIsNull = !gotSomething; 306 307 307 AssertMsg 308 AssertMsg(gotSomething, ("Nothing to fetch!\n")); 308 309 } 309 310 … … 315 316 316 317 mResultCode = x.mResultCode; 318 mResultDetail = x.mResultDetail; 317 319 mInterfaceID = x.mInterfaceID; 318 320 mComponent = x.mComponent; … … 465 467 466 468 // static 467 QString COMErrorInfo::getInterfaceNameFromIID 469 QString COMErrorInfo::getInterfaceNameFromIID(const QUuid &id) 468 470 { 469 471 QString name; 470 472 471 com::GetInterfaceNameByIID (COMBase::GUIDIn (id), COMBase::BSTROut(name));473 com::GetInterfaceNameByIID(COMBase::GUIDIn(id), COMBase::BSTROut(name)); 472 474 473 475 return name; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h
r103803 r105578 126 126 mIsFullAvailable(false), 127 127 mResultCode(S_OK), 128 mResultDetail(0), 128 129 m_pNext(NULL) 129 130 {} … … 151 152 } 152 153 153 bool isNull() const { return mIsNull; } 154 155 bool isBasicAvailable() const { return mIsBasicAvailable; } 156 bool isFullAvailable() const { return mIsFullAvailable; } 157 158 HRESULT resultCode() const { return mResultCode; } 154 bool isNull() const RT_NOEXCEPT { return mIsNull; } 155 156 bool isBasicAvailable() const RT_NOEXCEPT { return mIsBasicAvailable; } 157 bool isFullAvailable() const RT_NOEXCEPT { return mIsFullAvailable; } 158 159 HRESULT resultCode() const RT_NOEXCEPT { return mResultCode; } 160 ULONG resultDetail() const RT_NOEXCEPT { return mResultDetail; } 159 161 QUuid interfaceID() const { return mInterfaceID; } 160 162 QString component() const { return mComponent; } … … 181 183 182 184 HRESULT mResultCode; 185 ULONG mResultDetail; 183 186 QUuid mInterfaceID; 184 187 QString mComponent; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIErrorString.cpp
r103710 r105578 69 69 /** @todo r=bird: See UIErrorString::formatRC for 31th bit discussion. */ 70 70 char szHex[32]; 71 RTStrPrintf(szHex, sizeof(szHex), "%#010 X", rc);71 RTStrPrintf(szHex, sizeof(szHex), "%#010x", rc); 72 72 73 73 #ifdef RT_OS_WINDOWS … … 193 193 } 194 194 195 if (comInfo.resultDetail() != 0) 196 strFormatted += QString("<tr><td>%1</td><td><tt>%2 (0x%3)</tt></td></tr>") 197 .arg(QApplication::translate("UIErrorString", "Result Detail:", "error info")) 198 .arg(QString::number(int(comInfo.resultDetail()))) /* arg(int()) ends up as unsigned, thus the ::number crap. */ 199 .arg(comInfo.resultDetail(), 0, 16); 200 195 201 if (fHaveComponent) 196 202 strFormatted += QString("<tr><td>%1</td><td>%2</td></tr>")
Note:
See TracChangeset
for help on using the changeset viewer.