- Timestamp:
- Aug 25, 2021 12:20:08 PM (3 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/VirtualBoxClientImpl.h
r90828 r90879 99 99 ComPtr<IToken> m_pToken; 100 100 const ComObjPtr<EventSource> m_pEventSource; 101 ComPtr<IEventSource> m_pVBoxEventSource; 102 ComPtr<IEventListener> m_pVBoxEventListener; 101 103 102 104 RTTHREAD m_ThreadWatcher; … … 118 120 HRESULT i_reloadApiLanguage(); 119 121 HRESULT i_registerEventListener(); 122 void i_unregisterEventListener(); 120 123 #endif 121 124 }; -
trunk/src/VBox/Main/src-client/VirtualBoxClientImpl.cpp
r90849 r90879 59 59 60 60 61 HRESULT init(VirtualBoxClient *aClient) 62 { 63 mClient = aClient; 61 HRESULT init(void *) 62 { 63 return S_OK; 64 } 65 66 HRESULT init() 67 { 64 68 return S_OK; 65 69 } … … 80 84 case VBoxEventType_OnLanguageChanged: 81 85 { 82 mClient->i_reloadApiLanguage(); 86 VirtualBoxTranslator *pTranslator = VirtualBoxTranslator::instance(); 87 if (pTranslator) 88 { 89 ComPtr<ILanguageChangedEvent> pEvent = aEvent; 90 HRESULT rc = E_FAIL; 91 Assert(pEvent); 92 93 com::Bstr bstrLanguageId; 94 rc = pEvent->COMGETTER(LanguageId)(bstrLanguageId.asOutParam()); 95 AssertComRC(rc); 96 97 com::Utf8Str strLanguageId(bstrLanguageId); 98 pTranslator->i_loadLanguage(strLanguageId.c_str()); 99 pTranslator->release(); 100 } 83 101 break; 84 102 } … … 90 108 return S_OK; 91 109 } 92 private:93 ComObjPtr<VirtualBoxClient> mClient;94 110 }; 95 111 96 typedef ListenerImpl<VBoxEventListener , VirtualBoxClient*> VBoxEventListenerImpl;97 98 VBOX_LISTENER_DECLARE(VBox EventListenerImpl)112 typedef ListenerImpl<VBoxEventListener> VBoxEventListenerImpl; 113 114 VBOX_LISTENER_DECLARE(VBoxTrEventListenerImpl) 99 115 100 116 #endif /* VBOX_WITH_MAIN_NLS */ … … 527 543 if (autoUninitSpan.uninitDone()) 528 544 return; 545 546 #ifdef VBOX_WITH_MAIN_NLS 547 i_unregisterEventListener(); 548 #endif 529 549 530 550 if (mData.m_ThreadWatcher != NIL_RTTHREAD) … … 724 744 HRESULT VirtualBoxClient::i_registerEventListener() 725 745 { 726 ComPtr<IEventSource> pES; 727 HRESULT rc = mData.m_pVirtualBox->COMGETTER(EventSource)(pES.asOutParam()); 746 HRESULT rc = mData.m_pVirtualBox->COMGETTER(EventSource)(mData.m_pVBoxEventSource.asOutParam()); 728 747 if (SUCCEEDED(rc)) 729 748 { 730 ComObjPtr<VBoxEventListenerImpl> aVBoxListener;731 aVBoxListener.createObject();732 aVBoxListener->init(new VBoxEventListener(), this);733 // mData.m_pVBoxListener = aVBoxListener;749 ComObjPtr<VBoxEventListenerImpl> pVBoxListener; 750 pVBoxListener.createObject(); 751 pVBoxListener->init(new VBoxEventListener()); 752 mData.m_pVBoxEventListener = pVBoxListener; 734 753 com::SafeArray<VBoxEventType_T> eventTypes; 735 754 eventTypes.push_back(VBoxEventType_OnLanguageChanged); 736 rc = pES->RegisterListener(aVBoxListener, ComSafeArrayAsInParam(eventTypes), true);755 rc = mData.m_pVBoxEventSource->RegisterListener(pVBoxListener, ComSafeArrayAsInParam(eventTypes), true); 737 756 if (FAILED(rc)) 757 { 738 758 rc = setError(rc, tr("Failed to register listener")); 759 mData.m_pVBoxEventListener.setNull(); 760 mData.m_pVBoxEventSource.setNull(); 761 } 739 762 } 740 763 else … … 743 766 } 744 767 768 void VirtualBoxClient::i_unregisterEventListener() 769 { 770 if (mData.m_pVBoxEventListener.isNotNull()) 771 { 772 if (mData.m_pVBoxEventSource.isNotNull()) 773 mData.m_pVBoxEventSource->UnregisterListener(mData.m_pVBoxEventListener); 774 mData.m_pVBoxEventListener.setNull(); 775 } 776 mData.m_pVBoxEventSource.setNull(); 777 } 778 745 779 #endif /* VBOX_WITH_MAIN_NLS */ 746 780
Note:
See TracChangeset
for help on using the changeset viewer.