@@ -983,12 +983,13 @@ def check_user_config_file(self):
983983 with open (self .user_config_file , 'w' ) as h :
984984 json .dump (data , h , indent = 4 )
985985
986- def update_engine_to_config_file (self , eng_path_file , pname , user_opt ):
986+ def update_engine_to_config_file (self , eng_path_file , new_name , old_name , user_opt ):
987987 """
988988 Update engine config file based on params.
989989
990990 :param eng_path_file: full path of engine
991- :param pname: engine id name
991+ :param new_name: new engine id name
992+ :param new_name: old engine id name
992993 :param user_opt: a list of dict, i.e d = ['a':a, 'b':b, ...]
993994 :return:
994995 """
@@ -1007,8 +1008,8 @@ def update_engine_to_config_file(self, eng_path_file, pname, user_opt):
10071008 command = p ['command' ]
10081009 work_dir = p ['workingDirectory' ]
10091010
1010- if file == command and folder == work_dir :
1011- p ['name' ] = pname
1011+ if file == command and folder == work_dir and old_name == p [ 'name' ] :
1012+ p ['name' ] = new_name
10121013 for k , v in p .items ():
10131014 if k == 'options' :
10141015 for d in v :
@@ -1023,6 +1024,7 @@ def update_engine_to_config_file(self, eng_path_file, pname, user_opt):
10231024 if k1 == opt_name :
10241025 if v1 != opt_value :
10251026 d ['value' ] = v1
1027+ break
10261028
10271029 # Save data to pecg_engines.json
10281030 with open (self .engine_config_file , 'w' ) as h :
@@ -2984,7 +2986,7 @@ def main_loop(self):
29842986 button_title += '/' + e
29852987
29862988 try :
2987- engine_id_name = v ['engine_id_name_k' ][0 ]
2989+ orig_idname = engine_id_name = v ['engine_id_name_k' ][0 ]
29882990 except Exception :
29892991 sg .Popup ('Please select an engine to modify.' ,
29902992 title = '/Edit/Modify' ,
@@ -3144,8 +3146,9 @@ def main_loop(self):
31443146
31453147 # Save the new configured engine to pecg_engines.json file
31463148 if not is_cancel_edit_win and not is_cancel_modify_win :
3147- self .update_engine_to_config_file (engine_path_file ,
3148- engine_id_name , ret_opt_name )
3149+ self .update_engine_to_config_file (
3150+ engine_path_file , engine_id_name ,
3151+ orig_idname , ret_opt_name )
31493152 self .engine_id_name_list = self .get_engine_id_name_list ()
31503153
31513154 edit_win .Close ()
0 commit comments