Changeset 25942 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 20, 2010 5:26:22 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56784
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r25860 r25942 430 430 // So use a fallback approach similar to Linux. 431 431 { 432 if (RTEnv Get("VBOX_CDROM"))432 if (RTEnvExistEx(RTENV_DEFAULT, "VBOX_CDROM")) 433 433 { 434 char *cdromEnv = strdup(RTEnvGet("VBOX_CDROM"));434 char *cdromEnv = RTEnvDupEx(RTENV_DEFAULT, "VBOX_CDROM"); 435 435 char *saveStr = NULL; 436 436 char *cdromDrive = NULL; … … 448 448 cdromDrive = strtok_r(NULL, ":", &saveStr); 449 449 } 450 free(cdromEnv);450 RTStrFree(cdromEnv); 451 451 } 452 452 else -
trunk/src/VBox/Main/freebsd/HostHardwareFreeBSD.cpp
r25728 r25942 341 341 int rc = VINF_SUCCESS; 342 342 bool success = false; 343 char *pszFreeMe = RTEnvDupEx(RTENV_DEFAULT, pcszVar); 343 344 344 345 try 345 346 { 346 const char *pcszCurrent = RTEnvGet (pcszVar);347 const char *pcszCurrent = pszFreeMe; 347 348 while (pcszCurrent && *pcszCurrent != '\0') 348 349 { … … 357 358 if (RT_SUCCESS(RTPathReal(szPath, szReal, sizeof(szReal)))) 358 359 { 360 szUdi[0] = '\0'; /** @todo r=bird: missing a call to devValidateDevice() here and szUdi wasn't 361 * initialized because of that. Need proper fixing. */ 359 362 pList->push_back(DriveInfo(szReal, szUdi, szDesc)); 360 363 success = true; … … 369 372 rc = VERR_NO_MEMORY; 370 373 } 371 LogFlowFunc (("rc=%Rrc, success=%d\n", rc, success)); 374 RTStrFree(pszFreeMe); 375 LogFlowFunc(("rc=%Rrc, success=%d\n", rc, success)); 372 376 return rc; 373 377 } -
trunk/src/VBox/Main/glue/com.cpp
r22708 r25942 138 138 } 139 139 140 int GetVBoxUserHomeDirectory 140 int GetVBoxUserHomeDirectory(char *aDir, size_t aDirLen) 141 141 { 142 142 AssertReturn(aDir, VERR_INVALID_POINTER); … … 146 146 *aDir = 0; 147 147 148 const char *VBoxUserHome = RTEnvGet 148 const char *VBoxUserHome = RTEnvGet("VBOX_USER_HOME"); 149 149 150 150 char path [RTPATH_MAX]; … … 155 155 /* get the full path name */ 156 156 char *VBoxUserHomeUtf8 = NULL; 157 vrc = RTStrCurrentCPToUtf8 157 vrc = RTStrCurrentCPToUtf8(&VBoxUserHomeUtf8, VBoxUserHome); 158 158 if (RT_SUCCESS(vrc)) 159 159 { 160 vrc = RTPathAbs 160 vrc = RTPathAbs(VBoxUserHomeUtf8, path, sizeof (path)); 161 161 if (RT_SUCCESS(vrc)) 162 162 { 163 if (aDirLen < strlen 163 if (aDirLen < strlen(path) + 1) 164 164 vrc = VERR_BUFFER_OVERFLOW; 165 165 else 166 strcpy 166 strcpy(aDir, path); 167 167 } 168 RTStrFree 168 RTStrFree(VBoxUserHomeUtf8); 169 169 } 170 170 } … … 172 172 { 173 173 /* compose the config directory (full path) */ 174 vrc = RTPathUserHome (path, sizeof(path));174 vrc = RTPathUserHome(path, sizeof(path)); 175 175 if (RT_SUCCESS(vrc)) 176 176 { 177 size_t len = 178 RTStrPrintf (aDir, aDirLen, "%s%c%s", 179 path, RTPATH_DELIMITER, VBOX_USER_HOME_SUFFIX); 180 if (len != strlen (path) + 1 + strlen (VBOX_USER_HOME_SUFFIX)) 177 size_t len = RTStrPrintf(aDir, aDirLen, "%s%c%s", 178 path, RTPATH_DELIMITER, VBOX_USER_HOME_SUFFIX); 179 if (len != strlen(path) + 1 + strlen (VBOX_USER_HOME_SUFFIX)) 181 180 vrc = VERR_BUFFER_OVERFLOW; 182 181 } … … 185 184 /* ensure the home directory exists */ 186 185 if (RT_SUCCESS(vrc)) 187 if (!RTDirExists 188 vrc = RTDirCreateFullPath 186 if (!RTDirExists(aDir)) 187 vrc = RTDirCreateFullPath(aDir, 0777); 189 188 190 189 return vrc; -
trunk/src/VBox/Main/glue/initterm.cpp
r25813 r25942 6 6 7 7 /* 8 * Copyright (C) 2006-20 07Sun Microsystems, Inc.8 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 */ 22 22 23 #if !defined 24 25 # include <objbase.h>23 #if !defined(VBOX_WITH_XPCOM) 24 25 # include <objbase.h> 26 26 27 27 #else /* !defined (VBOX_WITH_XPCOM) */ 28 28 29 # include <stdlib.h>30 31 /* XPCOM_GLUE is defined when the client uses the standalone glue32 * (i.e. dynamically picks up the existing XPCOM shared library installation).33 * This is not the case for VirtualBox XPCOM clients (they are always34 * distrubuted with the self-built XPCOM library, and therefore have a binary35 * dependency on it) but left here for clarity.36 */37 # if defined(XPCOM_GLUE)38 # include <nsXPCOMGlue.h>39 # endif40 41 # include <nsIComponentRegistrar.h>42 # include <nsIServiceManager.h>43 # include <nsCOMPtr.h>44 # include <nsEventQueueUtils.h>45 # include <nsEmbedString.h>46 47 # include <nsILocalFile.h>48 # include <nsIDirectoryService.h>49 # include <nsDirectoryServiceDefs.h>50 51 #endif /* !defined 29 # include <stdlib.h> 30 31 /* XPCOM_GLUE is defined when the client uses the standalone glue 32 * (i.e. dynamically picks up the existing XPCOM shared library installation). 33 * This is not the case for VirtualBox XPCOM clients (they are always 34 * distrubuted with the self-built XPCOM library, and therefore have a binary 35 * dependency on it) but left here for clarity. 36 */ 37 # if defined(XPCOM_GLUE) 38 # include <nsXPCOMGlue.h> 39 # endif 40 41 # include <nsIComponentRegistrar.h> 42 # include <nsIServiceManager.h> 43 # include <nsCOMPtr.h> 44 # include <nsEventQueueUtils.h> 45 # include <nsEmbedString.h> 46 47 # include <nsILocalFile.h> 48 # include <nsIDirectoryService.h> 49 # include <nsDirectoryServiceDefs.h> 50 51 #endif /* !defined(VBOX_WITH_XPCOM) */ 52 52 53 53 #include "VBox/com/com.h" … … 70 70 { 71 71 72 #if defined 72 #if defined(VBOX_WITH_XPCOM) 73 73 74 74 class DirectoryServiceProvider : public nsIDirectoryServiceProvider … … 79 79 80 80 DirectoryServiceProvider() 81 : mCompRegLocation (NULL), mXPTIDatLocation(NULL)82 , mComponentDirLocation (NULL), mCurrProcDirLocation(NULL)81 : mCompRegLocation(NULL), mXPTIDatLocation(NULL) 82 , mComponentDirLocation(NULL), mCurrProcDirLocation(NULL) 83 83 {} 84 84 85 85 virtual ~DirectoryServiceProvider(); 86 86 87 HRESULT init 88 89 90 87 HRESULT init(const char *aCompRegLocation, 88 const char *aXPTIDatLocation, 89 const char *aComponentDirLocation, 90 const char *aCurrProcDirLocation); 91 91 92 92 NS_DECL_NSIDIRECTORYSERVICEPROVIDER 93 93 94 94 private: 95 95 /** @remarks This is not a UTF-8 string. */ 96 96 char *mCompRegLocation; 97 /** @remarks This is not a UTF-8 string. */ 97 98 char *mXPTIDatLocation; 99 /** @remarks This is not a UTF-8 string. */ 98 100 char *mComponentDirLocation; 101 /** @remarks This is not a UTF-8 string. */ 99 102 char *mCurrProcDirLocation; 100 103 }; 101 104 102 NS_IMPL_ISUPPORTS1 105 NS_IMPL_ISUPPORTS1(DirectoryServiceProvider, nsIDirectoryServiceProvider) 103 106 104 107 DirectoryServiceProvider::~DirectoryServiceProvider() … … 106 109 if (mCompRegLocation) 107 110 { 108 RTStrFree 111 RTStrFree(mCompRegLocation); 109 112 mCompRegLocation = NULL; 110 113 } 111 114 if (mXPTIDatLocation) 112 115 { 113 RTStrFree 116 RTStrFree(mXPTIDatLocation); 114 117 mXPTIDatLocation = NULL; 115 118 } 116 119 if (mComponentDirLocation) 117 120 { 118 RTStrFree 121 RTStrFree(mComponentDirLocation); 119 122 mComponentDirLocation = NULL; 120 123 } 121 124 if (mCurrProcDirLocation) 122 125 { 123 RTStrFree 126 RTStrFree(mCurrProcDirLocation); 124 127 mCurrProcDirLocation = NULL; 125 128 } … … 131 134 */ 132 135 HRESULT 133 DirectoryServiceProvider::init 134 135 136 136 DirectoryServiceProvider::init(const char *aCompRegLocation, 137 const char *aXPTIDatLocation, 138 const char *aComponentDirLocation, 139 const char *aCurrProcDirLocation) 137 140 { 138 141 AssertReturn(aCompRegLocation, NS_ERROR_INVALID_ARG); 139 142 AssertReturn(aXPTIDatLocation, NS_ERROR_INVALID_ARG); 140 143 141 int vrc = RTStrUtf8ToCurrentCP (&mCompRegLocation, aCompRegLocation); 144 /** @todo r=bird: Gotta check how this encoding stuff plays out on darwin! 145 * We get down to [VBoxNsxp]NS_NewNativeLocalFile and that file isn't 146 * nsLocalFileUnix.cpp on 32-bit darwin. On 64-bit darwin it's a question 147 * of what we're doing in IPRT and such... We should probably add a 148 * RTPathConvertToNative for use here. */ 149 int vrc = RTStrUtf8ToCurrentCP(&mCompRegLocation, aCompRegLocation); 142 150 if (RT_SUCCESS(vrc)) 143 vrc = RTStrUtf8ToCurrentCP 151 vrc = RTStrUtf8ToCurrentCP(&mXPTIDatLocation, aXPTIDatLocation); 144 152 if (RT_SUCCESS(vrc) && aComponentDirLocation) 145 vrc = RTStrUtf8ToCurrentCP 153 vrc = RTStrUtf8ToCurrentCP(&mComponentDirLocation, aComponentDirLocation); 146 154 if (RT_SUCCESS(vrc) && aCurrProcDirLocation) 147 vrc = RTStrUtf8ToCurrentCP 155 vrc = RTStrUtf8ToCurrentCP(&mCurrProcDirLocation, aCurrProcDirLocation); 148 156 149 157 return RT_SUCCESS(vrc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; … … 151 159 152 160 NS_IMETHODIMP 153 DirectoryServiceProvider::GetFile 154 155 161 DirectoryServiceProvider::GetFile(const char *aProp, 162 PRBool *aPersistent, 163 nsIFile **aRetval) 156 164 { 157 165 nsCOMPtr <nsILocalFile> localFile; … … 163 171 const char *fileLocation = NULL; 164 172 165 if (strcmp 173 if (strcmp(aProp, NS_XPCOM_COMPONENT_REGISTRY_FILE) == 0) 166 174 fileLocation = mCompRegLocation; 167 else if (strcmp 175 else if (strcmp(aProp, NS_XPCOM_XPTI_REGISTRY_FILE) == 0) 168 176 fileLocation = mXPTIDatLocation; 169 else if (mComponentDirLocation && strcmp 177 else if (mComponentDirLocation && strcmp(aProp, NS_XPCOM_COMPONENT_DIR) == 0) 170 178 fileLocation = mComponentDirLocation; 171 else if (mCurrProcDirLocation && strcmp 179 else if (mCurrProcDirLocation && strcmp(aProp, NS_XPCOM_CURRENT_PROCESS_DIR) == 0) 172 180 fileLocation = mCurrProcDirLocation; 173 181 else 174 182 return NS_ERROR_FAILURE; 175 183 176 rv = NS_NewNativeLocalFile (nsEmbedCString(fileLocation),177 PR_TRUE, getter_AddRefs(localFile));184 rv = NS_NewNativeLocalFile(nsEmbedCString(fileLocation), 185 PR_TRUE, getter_AddRefs(localFile)); 178 186 if (NS_FAILED(rv)) 179 187 return rv; 180 188 181 return localFile->QueryInterface (NS_GET_IID (nsIFile), 182 (void **) aRetval); 189 return localFile->QueryInterface(NS_GET_IID (nsIFile), (void **)aRetval); 183 190 } 184 191 … … 248 255 HRESULT rc = E_FAIL; 249 256 250 #if !defined 251 252 DWORD flags = COINIT_MULTITHREADED |253 COINIT_DISABLE_OLE1DDE |254 255 256 rc = CoInitializeEx 257 #if !defined(VBOX_WITH_XPCOM) 258 259 DWORD flags = COINIT_MULTITHREADED 260 | COINIT_DISABLE_OLE1DDE 261 | COINIT_SPEED_OVER_MEMORY; 262 263 rc = CoInitializeEx(NULL, flags); 257 264 258 265 /// @todo the below rough method of changing the aparment type doesn't … … 279 286 * worry at all. */ 280 287 281 rc = CoInitializeEx 288 rc = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); 282 289 if (rc == RPC_E_CHANGED_MODE) 283 290 { … … 285 292 rc = S_OK; 286 293 287 LogFlowFunc 288 294 LogFlowFunc(("COM is already initialized in neutral threaded " 295 "apartment mode,\nwill accept it.\n")); 289 296 } 290 297 else if (rc == S_FALSE) … … 294 301 rc = RPC_E_CHANGED_MODE; 295 302 296 LogFlowFunc 297 298 303 LogFlowFunc(("COM is already initialized in single threaded " 304 "apartment mode,\nwill reinitialize as " 305 "multi threaded.\n")); 299 306 300 307 enum { MaxTries = 10000 }; … … 303 310 { 304 311 CoUninitialize(); 305 rc = CoInitializeEx 312 rc = CoInitializeEx(NULL, flags); 306 313 if (rc == S_OK) 307 314 { … … 309 316 * initialization reference counter */ 310 317 311 LogFlowFunc 312 318 LogFlowFunc(("Will call CoInitializeEx() %d times.\n", 319 MaxTries - tries)); 313 320 314 321 while (tries ++ < MaxTries) 315 322 { 316 rc = CoInitializeEx 317 Assert 323 rc = CoInitializeEx(NULL, flags); 324 Assert(rc == S_FALSE); 318 325 } 319 326 } … … 321 328 } 322 329 else 323 AssertMsgFailed 330 AssertMsgFailed(("rc=%08X\n", rc)); 324 331 } 325 332 # endif … … 327 334 /* the overall result must be either S_OK or S_FALSE (S_FALSE means 328 335 * "already initialized using the same apartment model") */ 329 AssertMsg 336 AssertMsg(rc == S_OK || rc == S_FALSE, ("rc=%08X\n", rc)); 330 337 331 338 /* To be flow compatible with the XPCOM case, we return here if this isn't … … 334 341 * counting, so this exercise is entirely for the EventQueue init. */ 335 342 bool fRc; 336 RTTHREAD hSelf = RTThreadSelf 343 RTTHREAD hSelf = RTThreadSelf(); 337 344 if (hSelf != NIL_RTTHREAD) 338 ASMAtomicCmpXchgHandle 345 ASMAtomicCmpXchgHandle(&gCOMMainThread, hSelf, NIL_RTTHREAD, fRc); 339 346 else 340 347 fRc = false; … … 342 349 { 343 350 if ( gCOMMainThread == hSelf 344 && SUCCEEDED 351 && SUCCEEDED(rc)) 345 352 gCOMMainInitCount++; 346 353 347 AssertComRC 354 AssertComRC(rc); 348 355 return rc; 349 356 } 350 Assert (RTThreadIsMain(hSelf));357 Assert(RTThreadIsMain(hSelf)); 351 358 352 359 /* this is the first main thread initialization */ 353 Assert 354 if (SUCCEEDED 360 Assert(gCOMMainInitCount == 0); 361 if (SUCCEEDED(rc)) 355 362 gCOMMainInitCount = 1; 356 363 357 364 #else /* !defined (VBOX_WITH_XPCOM) */ 358 365 359 if (ASMAtomicXchgBool 366 if (ASMAtomicXchgBool(&gIsXPCOMInitialized, true) == true) 360 367 { 361 368 /* XPCOM is already initialized on the main thread, no special … … 365 372 * Win32). */ 366 373 367 nsCOMPtr 368 rc = NS_GetMainEventQ (getter_AddRefs(eventQ));374 nsCOMPtr<nsIEventQueue> eventQ; 375 rc = NS_GetMainEventQ(getter_AddRefs(eventQ)); 369 376 370 377 if (NS_SUCCEEDED(rc)) 371 378 { 372 379 PRBool isOnMainThread = PR_FALSE; 373 rc = eventQ->IsOnCurrentThread 380 rc = eventQ->IsOnCurrentThread(&isOnMainThread); 374 381 if (NS_SUCCEEDED(rc) && isOnMainThread) 375 ++ 376 } 377 378 AssertComRC 382 ++gXPCOMInitCount; 383 } 384 385 AssertComRC(rc); 379 386 return rc; 380 387 } 381 Assert (RTThreadIsMain(RTThreadSelf()));388 Assert(RTThreadIsMain(RTThreadSelf())); 382 389 383 390 /* this is the first initialization */ … … 386 393 387 394 /* prepare paths for registry files */ 388 char userHomeDir [RTPATH_MAX]; 389 int vrc = GetVBoxUserHomeDirectory (userHomeDir, sizeof (userHomeDir)); 390 AssertRCReturn (vrc, NS_ERROR_FAILURE); 391 392 char compReg [RTPATH_MAX]; 393 char xptiDat [RTPATH_MAX]; 394 395 /** @todo use RTPathAppend */ 396 RTStrPrintf (compReg, sizeof (compReg), "%s%c%s", 397 userHomeDir, RTPATH_DELIMITER, "compreg.dat"); 398 RTStrPrintf (xptiDat, sizeof (xptiDat), "%s%c%s", 399 userHomeDir, RTPATH_DELIMITER, "xpti.dat"); 400 401 LogFlowFunc (("component registry : \"%s\"\n", compReg)); 402 LogFlowFunc (("XPTI data file : \"%s\"\n", xptiDat)); 395 char szCompReg[RTPATH_MAX]; 396 char szXptiDat[RTPATH_MAX]; 397 398 int vrc = GetVBoxUserHomeDirectory(szCompReg, sizeof(szCompReg)); 399 AssertRCReturn(vrc, NS_ERROR_FAILURE); 400 strcpy(szXptiDat, szCompReg); 401 402 vrc = RTPathAppend(szCompReg, sizeof(szCompReg), "compreg.dat"); 403 AssertRCReturn(vrc, NS_ERROR_FAILURE); 404 vrc = RTPathAppend(szXptiDat, sizeof(szXptiDat), "xpti.dat"); 405 AssertRCReturn(vrc, NS_ERROR_FAILURE); 406 407 LogFlowFunc(("component registry : \"%s\"\n", szCompReg)); 408 LogFlowFunc(("XPTI data file : \"%s\"\n", szXptiDat)); 403 409 404 410 #if defined (XPCOM_GLUE) 405 XPCOMGlueStartup 411 XPCOMGlueStartup(nsnull); 406 412 #endif 407 413 … … 422 428 423 429 /* Find out the directory where VirtualBox binaries are located */ 424 for (size_t i = 0; i < RT_ELEMENTS (kAppPathsToProbe); ++ i) 425 { 426 char appHomeDir [RTPATH_MAX]; 427 appHomeDir [RTPATH_MAX - 1] = '\0'; 430 for (size_t i = 0; i < RT_ELEMENTS(kAppPathsToProbe); ++ i) 431 { 432 char szAppHomeDir[RTPATH_MAX]; 428 433 429 434 if (i == 0) 430 435 { 431 436 /* Use VBOX_APP_HOME if present */ 432 if (!RTEnvExist ("VBOX_APP_HOME")) 437 vrc = RTEnvGetEx(RTENV_DEFAULT, "VBOX_APP_HOME", szAppHomeDir, sizeof(szAppHomeDir), NULL); 438 if (vrc == VERR_ENV_VAR_NOT_FOUND) 433 439 continue; 434 435 strncpy (appHomeDir, RTEnvGet ("VBOX_APP_HOME"), RTPATH_MAX - 1); /** @todo r=bird: Use RTEnvGetEx. */ 440 AssertRC(vrc); 436 441 } 437 442 else if (i == 1) 438 443 { 439 444 /* Use RTPathAppPrivateArch() first */ 440 vrc = RTPathAppPrivateArch (appHomeDir, sizeof (appHomeDir));445 vrc = RTPathAppPrivateArch(szAppHomeDir, sizeof(szAppHomeDir)); 441 446 AssertRC (vrc); 442 if (RT_FAILURE(vrc))443 {444 rc = NS_ERROR_FAILURE;445 continue;446 }447 447 } 448 448 else 449 449 { 450 450 /* Iterate over all other paths */ 451 strncpy (appHomeDir, kAppPathsToProbe [i], RTPATH_MAX - 1); 452 } 453 454 nsCOMPtr <DirectoryServiceProvider> dsProv; 455 456 char compDir [RTPATH_MAX]; 457 RTStrPrintf (compDir, sizeof (compDir), "%s%c%s", 458 appHomeDir, RTPATH_DELIMITER, "components"); 459 LogFlowFunc (("component directory : \"%s\"\n", compDir)); 460 451 szAppHomeDir[RTPATH_MAX - 1] = '\0'; 452 strncpy(szAppHomeDir, kAppPathsToProbe [i], RTPATH_MAX - 1); 453 vrc = VINF_SUCCESS; 454 } 455 if (RT_FAILURE(vrc)) 456 { 457 rc = NS_ERROR_FAILURE; 458 continue; 459 } 460 461 char szCompDir[RTPATH_MAX]; 462 vrc = RTPathAppend(strcpy(szCompDir, szAppHomeDir), sizeof(szCompDir), "components"); 463 if (RT_FAILURE(vrc)) 464 { 465 rc = NS_ERROR_FAILURE; 466 continue; 467 } 468 LogFlowFunc(("component directory : \"%s\"\n", szCompDir)); 469 470 nsCOMPtr<DirectoryServiceProvider> dsProv; 461 471 dsProv = new DirectoryServiceProvider(); 462 472 if (dsProv) 463 rc = dsProv->init (compReg, xptiDat, compDir, appHomeDir);473 rc = dsProv->init(szCompReg, szXptiDat, szCompDir, szAppHomeDir); 464 474 else 465 475 rc = NS_ERROR_OUT_OF_MEMORY; 466 if (NS_FAILED 476 if (NS_FAILED(rc)) 467 477 break; 468 478 … … 475 485 { 476 486 char *appDirCP = NULL; 477 vrc = RTStrUtf8ToCurrentCP (&appDirCP, appHomeDir);487 vrc = RTStrUtf8ToCurrentCP(&appDirCP, szAppHomeDir); 478 488 if (RT_SUCCESS(vrc)) 479 489 { 480 nsCOMPtr 481 rc = NS_NewNativeLocalFile (nsEmbedCString(appDirCP),482 PR_FALSE, getter_AddRefs(file));490 nsCOMPtr<nsILocalFile> file; 491 rc = NS_NewNativeLocalFile(nsEmbedCString(appDirCP), 492 PR_FALSE, getter_AddRefs(file)); 483 493 if (NS_SUCCEEDED(rc)) 484 appDir = do_QueryInterface 485 486 RTStrFree 494 appDir = do_QueryInterface(file, &rc); 495 496 RTStrFree(appDirCP); 487 497 } 488 498 else 489 499 rc = NS_ERROR_FAILURE; 490 500 } 491 if (NS_FAILED 501 if (NS_FAILED(rc)) 492 502 break; 493 503 494 504 /* Set VBOX_XPCOM_HOME to the same app path to make XPCOM sources that 495 505 * still use it instead of the directory service happy */ 496 { 497 char *pathCP = NULL; 498 vrc = RTStrUtf8ToCurrentCP (&pathCP, appHomeDir); 499 if (RT_SUCCESS(vrc)) 500 { 501 vrc = RTEnvSet ("VBOX_XPCOM_HOME", pathCP); 502 RTStrFree (pathCP); 503 } 504 AssertRC (vrc); 505 } 506 vrc = RTEnvSetEx(RTENV_DEFAULT, "VBOX_XPCOM_HOME", szAppHomeDir); 507 AssertRC(vrc); 506 508 507 509 /* Finally, initialize XPCOM */ 508 510 { 509 nsCOMPtr <nsIServiceManager> serviceManager; 510 rc = NS_InitXPCOM2 (getter_AddRefs (serviceManager), 511 appDir, dsProv); 512 511 nsCOMPtr<nsIServiceManager> serviceManager; 512 rc = NS_InitXPCOM2(getter_AddRefs(serviceManager), appDir, dsProv); 513 513 if (NS_SUCCEEDED(rc)) 514 514 { 515 nsCOMPtr 516 do_QueryInterface 515 nsCOMPtr<nsIComponentRegistrar> registrar = 516 do_QueryInterface(serviceManager, &rc); 517 517 if (NS_SUCCEEDED(rc)) 518 518 { 519 rc = registrar->AutoRegister 519 rc = registrar->AutoRegister(nsnull); 520 520 if (NS_SUCCEEDED(rc)) 521 521 { 522 522 /* We succeeded, stop probing paths */ 523 LogFlowFunc 523 LogFlowFunc(("Succeeded.\n")); 524 524 break; 525 525 } … … 529 529 530 530 /* clean up before the new try */ 531 rc = NS_ShutdownXPCOM 531 rc = NS_ShutdownXPCOM(nsnull); 532 532 533 533 if (i == 0) … … 545 545 util::InitAutoLockSystem(); 546 546 547 AssertComRC 547 AssertComRC(rc); 548 548 549 549 /* 550 550 * Init the main event queue (ASSUMES it cannot fail). 551 551 */ 552 if (SUCCEEDED 552 if (SUCCEEDED(rc)) 553 553 EventQueue::init(); 554 554 … … 560 560 HRESULT rc = S_OK; 561 561 562 #if !defined 562 #if !defined(VBOX_WITH_XPCOM) 563 563 564 564 /* EventQueue::uninit reference counting fun. */ … … 570 570 { 571 571 EventQueue::uninit(); 572 ASMAtomicWriteHandle 572 ASMAtomicWriteHandle(&gCOMMainThread, NIL_RTTHREAD); 573 573 } 574 574 } … … 578 578 #else /* !defined (VBOX_WITH_XPCOM) */ 579 579 580 nsCOMPtr 581 rc = NS_GetMainEventQ (getter_AddRefs(eventQ));580 nsCOMPtr<nsIEventQueue> eventQ; 581 rc = NS_GetMainEventQ(getter_AddRefs(eventQ)); 582 582 583 583 if (NS_SUCCEEDED(rc) || rc == NS_ERROR_NOT_AVAILABLE) … … 593 593 if (NS_SUCCEEDED(rc)) 594 594 { 595 rc = eventQ->IsOnCurrentThread 595 rc = eventQ->IsOnCurrentThread(&isOnMainThread); 596 596 eventQ = nsnull; /* early release before shutdown */ 597 597 } … … 606 606 /* only the main thread needs to uninitialize XPCOM and only if 607 607 * init counter drops to zero */ 608 if (-- 608 if (--gXPCOMInitCount == 0) 609 609 { 610 610 EventQueue::uninit(); 611 rc = NS_ShutdownXPCOM 611 rc = NS_ShutdownXPCOM(nsnull); 612 612 613 613 /* This is a thread initialized XPCOM and set gIsXPCOMInitialized to 614 614 * true. Reset it back to false. */ 615 bool wasInited = ASMAtomicXchgBool 616 Assert 617 NOREF 618 619 # if defined (XPCOM_GLUE)615 bool wasInited = ASMAtomicXchgBool(&gIsXPCOMInitialized, false); 616 Assert(wasInited == true); 617 NOREF(wasInited); 618 619 # if defined (XPCOM_GLUE) 620 620 XPCOMGlueShutdown(); 621 # endif621 # endif 622 622 } 623 623 } 624 624 } 625 625 626 #endif /* !defined 627 628 AssertComRC 626 #endif /* !defined(VBOX_WITH_XPCOM) */ 627 628 AssertComRC(rc); 629 629 630 630 return rc; -
trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
r25728 r25942 581 581 int rc = VINF_SUCCESS; 582 582 bool success = false; 583 char *pszFreeMe = RTEnvDupEx(RTENV_DEFAULT, pcszVar); 583 584 584 585 try 585 586 { 586 const char *pcszCurrent = RTEnvGet (pcszVar);587 const char *pcszCurrent = pszFreeMe; 587 588 while (pcszCurrent && *pcszCurrent != '\0') 588 589 { … … 611 612 rc = VERR_NO_MEMORY; 612 613 } 613 LogFlowFunc (("rc=%Rrc, success=%d\n", rc, success)); 614 RTStrFree(pszFreeMe); 615 LogFlowFunc(("rc=%Rrc, success=%d\n", rc, success)); 614 616 return rc; 615 617 }
Note:
See TracChangeset
for help on using the changeset viewer.