chewing / chewing-editor

Cross platform chewing user phrase editor
https://chewing.im/
GNU General Public License v2.0
31 stars 52 forks source link

[Bug] Import feature doesn't work. #187

Closed PeterDaveHello closed 8 years ago

PeterDaveHello commented 8 years ago

Tested on a clean Ubuntu 16.04 LTS amd64 and Linuxmint Cinnamon 17.3 amd64 which is based on Ubuntu 14.04 LTS.

The export feature works well, but the import feature doesn't work here, it will open a window to let me choose the file to be imported, but after that, nothing happened, that's old, I'm not sure if it's a bug or it's my problem, I try to use a clean Ubuntu to reproduce this problem and it just happened.

czchen commented 8 years ago

You can use chewing-editor -d to enable debug mode to see if there is any error message.

PeterDaveHello commented 8 years ago

@czchen Thanks, I will.

PeterDaveHello commented 8 years ago

Here are some logs, I'm still tracing.

First time to click "File / Import" :

Debug: import_count =  0  (void ChewingEditor::selectImportFile() ChewingEditor.cpp:112)
Debug: dialogType_ =  11  (void ChewingEditor::execFileDialog(ChewingEditor::DialogType) ChewingEditor.cpp:80)

Second time (and after the second time) to click "File / Import" :

Debug: import_count =  0  (void ChewingEditor::selectImportFile() ChewingEditor.cpp:112)
Debug: dialogType_ =  0  (void ChewingEditor::execFileDialog(ChewingEditor::DialogType) ChewingEditor.cpp:80)

Double click to open a file:

Debug: dialogType_ =  0  (void ChewingEditor::finishFileSelection(const QString&) ChewingEditor.cpp:123)
Debug: import_count =  1  (void ChewingEditor::finishFileSelection(const QString&) ChewingEditor.cpp:131)

Click a file and then click open button:

Debug: dialogType_ =  0  (void ChewingEditor::finishFileSelection(const QString&) ChewingEditor.cpp:123)
Debug: import_count =  1  (void ChewingEditor::finishFileSelection(const QString&) ChewingEditor.cpp:131)

import_count = 1, but still didn't get any result in the screen.

PeterDaveHello commented 8 years ago

cc @robert501128 @hwhung0111

PeterDaveHello commented 8 years ago

Just note that even there are 4 phrases in total, the debug message of export still shows 1:

Debug: import_count =  0  (void ChewingEditor::selectImportFile() ChewingEditor.cpp:112)
Debug: dialogType_ =  0  (void ChewingEditor::execFileDialog(ChewingEditor::DialogType) ChewingEditor.cpp:80)
Debug: dialogType_ =  0  (void ChewingEditor::finishFileSelection(const QString&) ChewingEditor.cpp:123)
Debug: import_count =  1  (void ChewingEditor::finishFileSelection(const QString&) ChewingEditor.cpp:131)
PeterDaveHello commented 8 years ago

The bug came from #187, revert cc5cd9643583a763592ec5e6993782573c491bae for #49 actually fix this problem.

PeterDaveHello commented 8 years ago

@robert501128 @hwhung0111 would you please confirm that?

david50407 commented 8 years ago

Which version do you use? From apt or build by yourself (from which commit)? Could you provide more information about the environment? And the import json file, please :smile:

jserv commented 8 years ago

Cc. @cyng93

PeterDaveHello commented 8 years ago

@david50407 build from https://github.com/chewing/chewing-editor/commit/50c105e5ef002eb85fa5e2b0ff144f612ab4ca4b, on Ubuntu 14.04.4 LTS with qt 5.2.1, the json file:

{
    "userphrase": [
        {
            "bopomofo": "ㄎㄠˇ",
            "phrase": "考"
        },
        {
            "bopomofo": "ㄧ ㄕˋ ㄓ ㄒㄩㄥˊ",
            "phrase": "一世之雄"
        }
    ]
}
david50407 commented 8 years ago

That seems you only trigger the dialog once.

BTW, #126 is trying to solve the problem in #49 that importing will trigger twice event, And #126 says that Second trigger should be ignored but it skipped the first trigger in https://github.com/chewing/chewing-editor/commit/cc5cd9643583a763592ec5e6993782573c491bae#diff-fe73a7ae7fac4644eebd943eeb1959c4R127 I'm going to fix this (by skipping the second trigger correctly), any other thoughts?

PeterDaveHello commented 8 years ago

I actually have a patch for this problem, will send it now, just want to confirm the issue first.

david50407 commented 8 years ago

Yes, I have the same problem on Ubuntu 14.04 /w Qt 5.4.2

PeterDaveHello commented 8 years ago

I just sent the patch to #193, would you guys please help review it?

hunghw commented 8 years ago

I had tried #193, and I think it fix the bug.

cyng93 commented 8 years ago

That seems you only trigger the dialog once.

BTW, #126 is trying to solve the problem in #49 that importing will trigger twice event, And #126 says that Second trigger should be ignored but it skipped the first trigger in cc5cd96#diff-fe73a7ae7fac4644eebd943eeb1959c4R127 I'm going to fix this (by skipping the second trigger correctly), any other thoughts?

It was my bad in #126 for messing up import_count++ with ++import_count, thanks @david50407 for pointing out that.