diff --git a/ide/editoroptions.pp b/ide/editoroptions.pp index 44a53b8637..37e7e0ff81 100644 --- a/ide/editoroptions.pp +++ b/ide/editoroptions.pp @@ -5421,10 +5421,12 @@ begin XMLConfig.GetValue('EditorOptions/Display/DoNotWarnForFont', ''); // Key Mappings options + LoadCustomKeySchemas; fKeyMappingScheme := XMLConfig.GetValue('EditorOptions/KeyMapping/Scheme', KeyMapSchemeNames[kmsLazarus]); - fKeyMap.LoadFromXMLConfig(XMLConfig - , 'EditorOptions/KeyMapping/' + fKeyMappingScheme + '/'); + if not fKeyMap.LoadFromXMLConfig(XMLConfig + , 'EditorOptions/KeyMapping/' + fKeyMappingScheme + '/') then + fKeyMappingScheme := KeyMapSchemeNames[kmsLazarus]; // Color options for i := IdeHighlighterStartId to HighlighterList.Count - 1 do diff --git a/ide/keymapping.pp b/ide/keymapping.pp index ffbeed97c8..a6e9bbfb29 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -79,6 +79,8 @@ const ecIdePSyncroOutOffset = ecSynPSyncroEdNextCell - ecIdePSyncroEdOutNextCell; ecIdePSyncroSelOffset = ecSynPSyncroEdStart - ecIdePSyncroEdSelStart; + KeyMappingSchemeConfigDirName = 'userkeyschemes'; + type //--------------------------------------------------------------------------- // TKeyCommandCategory is used to divide the key commands in handy packets @@ -3597,8 +3599,11 @@ begin FileVersion:=XMLConfig.GetValue(Path+'Version/Value',0); ExtToolCount:=XMLConfig.GetValue(Path+'ExternalToolCount/Value',0); + Result:=false; + if FileVersion>5 then begin Cnt:=XMLConfig.GetValue(Path+'Count',0); + Result:=Cnt>0; // load all keys from the config, this may be more than the current relations // for example because the command is not yet registered. for a:=1 to Cnt do begin @@ -3659,6 +3664,7 @@ begin Relations[a].ShortcutA:=Relations[a].DefaultShortcutA; Relations[a].ShortcutB:=Relations[a].DefaultShortcutB; end else begin + Result:=true; p:=1; Key1:=word(ReadNextInt); Shift1:=FixShift(IntToShiftState(ReadNextInt)); @@ -3684,7 +3690,6 @@ begin end; end; end; - Result:=true; end; function TKeyCommandRelationList.SaveToXMLConfig( @@ -4394,7 +4399,7 @@ begin if not Assigned(dst) then Exit; fn := FindAllFiles( - IncludeTrailingPathDelimiter(dir)+'keyschema', '*.xml', false); + IncludeTrailingPathDelimiter(dir)+KeyMappingSchemeConfigDirName, '*.xml', false); if not Assigned(fn) then Exit; try @@ -4447,6 +4452,7 @@ end; initialization RegisterKeyCmdIdentProcs(@IdentToIDECommand, @IDECommandToIdent); + // CustomKeySchemas should be freed in TMainIDE.Destroy destructor CustomKeySchemas := TStringList.Create; CustomKeySchemas.OwnsObjects := true; @@ -4457,8 +4463,5 @@ initialization RegisterMouseCmdNameAndOptProcs(@EditorMouseCommandToDescriptionString, @EditorMouseCommandToConfigString); -finalization - CustomKeySchemas.Free; - end. diff --git a/ide/main.pp b/ide/main.pp index 625fe0dd2d..80b917c1a9 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -1791,6 +1791,7 @@ begin FreeThenNil(MiscellaneousOptions); FreeThenNil(EditorOpts); IDECommandList := nil; + FreeThenNil(CustomKeySchemas); FreeThenNil(IDECommandScopes); // free control selection FreeThenNil(TheControlSelection);