Hiroyuki Ikezoe
poinc****@ikezo*****
2005年 10月 12日 (水) 19:24:31 JST
zoeです。 2005-10-12 (水) の 09:09 +0900 に Hiroyuki Ikezoe さんは書きました: > * scim-primeでIConvertをstaticじゃなくする > * glibcのiconv調査 > > の順に作業を進めます。 てけとーに修正したパッチを投げときます。 -------------- next part -------------- ? p Index: prime_connection.cpp =================================================================== RCS file: /cvsroot/scim-imengine/scim-prime/src/prime_connection.cpp,v retrieving revision 1.21 diff -u -r1.21 prime_connection.cpp --- prime_connection.cpp 23 Aug 2005 08:00:26 -0000 1.21 +++ prime_connection.cpp 12 Oct 2005 10:20:53 -0000 @@ -72,7 +72,10 @@ std::vector<PrimeConnection *>::iterator it; for (it = connection_list.begin (); it != connection_list.end (); it++) { if ((*it) == this) + { connection_list.erase (it); + break; + } } } Index: scim_prime_imengine.cpp =================================================================== RCS file: /cvsroot/scim-imengine/scim-prime/src/scim_prime_imengine.cpp,v retrieving revision 1.92 diff -u -r1.92 scim_prime_imengine.cpp --- scim_prime_imengine.cpp 29 Aug 2005 01:43:31 -0000 1.92 +++ scim_prime_imengine.cpp 12 Oct 2005 10:20:53 -0000 @@ -53,9 +53,11 @@ #define MAX_TRY_RECOVERY 3 -PrimeConnection PrimeInstance::m_prime = PrimeConnection(); unsigned int PrimeInstance::m_recovery_count = 0; +unsigned int m_prime_ref_count = 0; +PrimeConnection* m_prime = NULL; + PrimeInstance::PrimeInstance (PrimeFactory *factory, const String &encoding, int id) @@ -75,9 +77,14 @@ { SCIM_DEBUG_IMENGINE(1) << "Create PRIME Instance : "; - if (!m_prime.is_connected ()) { + if (!m_prime) { + m_prime = new PrimeConnection; + } + m_prime_ref_count++; + + if (!m_prime->is_connected ()) { bool rv; - rv = m_prime.open_connection (m_factory->m_command.c_str(), + rv = m_prime->open_connection (m_factory->m_command.c_str(), m_factory->m_typing_method.c_str()); if (!rv) { m_disable = true; @@ -89,10 +96,16 @@ PrimeInstance::~PrimeInstance () { if (m_session) { - m_prime.session_end (m_session); + m_prime->session_end (m_session); delete m_session; m_session = NULL; } + + m_prime_ref_count--; + if (m_prime_ref_count == 0 && m_prime) { + delete m_prime; + m_prime = NULL; + } } bool @@ -425,14 +438,14 @@ if (m_disable) return NULL; - if (m_prime.major_version () < 0 || !m_prime.is_connected ()) { + if (m_prime->major_version () < 0 || !m_prime->is_connected ()) { delete m_session; m_session = NULL; m_disable = true; set_error_message (); return NULL; - } else if (m_prime.major_version () < 1) { + } else if (m_prime->major_version () < 1) { const char *message = _("Your PRIME is out of date. " "Please install PRIME-1.0.0 or later."); show_aux_string (); @@ -958,7 +971,7 @@ if (m_registering_key.length () > 0 && m_registering_value.length () > 0) { - m_prime.learn_word (m_registering_key, m_registering_value, + m_prime->learn_word (m_registering_key, m_registering_value, WideString (), WideString (), WideString (), WideString ()); } @@ -1896,14 +1909,14 @@ m_language = SCIM_PRIME_LANGUAGE_JAPANESE; } else { m_session->edit_get_query_string (query); - m_prime.session_end (m_session); + m_prime->session_end (m_session); delete m_session; m_session = NULL; } } if (!m_session) { - m_session = m_prime.session_start ("Japanese"); + m_session = m_prime->session_start ("Japanese"); if (m_session) { m_language = SCIM_PRIME_LANGUAGE_JAPANESE; m_session->edit_insert (query.c_str ()); @@ -1950,14 +1963,14 @@ m_language = SCIM_PRIME_LANGUAGE_ENGLISH; } else { m_session->edit_get_query_string (query); - m_prime.session_end (m_session); + m_prime->session_end (m_session); delete m_session; m_session = NULL; } } if (!m_session) { - m_session = m_prime.session_start ("English"); + m_session = m_prime->session_start ("English"); if (m_session) { m_language = SCIM_PRIME_LANGUAGE_ENGLISH; m_session->edit_insert (query.c_str ()); @@ -2022,7 +2035,7 @@ return false; bool rv; - rv = m_prime.open_connection (m_factory->m_command.c_str(), + rv = m_prime->open_connection (m_factory->m_command.c_str(), m_factory->m_typing_method.c_str()); if (rv) { m_disable = false; @@ -2095,7 +2108,7 @@ PrimeInstance::set_error_message (void) { WideString msg; - m_prime.get_error_message (msg); + m_prime->get_error_message (msg); update_aux_string (msg); show_aux_string (); Index: scim_prime_imengine.h =================================================================== RCS file: /cvsroot/scim-imengine/scim-prime/src/scim_prime_imengine.h,v retrieving revision 1.41 diff -u -r1.41 scim_prime_imengine.h --- scim_prime_imengine.h 29 Aug 2005 01:43:31 -0000 1.41 +++ scim_prime_imengine.h 12 Oct 2005 10:20:53 -0000 @@ -159,7 +159,6 @@ void set_error_message (void); private: - static PrimeConnection m_prime; static unsigned int m_recovery_count; PrimeSession *m_session;