From 1e18f80266808ba71138775d73244abff6f2fdd7 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Sat, 8 Oct 2011 10:03:26 +0800 Subject: [PATCH] alloc/free pinyin instance --- src/PYMain.cc | 2 +- src/PYPBopomofoEditor.cc | 4 ++++ src/PYPDoublePinyinEditor.cc | 8 ++++++++ src/PYPDoublePinyinEditor.h | 1 + src/PYPFullPinyinEditor.cc | 4 ++++ src/PYPPinyinEditor.h | 2 -- 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/PYMain.cc b/src/PYMain.cc index d24cc3c..ae7c4cd 100644 --- a/src/PYMain.cc +++ b/src/PYMain.cc @@ -87,9 +87,9 @@ start_component (void) } Database::init (); + LibPinyinBackEnd::init (); PinyinConfig::init (bus); BopomofoConfig::init (bus); - LibPinyinBackEnd::init (); g_signal_connect ((IBusBus *)bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), NULL); diff --git a/src/PYPBopomofoEditor.cc b/src/PYPBopomofoEditor.cc index 1945183..f13fcc9 100644 --- a/src/PYPBopomofoEditor.cc +++ b/src/PYPBopomofoEditor.cc @@ -20,6 +20,7 @@ */ #include "PYPBopomofoEditor.h" #include "PYConfig.h" +#include "PYLibPinyin.h" #include "PYPinyinProperties.h" #include "PYSimpTradConverter.h" #include "PYHalfFullConverter.h" @@ -48,10 +49,13 @@ LibPinyinBopomofoEditor::LibPinyinBopomofoEditor : LibPinyinPhoneticEditor (props, config), m_select_mode (FALSE) { + m_instance = LibPinyinBackEnd::instance ().allocChewingInstance (); } LibPinyinBopomofoEditor::~LibPinyinBopomofoEditor (void) { + LibPinyinBackEnd::instance ().freeChewingInstance (m_instance); + m_instance = NULL; } void diff --git a/src/PYPDoublePinyinEditor.cc b/src/PYPDoublePinyinEditor.cc index d37a480..8db80a4 100644 --- a/src/PYPDoublePinyinEditor.cc +++ b/src/PYPDoublePinyinEditor.cc @@ -21,6 +21,7 @@ #include "PYPDoublePinyinEditor.h" #include "PYConfig.h" +#include "PYLibPinyin.h" #define DEFINE_DOUBLE_PINYIN_TABLES #include "PYDoublePinyinTable.h" @@ -48,6 +49,13 @@ LibPinyinDoublePinyinEditor::LibPinyinDoublePinyinEditor ( PinyinProperties & props, Config & config) : LibPinyinPinyinEditor (props, config) { + m_instance = LibPinyinBackEnd::instance ().allocPinyinInstance (); +} + +LibPinyinDoublePinyinEditor::~LibPinyinDoublePinyinEditor (void) +{ + LibPinyinBackEnd::instance ().freePinyinInstance (m_instance); + m_instance = NULL; } gboolean diff --git a/src/PYPDoublePinyinEditor.h b/src/PYPDoublePinyinEditor.h index b06e144..0989a24 100644 --- a/src/PYPDoublePinyinEditor.h +++ b/src/PYPDoublePinyinEditor.h @@ -29,6 +29,7 @@ class LibPinyinDoublePinyinEditor : public LibPinyinPinyinEditor { public: LibPinyinDoublePinyinEditor (PinyinProperties & props, Config & config); + ~LibPinyinDoublePinyinEditor (void); gboolean insert (gint ch); diff --git a/src/PYPFullPinyinEditor.cc b/src/PYPFullPinyinEditor.cc index 064ae40..f07204b 100644 --- a/src/PYPFullPinyinEditor.cc +++ b/src/PYPFullPinyinEditor.cc @@ -21,6 +21,7 @@ #include "PYPFullPinyinEditor.h" #include "PYConfig.h" +#include "PYLibPinyin.h" using namespace PY; @@ -28,10 +29,13 @@ LibPinyinFullPinyinEditor::LibPinyinFullPinyinEditor (PinyinProperties & props, Config & config) : LibPinyinPinyinEditor (props, config) { + m_instance = LibPinyinBackEnd::instance ().allocPinyinInstance (); } LibPinyinFullPinyinEditor::~LibPinyinFullPinyinEditor (void) { + LibPinyinBackEnd::instance ().freePinyinInstance (m_instance); + m_instance = NULL; } void diff --git a/src/PYPPinyinEditor.h b/src/PYPPinyinEditor.h index 87fe210..3c61918 100644 --- a/src/PYPPinyinEditor.h +++ b/src/PYPPinyinEditor.h @@ -29,8 +29,6 @@ namespace PY { class Config; -class SpecialPhraseTable; - class LibPinyinPinyinEditor : public LibPinyinPhoneticEditor { public: LibPinyinPinyinEditor (PinyinProperties & props, Config & config); -- 2.7.4