- Timestamp:
- Oct 27, 2021 8:21:30 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-all/VirtualBoxTranslator.cpp
r92102 r92115 37 37 RTCRITSECTRW VirtualBoxTranslator::s_instanceRwLock; 38 38 VirtualBoxTranslator *VirtualBoxTranslator::s_pInstance = NULL; 39 /** TLS index that points to the translated text. */ 39 40 static RTTLS g_idxTlsTr = NIL_RTTLS; 41 /** TLS index that points to the original text. */ 40 42 static RTTLS g_idxTlsSrc = NIL_RTTLS; 41 43 … … 57 59 , m_hStrCache(NIL_RTSTRCACHE) 58 60 { 59 RTTlsAllocEx(&g_idxTlsTr, NULL);60 RTTlsAllocEx(&g_idxTlsSrc, NULL);61 g_idxTlsTr = RTTlsAlloc(); 62 g_idxTlsSrc = RTTlsAlloc(); 61 63 int rc = RTStrCacheCreate(&m_hStrCache, "API Translation"); 62 64 m_rcCache = rc; … … 68 70 VirtualBoxTranslator::~VirtualBoxTranslator() 69 71 { 70 if (g_idxTlsTr != NIL_RTTLS) 71 { 72 RTTlsFree(g_idxTlsTr); 73 g_idxTlsTr = NIL_RTTLS; 74 } 75 if (g_idxTlsSrc != NIL_RTTLS) 76 { 77 RTTlsFree(g_idxTlsSrc); 78 g_idxTlsSrc = NIL_RTTLS; 79 } 72 RTTlsFree(g_idxTlsTr); 73 g_idxTlsTr = NIL_RTTLS; 74 RTTlsFree(g_idxTlsSrc); 75 g_idxTlsSrc = NIL_RTTLS; 80 76 81 77 m_pDefaultComponent = NULL; … … 446 442 const char *pszSafeSource = NULL; 447 443 const char *pszTranslation = aComponent->pTranslator->translate(aContext, aSourceText, &pszSafeSource, aComment, aNum); 448 if (pszSafeSource) 449 { 450 if (g_idxTlsSrc != NIL_RTTLS && g_idxTlsTr != NIL_RTTLS) 451 { 452 int vrc = RTTlsSet(g_idxTlsTr, (void*)pszTranslation); 453 if (RT_SUCCESS(vrc)) 454 vrc = RTTlsSet(g_idxTlsSrc, (void*)pszSafeSource); 455 if (RT_FAILURE(vrc)) 456 RTTlsSet(g_idxTlsTr, NULL); 457 } 444 if (pszSafeSource && g_idxTlsSrc != NIL_RTTLS && g_idxTlsTr != NIL_RTTLS) 445 { 446 RTTlsSet(g_idxTlsTr, (void *)pszTranslation); 447 RTTlsSet(g_idxTlsSrc, (void *)pszSafeSource); 458 448 } 459 449 … … 470 460 if (g_idxTlsSrc != NIL_RTTLS && g_idxTlsTr != NIL_RTTLS) 471 461 { 472 const char * pszTranslationTls = NULL;473 const char * pszSourceTls = NULL;474 i nt vrc =RTTlsGetEx(g_idxTlsTr, (void**)&pszTranslationTls);475 if ( RT_SUCCESS(vrc)462 const char * const pszTranslationTls = (const char *)RTTlsGet(g_idxTlsTr); 463 const char * const pszSourceTls = (const char *)RTTlsGet(g_idxTlsSrc); 464 if ( pszSourceTls != NULL 465 && pszTranslationTls != NULL 476 466 && ( pszTranslationTls == aTranslation 477 467 || strcmp(pszTranslationTls, aTranslation) == 0)) 478 { 479 vrc = RTTlsGetEx(g_idxTlsSrc, (void**)&pszSourceTls); 480 if (RT_SUCCESS(vrc)) 481 pszSource = pszSourceTls; 482 } 468 pszSource = pszSourceTls; 483 469 } 484 470 pCurInstance->release();
Note:
See TracChangeset
for help on using the changeset viewer.