mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1280355 part.1 TISInputSourceWrapper::CurrentInputSource() should create the static instance when it's called r=m_kato
This is preparation. TISInputSourceWrapper is created before starting XPCOM, however, when its first instance is created, TextInputHandler.mm tries to log all keyboard layouts and IMEs which are installed into the system. This would be problem if it uses LazyLogModule because it's initialized at starting XPCOM. MozReview-Commit-ID: DWz8TylL175 --HG-- extra : rebase_source : f377530f6325d6fcf8f90be5d6856972e9d312e5
This commit is contained in:
parent
d829b3effe
commit
a39783f70c
@ -55,6 +55,10 @@ class TISInputSourceWrapper
|
||||
{
|
||||
public:
|
||||
static TISInputSourceWrapper& CurrentInputSource();
|
||||
/**
|
||||
* Shutdown() should be called when nobody doesn't need to use this class.
|
||||
*/
|
||||
static void Shutdown();
|
||||
|
||||
TISInputSourceWrapper()
|
||||
{
|
||||
@ -346,6 +350,8 @@ protected:
|
||||
int8_t mIsRTL;
|
||||
|
||||
bool mOverrideKeyboard;
|
||||
|
||||
static TISInputSourceWrapper* sCurrentInputSource;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -290,7 +290,6 @@ IsControlChar(uint32_t aCharCode)
|
||||
}
|
||||
|
||||
static uint32_t gHandlerInstanceCount = 0;
|
||||
static TISInputSourceWrapper gCurrentInputSource;
|
||||
|
||||
static void
|
||||
InitLogModule()
|
||||
@ -303,22 +302,6 @@ InitLogModule()
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
InitCurrentInputSource()
|
||||
{
|
||||
if (gHandlerInstanceCount > 0 &&
|
||||
!gCurrentInputSource.IsInitializedByCurrentInputSource()) {
|
||||
gCurrentInputSource.InitByCurrentInputSource();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
FinalizeCurrentInputSource()
|
||||
{
|
||||
gCurrentInputSource.Clear();
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
@ -328,12 +311,31 @@ FinalizeCurrentInputSource()
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
TISInputSourceWrapper* TISInputSourceWrapper::sCurrentInputSource = nullptr;
|
||||
|
||||
// static
|
||||
TISInputSourceWrapper&
|
||||
TISInputSourceWrapper::CurrentInputSource()
|
||||
{
|
||||
InitCurrentInputSource();
|
||||
return gCurrentInputSource;
|
||||
if (!sCurrentInputSource) {
|
||||
sCurrentInputSource = new TISInputSourceWrapper();
|
||||
}
|
||||
if (!sCurrentInputSource->IsInitializedByCurrentInputSource()) {
|
||||
sCurrentInputSource->InitByCurrentInputSource();
|
||||
}
|
||||
return *sCurrentInputSource;
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
TISInputSourceWrapper::Shutdown()
|
||||
{
|
||||
if (!sCurrentInputSource) {
|
||||
return;
|
||||
}
|
||||
sCurrentInputSource->Clear();
|
||||
delete sCurrentInputSource;
|
||||
sCurrentInputSource = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -3949,7 +3951,7 @@ TextInputHandlerBase::~TextInputHandlerBase()
|
||||
{
|
||||
[mView release];
|
||||
if (--gHandlerInstanceCount == 0) {
|
||||
FinalizeCurrentInputSource();
|
||||
TISInputSourceWrapper::Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user