VirtualBox

Changeset 91391 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 27, 2021 11:50:27 AM (3 years ago)
Author:
vboxsync
Message:

Main/NLS: More on same. Found bug in i_translate. bugref:1909

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/VirtualBoxTranslator.h

    r91390 r91391  
    4343    HRESULT loadLanguage(ComPtr<IVirtualBox> aVirtualBox);
    4444
     45private:
     46    /** Translator component. */
     47    struct TranslatorComponent
     48    {
     49        QMTranslator *pTranslator;
     50        /** Path to translation files. It includes file prefix, i.e '/path/to/folder/file_prefix'. */
     51        com::Utf8Str  strPath;
     52
     53        TranslatorComponent() : pTranslator(NULL) {}
     54    };
     55public:
    4556    /** Pointer to a translator component. */
    46     typedef struct TranslatorComponent *PTRCOMPONENT;
     57    typedef TranslatorComponent *PTRCOMPONENT;
    4758
    4859    /**
     
    102113    uint32_t m_cInstanceRefs;
    103114
    104     /** Translator component. */
    105     struct TranslatorComponent
    106     {
    107         QMTranslator *pTranslator;
    108         /** Path to translation files. It includes file prefix, i.e '/path/to/folder/file_prefix'. */
    109         com::Utf8Str  strPath;
    110 
    111         TranslatorComponent() : pTranslator(NULL) {}
    112     };
    113115    typedef std::list<TranslatorComponent> TranslatorList;
    114116    TranslatorList  m_lTranslators;
  • trunk/src/VBox/Main/src-all/VirtualBoxTranslator.cpp

    r91390 r91391  
    408408    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    409409
    410     TranslatorComponent *pComponent = (TranslatorComponent *)aComponent;
    411 
    412     if (pComponent == m_pDefaultComponent)
     410    if (aComponent == m_pDefaultComponent)
    413411        m_pDefaultComponent = NULL;
    414412
     
    417415         ++it)
    418416    {
    419         if (&(*it) == pComponent)
    420         {
    421             delete pComponent->pTranslator;
     417        if (&(*it) == aComponent)
     418        {
     419            delete aComponent->pTranslator;
    422420            m_lTranslators.erase(it);
    423421            return VINF_SUCCESS;
     
    481479    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    482480
    483     TranslatorComponent *pComponent = (TranslatorComponent *)aComponent;
    484     if (pComponent == NULL)
    485         pComponent = m_pDefaultComponent;
    486 
    487     if (   pComponent == NULL
    488         || pComponent->pTranslator == NULL)
     481    if (aComponent == NULL)
     482        aComponent = m_pDefaultComponent;
     483
     484    if (   aComponent == NULL
     485        || aComponent->pTranslator == NULL)
    489486        return aSourceText;
    490487
    491     const char *pszTranslation = pComponent->pTranslator->translate(aContext, aSourceText, aComment, aNum);
     488    const char *pszTranslation = aComponent->pTranslator->translate(aContext, aSourceText, aComment, aNum);
    492489
    493490    LastTranslation *pEntry = getTlsEntry();
     
    495492    {
    496493        pEntry->first = pszTranslation;
    497         pEntry->second = m_hStrCache != NIL_RTSTRCACHE ?
    498                             RTStrCacheEnter(m_hStrCache, aSourceText) :
    499                             aSourceText;
     494        /** @todo r=bird: This is not technically threadsafe.  Move this down to the
     495         *        above translator call. */
     496        pEntry->second = m_hStrCache != NIL_RTSTRCACHE ? RTStrCacheEnter(m_hStrCache, aSourceText) : aSourceText;
    500497    }
    501498
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette