This repository has been archived by the owner. It is now read-only.

fix unexpected clear key bindings when load_config() #9

Merged
merged 1 commit into from May 16, 2015

Conversation

Projects
None yet
3 participants
@m-shibata
Contributor

m-shibata commented May 13, 2015

The destructor of Action class frees the memory of
(FcitxHotkey*)m_key_bindings by calling FcitxHotkeyFree().

m_key_bindings is same as the member of AnthyKeyProfile which is
AnthyInstance::m_config.m_key_default.

The members of m_key_defualt is allocated by FcitxConfigBindSync() in
AnthyInstance::load_config(), and it is passed to Action instance by
APPEND_ACTION() macro in AnthyInstance::configure().

However configure() is call AnthyInstance::m_actions.clear() before
APPEND_ACTION(). This is call destructor of Action class, then
m_key_bindings is freed by FcitxHotkeyFree(). The result of this, the
value of desc members of AnthyInstance::m_config.m_key_default is set to
NULL.

Because next AnthyInstance::save_coanfig() will treat all Hotkey of Key
group Null string, key bindings in fcitx-anthy.conf are cleared.

This commit prevent unexpexted call FcitxHotkeyFree() for
m_key_bindings. Instance of m_key_bindings is freed inside of
FcitxHotkeySet() routine, not needed to explicit free().


How to reproduce:

  • Type A:
    1. enable fcitx-anthy
    2. save ~/.conf/fcitx/conf/fcitx-anthy.conf
    3. type "Ctrl-,", it's circler input mode
    4. check .conf/fcitx/conf/fcitx-anthy.conf
    5. compare conf files 2 and 4
  • Type B:
    1. enable fcitx-anthy
    2. save ~/.conf/fcitx/conf/fcitx-anthy.conf
    3. configure KeyBindingProfile to Custom and LatinModeKey to MUHENKAN
    4. type "MUHENKAN" to change to Latin Mode from Kana Mode
    5. check .conf/fcitx/conf/fcitx-anthy.conf
    6. compare conf files 2 and 5
fix unexpected clear key bindings when load_config()
The destructor of Action class frees the memory of
(FcitxHotkey*)m_key_bindings by calling FcitxHotkeyFree().

m_key_bindings is same as the member of AnthyKeyProfile which is
AnthyInstance::m_config.m_key_default.

The members of m_key_defualt is allocated by FcitxConfigBindSync() in
AnthyInstance::load_config(), and it is passed to Action instance by
APPEND_ACTION() macro in AnthyInstance::configure().

However configure() is call AnthyInstance::m_actions.clear() before
APPEND_ACTION(). This is call destructor of Action class, then
m_key_bindings is freed by FcitxHotkeyFree(). The result of this, the
value of desc members of AnthyInstance::m_config.m_key_default is set to
NULL.

Because next AnthyInstance::save_coanfig() will treat all Hotkey of Key
group Null string, key bindings in fcitx-anthy.conf are cleared.

This commit prevent unexpexted call FcitxHotkeyFree() for
m_key_bindings. Instance of m_key_bindings is freed inside of
FcitxHotkeySet() routine, not needed to explicit free().
@ikunya

This comment has been minimized.

Show comment
Hide comment
@ikunya

ikunya May 15, 2015

Contributor

Please merge this PR.
This issue is so annoying and affects many users including me.

Contributor

ikunya commented May 15, 2015

Please merge this PR.
This issue is so annoying and affects many users including me.

wengxt added a commit that referenced this pull request May 16, 2015

Merge pull request #9 from m-shibata/fixClearKeyBindings
fix unexpected clear key bindings when load_config()

@wengxt wengxt merged commit fb6ce38 into fcitx:master May 16, 2015

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.