View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0028059 | Lazarus | IDE | public | 2015-05-09 10:49 | 2016-04-27 11:07 |
Reporter | Mario Ray Mahardhika | Assigned To | Ondrej Pokorny | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | x86_64 | OS | linux | OS Version | Rolling release |
Product Version | 1.5 (SVN) | Product Build | 48971 | ||
Target Version | 1.6 | Fixed in Version | 1.7 (SVN) | ||
Summary | 0028059: Options changed through "Change Build Mode" CoolBar button isn't respected by the compiler | ||||
Description | I want to switch target processor from default (x86_64) to i386 from button above. However, the messages window still shows "FPC for x86_64". Only when I change it from Project->Project Options then the compiler will respect the change (despite the change is recognized by Project->Project Options). | ||||
Steps To Reproduce | 0. Start with an empty project 1. Compile, check messages window for "FPC for ..." 2. Press "Change Build Mode" CoolBar button 3. Change some option from default, e.g. target processor other than the default / your host (... in step 1) 4. Compile again, check messages window for "FPC for ..." Expected: ... in "FPC for ..." in step 1 <> the one in step 4 Actual: ... in "FPC for ..." in step 1 = the one in step 4 | ||||
Tags | No tags attached. | ||||
Fixed in Revision | (51068),51229 | ||||
LazTarget | 1.6 | ||||
Widgetset | |||||
Attached Files |
|
related to | 0029292 | closed | Juha Manninen | IDE crashes when you click button "Change Build Mode" and then click "Cancel" in the Dialog. |
|
It works in 1.4, doesn't it? |
|
I don't know, I cannot even make 1.4 working right. |
|
>> It works in 1.4, doesn't it? At least in 1.4.2: There is no such a button. The IDECoolBar seems not to be user-changeable (?). @Juha: the issue hasn't anything to do with my changes. I tried to fix it but I am not sure if I did it correctly. I ask for review of the supplied patch. Especially what code has to be moved from TMainIDE.DoProjectOptionsAfterWrite to TMainIDE.DoCompilerOptionsAfterWrite. |
|
compileroptions-afterwrite-1.patch (6,772 bytes)
Index: ide/main.pp =================================================================== --- ide/main.pp (revision 51054) +++ ide/main.pp (working copy) @@ -434,6 +434,7 @@ procedure DoCodeExplorerOptionsAfterWrite(Sender: TObject; Restore: boolean); procedure DoProjectOptionsBeforeRead(Sender: TObject); procedure DoProjectOptionsAfterWrite(Sender: TObject; Restore: boolean); + procedure DoCompilerOptionsAfterWrite(Sender: TObject; Restore: boolean); procedure OnCompilerOptionsDialogTest(Sender: TObject); function DoTestCompilerSettings(TheCompilerOptions: TCompilerOptions): TModalResult; function OnCheckCompOptsAndMainSrcForNewUnit(CompOpts: TLazCompilerOptions): TModalResult; @@ -4823,7 +4824,6 @@ procedure TMainIDE.DoProjectOptionsAfterWrite(Sender: TObject; Restore: boolean); var AProject: TProject; - aFilename: String; function GetTitle: String; begin @@ -4922,36 +4922,11 @@ mtWarning, [mbOk]); end; UpdateCaption; - AProject.DefineTemplates.AllChanged; end; if Restore then begin - AProject.RestoreBuildModes; AProject.RestoreSession; end; - - IncreaseCompilerParseStamp; - MainBuildBoss.SetBuildTargetProject1(false); - - if not Restore then - begin - if AProject.UseAsDefault then - begin - // save as default - aFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename; - AProject.WriteProject([pwfSkipSeparateSessionInfo,pwfIgnoreModified], - aFilename,EnvironmentOptions.BuildMatrixOptions); - end; - - Project1.UpdateAllSyntaxHighlighter; - SourceEditorManager.BeginGlobalUpdate; - try - UpdateHighlighters(True); - SourceEditorManager.ReloadEditorOptions; - finally - SourceEditorManager.EndGlobalUpdate; - end; - end; end; procedure TMainIDE.ComponentPaletteClassSelected(Sender: TObject); @@ -6075,6 +6050,7 @@ Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile; Result.IDEOptions.OnBeforeRead:=@DoProjectOptionsBeforeRead; Result.IDEOptions.OnAfterWrite:=@DoProjectOptionsAfterWrite; + Result.OnCompilerOptionsAfterWrite := @DoCompilerOptionsAfterWrite; end; function TMainIDE.DoNewProject(ProjectDesc: TProjectDescriptor): TModalResult; @@ -6785,6 +6761,47 @@ DoBuildProject(crCompile, []); end; +procedure TMainIDE.DoCompilerOptionsAfterWrite(Sender: TObject; Restore: boolean + ); +var + AProject: TProject; + aFilename: string; +begin + AProject:=(Sender as TProjectCompilerOptions).Project; + + if not Restore then + begin + AProject.DefineTemplates.AllChanged; + end; + if Restore then + begin + AProject.RestoreBuildModes; + end; + + IncreaseCompilerParseStamp; + MainBuildBoss.SetBuildTargetProject1(false); + + if not Restore then + begin + if AProject.UseAsDefault then + begin + // save as default + aFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename; + AProject.WriteProject([pwfSkipSeparateSessionInfo,pwfIgnoreModified], + aFilename,EnvironmentOptions.BuildMatrixOptions); + end; + + Project1.UpdateAllSyntaxHighlighter; + SourceEditorManager.BeginGlobalUpdate; + try + UpdateHighlighters(True); + SourceEditorManager.ReloadEditorOptions; + finally + SourceEditorManager.EndGlobalUpdate; + end; + end; +end; + procedure TMainIDE.DoQuickCompile; begin DoBuildProject(crCompile,[pbfSkipLinking,pbfSkipTools,pbfSkipAssembler]); Index: ide/project.pp =================================================================== --- ide/project.pp (revision 51054) +++ ide/project.pp (working copy) @@ -550,6 +550,7 @@ property BuildMode: TProjectBuildMode read FBuildMode; published property CompileReasons: TCompileReasons read FCompileReasons write FCompileReasons; + property Project: TProject read FProject; end; { TProjectDefineTemplates } @@ -615,6 +616,7 @@ function GetItems(Index: integer): TProjectBuildMode; function GetModified: boolean; procedure OnItemChanged(Sender: TObject); + procedure CompilerOptionsAfterWrite(Sender: TObject; Restore: boolean); procedure SetModified(const AValue: boolean); // Used by LoadFromXMLConfig procedure AddMatrixMacro(const MacroName, MacroValue, ModeIdentifier: string; InSession: boolean); @@ -736,6 +738,7 @@ FOnLoadProjectInfo: TOnLoadProjectInfo; FOnSaveProjectInfo: TOnSaveProjectInfo; FOnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo; + FOnCompilerOptionsAfterWrite: TIDEOptionsWriteEvent; fPathDelimChanged: boolean; // PathDelim in system and current config differ (see StorePathDelim and SessionStorePathDelim) FPOOutputDirectory: string; fProjectDirectory: string; @@ -833,6 +836,7 @@ procedure SaveToLPI; procedure SaveToSession; function DoWrite(Filename: String; IsLpi: Boolean): TModalResult; + procedure CompilerOptionsAfterWrite(Sender: TObject; Restore: boolean); protected function GetActiveBuildModeID: string; override; function GetDefineTemplates: TProjPackDefineTemplates; @@ -1079,6 +1083,8 @@ write FOnSaveProjectInfo; property OnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo read FOnSaveUnitSessionInfo write FOnSaveUnitSessionInfo; + property OnCompilerOptionsAfterWrite: TIDEOptionsWriteEvent + read FOnCompilerOptionsAfterWrite write FOnCompilerOptionsAfterWrite; property POOutputDirectory: string read FPOOutputDirectory write SetPOOutputDirectory; property ProjectDirectory: string read fProjectDirectory; property ProjectInfoFile: string read GetProjectInfoFile write SetProjectInfoFile; @@ -4725,6 +4731,12 @@ Units[i].ClearUnitComponentDependencies(ClearTypes); end; +procedure TProject.CompilerOptionsAfterWrite(Sender: TObject; Restore: boolean); +begin + if Assigned(FOnCompilerOptionsAfterWrite) then + FOnCompilerOptionsAfterWrite(Sender, Restore); +end; + procedure TProject.FindUnitsUsingSubComponent(SubComponent: TComponent; List: TFPList; IgnoreOwner: boolean); @@ -6750,6 +6762,12 @@ SessionMatrixOptions.Clear; end; +procedure TProjectBuildModes.CompilerOptionsAfterWrite(Sender: TObject; + Restore: boolean); +begin + LazProject.CompilerOptionsAfterWrite(Sender, Restore); +end; + function TProjectBuildModes.IsEqual(OtherModes: TProjectBuildModes): boolean; var i: Integer; @@ -6833,6 +6851,7 @@ if LazProject<>nil then Result.CompilerOptions.BaseDirectory:=LazProject.ProjectDirectory; Result.AddOnChangedHandler(@OnItemChanged); + Result.CompilerOptions.OnAfterWrite:=@CompilerOptionsAfterWrite; fItems.Add(Result); end; |
|
Fixed by applying the patch. It looks good. Please test and close if OK. |
|
The patch caused crashes. The related issue was only one problem. When you open project options (Ctrl-Shift-F11) and click Cancel, you get an access violation. When calling the AfterWrite methods, some IDEOptions are already freed. It can be seen in TAbstractIDEOptions.DoAfterWrite when -gt and other debug flags are set. Must be either reverted or fixed in a better way. Difference between DoProjectOptionsAfterWrite and DoCompilerOptionsAfterWrite looks fuzzy. I don't understand that code very well. |
|
>> When you open project options (Ctrl-Shift-F11) and click Cancel, you get an access violation. Not for me. Do you have more information? |
|
I can reproduce this every time now. However I know such problems do not show up always and/or in all computers, even if -gt is used for building Lazarus. I bisected for the guilty revision and could reproduce systematically also during the process. Trying again and I could no more reproduce with a simple Cancel in project options. This still does it though: - Open the BuildModes manager window from project options - Create Debug and Release modes, click OK. - In project options window click Cancel. procedure TMainIDE.DoCompilerOptionsAfterWrite(Sender: TObject; Restore: boolean); was called called from TAbstractIDEOptions.DoAfterWrite once and BuildModes were restored, but in next iteration the IDEOptions object was freed and contained f0f0f0f0f0f0f0f0 thanks to -gt. [Edit] Now I can reproduce again with just Cancel (?) procedure TIDEOptionsDialog.WriteAll gets an TAbstractIDEOptions instance like this: Instance := Rec^.GroupClass.GetInstance; where Rec is an item in IDEEditorGroups. I don't know (yet) where the objects are freed. I suggest we revert r51068 and study the code in peace. The original bug does not block up 1.6 release but a crash bug does. Below is a backtrace. I will attach a screenshot, too. --- Program received signal SIGSEGV, Segmentation fault. 0x000000000058436f in COUNT (this=0xf0f0f0f0f0f0f0f0) at lazmethodlist.pas:111 111 Result:=FCount (gdb) bt #0 0x000000000058436f in COUNT (this=0xf0f0f0f0f0f0f0f0) at lazmethodlist.pas:111 0000001 0x000000000049e8e3 in DOAFTERWRITE (this=0x7fffed995710, RESTORE=true) at ideoptionsintf.pas:972 0000002 0x0000000000c80fee in WRITEALL (this=0x7fffe649fdd0, RESTORE=true) at ideoptionsdlg.pas:435 0000003 0x00000000004babf9 in DOOPENIDEOPTIONS (this=0x7fffefb0daf0, AEDITOR=0x0, ACAPTION=0x7fffe5ad9ad8 'Options for Project: Lazarus', AOPTIONSFILTER=..., highAOPTIONSFILTER=1, ASETTINGS=...) at main.pp:4636 0000004 0x00000000004b76fa in PROJECTOPTIONSHELPER (this=0x7fffefb0daf0, AFILTER=..., highAFILTER=1) at main.pp:4043 0000005 0x00000000004b786e in MNUPROJECTOPTIONSCLICKED (this=0x7fffefb0daf0, SENDER=0x7fffee9b32c0) at main.pp:4053 0000006 0x00000000009a0c2b in EXECUTE (this=0x7fffee9b32c0, SENDER=0x7fffee9b32c0) at idecommands.pas:1491 0000007 0x00000000004b3073 in HANDLEPROCESSIDECOMMAND (this=0x7fffefb0daf0, SENDER=0x7fffe7ac8b10, COMMAND=1514, HANDLED=false) at main.pp:3324 0000008 0x0000000000b70b3c in PROCESSPARENTCOMMAND (this=0x7fffe7ac8b10, SENDER=0x7fffe79453a0, COMMAND=1514, ACHAR=..., DATA=0x0, HANDLED=false) at sourceeditor.pp:8527 0000009 0x0000000000b58f6a in PROCESSUSERCOMMAND (this=0x7fffe79453a0, SENDER=0x7fffe7d793d0, COMMAND=1514, ACHAR=..., DATA=0x0) at sourceeditor.pp:4016 0000010 0x0000000000ed5c7c in DOONPROCESSCOMMAND (this=0x7fffe7d793d0, COMMAND=1514, ACHAR=..., DATA=0x0) at synedit.pp:6996 0000011 0x0000000000ed2198 in COMMANDPROCESSOR (this=0x7fffe7d793d0, COMMAND=1514, ACHAR=..., DATA=0x0, ASKIPHOOKS=...) at synedit.pp:6365 0000012 0x0000000000ec0ce1 in KEYDOWN (this=0x7fffe7d793d0, KEY=0, SHIFT=...) at synedit.pp:2862 0000013 0x00000000006b9d63 in KEYDOWNBEFOREINTERFACE (this=0x7fffe7d793d0, KEY=0, SHIFT=...) at include/wincontrol.inc:5653 0000014 0x00000000006ba12e in DOKEYDOWNBEFOREINTERFACE (this=0x7fffe7d793d0, MESSAGE=..., ISRECURSECALL=false) at include/wincontrol.inc:5784 0000015 0x00000000006be2b6 in CNKEYDOWN (this=0x7fffe7d793d0, MESSAGE=...) at include/wincontrol.inc:7122 0000016 0x000000000043275f in SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal () --- |
|
>> I suggest we revert r51068 and study the code in peace. The original bug does not block up 1.6 release but a crash bug does. I agree. + I am for removing this action. For 1.6 "Project Options" could be shown when "change build mode" is clicked. + For 1.8 we can remove the action completely and keep only single DropButton with tbsButtonDrop: http://wiki.lazarus.freepascal.org/index.php?title=Lazarus_1.8.0_release_notes Why should we lose time with such doubled functionality? |
|
IdeOptionsFreed.png (322,637 bytes) |
|
> + For 1.8 we can remove the action completely and keep only single DropButton with tbsButtonDrop Yes but the bug must be solved before that. The problem happened exactly when selecting BuildMode from a DropButton. |
|
> Yes but the bug must be solved before that. The problem happened exactly when selecting BuildMode from a DropButton. Does the bug also occur when changing build mode from the drop-down menu? I thought the bug occurred if the options have been changed from the "Change build mode" dialog. |
|
Ok, maybe I misunderstood. I don't have cross-compilation configured and didn't test it. Must study the issue better later. Now I plan to revert your commit + partly my changes for the related issue. [Edit] Done in r51166. |
|
>> Does the bug also occur when changing build mode from the drop-down menu? >Ok, maybe I misunderstood. I don't have cross-compilation configured and didn't test it. Yes, Juha. The drop-down menu works well. Changing options from the dialog doesn't work. |
|
So what to do now? The button is very similar to "Project options" and the dialog doesn't work. IMO we have these possibilities: 1.) Remove the button completely, add the drop-down-menu to "Project options" and set default IDECoolbar configuration accordingly. Add the same drop-down-menu to "Project options" button in Project Inspector as well. 2.) Make it only show the drop-down-menu, no dialog. 3.) Make the dialog work. I vote for (1). |
|
Yet another attempt to make the dialog work. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-05-09 10:49 | Mario Ray Mahardhika | New Issue | |
2015-05-09 14:49 | Juha Manninen | Note Added: 0083534 | |
2015-05-09 15:51 | Mario Ray Mahardhika | Note Added: 0083535 | |
2015-12-17 17:43 | Juha Manninen | Assigned To | => Ondrej Pokorny |
2015-12-17 17:43 | Juha Manninen | Status | new => assigned |
2015-12-27 20:07 | Ondrej Pokorny | Note Added: 0088329 | |
2015-12-27 20:07 | Ondrej Pokorny | File Added: compileroptions-afterwrite-1.patch | |
2015-12-27 21:09 | Ondrej Pokorny | LazTarget | => - |
2015-12-27 21:09 | Ondrej Pokorny | Target Version | => 1.6 |
2015-12-28 20:31 | Ondrej Pokorny | Fixed in Revision | => 51068 |
2015-12-28 20:31 | Ondrej Pokorny | LazTarget | - => 1.6 |
2015-12-28 20:31 | Ondrej Pokorny | Note Added: 0088360 | |
2015-12-28 20:31 | Ondrej Pokorny | Status | assigned => resolved |
2015-12-28 20:31 | Ondrej Pokorny | Fixed in Version | => 1.7 (SVN) |
2015-12-28 20:31 | Ondrej Pokorny | Resolution | open => fixed |
2016-01-03 00:49 | Juha Manninen | Relationship added | related to 0029292 |
2016-01-03 01:00 | Juha Manninen | Note Added: 0088536 | |
2016-01-03 01:00 | Juha Manninen | Status | resolved => assigned |
2016-01-03 01:00 | Juha Manninen | Resolution | fixed => reopened |
2016-01-03 01:20 | Ondrej Pokorny | Note Added: 0088537 | |
2016-01-03 15:42 | Juha Manninen | Note Added: 0088545 | |
2016-01-03 15:49 | Juha Manninen | Note Edited: 0088545 | View Revisions |
2016-01-03 15:52 | Ondrej Pokorny | Note Added: 0088547 | |
2016-01-03 15:57 | Juha Manninen | Note Edited: 0088545 | View Revisions |
2016-01-03 16:17 | Juha Manninen | Note Edited: 0088545 | View Revisions |
2016-01-03 16:22 | Juha Manninen | File Added: IdeOptionsFreed.png | |
2016-01-03 16:28 | Juha Manninen | File Deleted: IdeOptionsFreed.png | |
2016-01-03 16:28 | Juha Manninen | File Added: IdeOptionsFreed.png | |
2016-01-03 16:49 | Juha Manninen | Note Added: 0088557 | |
2016-01-03 16:57 | Ondrej Pokorny | Note Added: 0088558 | |
2016-01-03 17:09 | Juha Manninen | Note Added: 0088559 | |
2016-01-03 17:48 | Juha Manninen | Note Edited: 0088559 | View Revisions |
2016-01-03 22:02 | Ondrej Pokorny | Note Added: 0088571 | |
2016-01-03 22:10 | Ondrej Pokorny | Note Added: 0088572 | |
2016-01-03 22:10 | Ondrej Pokorny | Note Edited: 0088571 | View Revisions |
2016-01-03 22:11 | Ondrej Pokorny | Note Edited: 0088572 | View Revisions |
2016-01-08 13:37 | Ondrej Pokorny | Fixed in Revision | 51068 => (51068),51229 |
2016-01-08 13:37 | Ondrej Pokorny | Status | assigned => resolved |
2016-01-08 13:37 | Ondrej Pokorny | Resolution | reopened => fixed |
2016-01-08 13:37 | Ondrej Pokorny | Note Added: 0088731 | |
2016-04-27 11:07 | Mario Ray Mahardhika | Status | resolved => closed |