IDE launches wrong form lazarus / 9-Editor ---------------------------------------------------------------------- BobD · 2005-04-06 05:48 I'm using Lazarus under Linux. When I design a form and then compile the project a new blank form appears that is not the form I designed. Closing it doesn't help as a new blank one appears next time. How can I get the form I designed to be used by the app instead of a new blank form? Thanks, Bob ---------------------------------------------------------------------- Anonymous · 2005-04-06 13:39 I have the same problem since more than 10 days on windows. It seems that they (the lazarus developpers) use scince there another compiler version.... different units? Where can I get the current compiler for the cvs of Lazarus? If I am right: the compiler shipped with Lazarus contains additional libraries. So it isn't possible to use the "normal" FPC. Maybe that is all wrong.... just a suggestion. regards namrud ---------------------------------------------------------------------- Marc · 2005-04-06 15:39 the compiler is not the issue here, I still work with the 1.9.8 version Look under project -> project options   which form is auto created as first. That form will show ---------------------------------------------------------------------- Anonymous · 2005-04-07 00:05 Quote from: "Marc"the compiler is not the issue here, I still work with the 1.9.8 version Look under project -> project options   which form is auto created as first. That form will showNothing I did with Project Options seemed to help. The problem seems to be related to the name given to the main unit's file when I first save it. If I choose "main.pas" as the name, I have the trouble mentioned above. If I choose something else, it seems okay. Bob ---------------------------------------------------------------------- BobD · 2005-04-07 05:02 No, the Project Options doesn't fix it. The only option is to move Form1 (in this case) from the "Auto Create Forms" list to the "Available Forms" list (what ever that means).  Doing that has no effect on the problem. It makes no sense to me that the IDE can't tell which form is the one to use when there is only one. Bob ---------------------------------------------------------------------- Marc · 2005-04-07 09:39 if you look at the code of your project.lpr (view source), does it look like ? Code: [Select] uses   Interfaces, // this includes the LCL widgetset   Forms,   {add your units here }, unit1; begin   Application.Initialize;   Application.CreateForm(TForm1, Form1);   Application.Run; end. In this code read unit1 as the name of your unit and  TForm1/form1 as the name of your form is there somewhere on your disk another file unit1.pas or .pp with a different casing ? ---------------------------------------------------------------------- BobD · 2005-04-07 14:19 Quote from: "Marc"if you look at the code of your project.lpr (view source), does it look like ? Code: [Select] uses   Interfaces, // this includes the LCL widgetset   Forms,   {add your units here }, unit1; begin   Application.Initialize;   Application.CreateForm(TForm1, Form1);   Application.Run; end. In this code read unit1 as the name of your unit and  TForm1/form1 as the name of your form is there somewhere on your disk another file unit1.pas or .pp with a different casing ?No. When  I start a new project by placing a button on the form and then save it and then choose View --> Source Editor I see 2 sources:  One called Unit1 and the other called Unit1(2). They look like this: //labeled Unit1 unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs; type   TForm1 = class(TForm)   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation initialization   {$I unit1.lrs} end. //****************************************** //labeled Unit1(2) unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation initialization   {$I unit1.lrs} end. ---------------------------------------------------------------------- Marc · 2005-04-08 12:23 Ahh... now we are getting somewhere. The editor sees two different files called unit1. You are editing the second, while the compiler sees the first. Look in the bottom part of the source editor and compare the paths to both files. Is there any difference ? ---------------------------------------------------------------------- BobD · 2005-04-08 16:18 Quote from: "Marc"Ahh... now we are getting somewhere. The editor sees two different files called unit1. You are editing the second, while the compiler sees the first. Look in the bottom part of the source editor and compare the paths to both files. Is there any difference ? Yes, the 2 paths are different  The path for "Unit1" is just unit1.pas (no path) The path for Unit1(2) is  ~/lazarus/projects/unit1.pas Bob ---------------------------------------------------------------------- Marc · 2005-04-11 10:06 if you have unit1.pas focused an you click on save as, where is it saved ? And, is your project file saved in the same dir as ~/lazarus/projects/unit1.pas ? ---------------------------------------------------------------------- wes12 · 2005-04-12 12:28 The extra unit may be clouding the problem. I've not been able to start a new project since getting version 096. The compiler starts by complaining about a missing resource file in unit1 before I've even saved the unmodified project. After a lot of fiddling, the project eventually saves, but it compiles to a blank form, no matter what I've added. It isn't hiding the components because if I change the position of the form itself (poDesigned,etc) it still stays at top left. The only way I've managed to start a project is by copying an old project designed under a previous Laz version (094?), and changing that. I'm using Win2KPro and 98SE. ---------------------------------------------------------------------- Anonymous · 2005-04-12 18:16 Exact the same bug under WinXP Home with the latest CVS source. Scince more than 2 weeks I cannot work with Lazarus. I hope anyone will find the bug... ---------------------------------------------------------------------- Vincent Snijders · 2005-04-13 08:01 Hint: If you create a new project and compile it without saving, lazarus saves it in a temp dir: You can see/change that temp dir in Environment -> Environment Options -> Files tab -> Directory for building test projects. Maybe you can clean that directory or choose another directory. Also make sure no other unit1.pas or unit1.o is found by the compiler, for example by searching you lazarus tree for such files. The only unit1 in the lazarus tree is in \lazarus\examples\grid_semaphor\example, so all others have been made by you. ---------------------------------------------------------------------- wes12 · 2005-04-13 09:06 Vincent: Cracked it   When you start a new project, the IDE generates this statement in the unit1 initialisation section:   { $ I Unit1.Lrs} This is seen as a plain text comment, and highlighted blue in the default Lazarus settings. If you change this to:   {$I Unit1.Lrs} the highlight changes to red,as Lazarus recognises this as an include, and everything will run as normal. So I think the original problem was this, and not the extra unit1, and this error has only occurred since version 096. ---------------------------------------------------------------------- Vincent Snijders · 2005-04-13 13:21 Does this still occurs with the current CVS version (or the snapshot at http://www.ca.freepascal.org/Lazarus )? ---------------------------------------------------------------------- wes12 · 2005-04-13 14:03 Quote from: "Vincent"Does this still occurs with the current CVS version (or the snapshot at http://www.ca.freepascal.org/Lazarus)? I can't get the snapshot  (the address in the quote above has been corrected) - the download gives me a 114K exe file that says its been corrupted. I haven't got a CVS running yet. ---------------------------------------------------------------------- Vincent Snijders · 2005-04-13 15:04 Thanks for the notification. It is fixed now. ---------------------------------------------------------------------- Anonymous · 2005-04-13 17:45 Right now I downloaed and compiled the newest sources, but the same bug. After I modified "{ $I Unit1.Lrs }" to  "{$I Unit1.Lrs}" it worked. But I have still in a new project this directive "{ $I Unit1.Lrs }". Can you please fix it. I think it's just a smal fix. ---------------------------------------------------------------------- Vincent Snijders · 2005-04-13 18:42 It would be a small fix, if I could reproduce it. I downloaded the 20050403 installer for windows and installed. I created a new project and it had the lines: initialization   {$I unit1.lrs} So, can you give exact steps to reproduce this error? Then I can give it a try. ---------------------------------------------------------------------- BobD · 2005-04-13 22:17 When I start a new project I get: initialization   {$I unit1.lrs} So, I guess this bug does not affect my situation.  I'm using Laz 0.9.4 beta on Linux. Getting rid of duplicate unit1.pas files seems to correct the problem so far but it seems odd that I'd have to do that.  Does Laz remember all the dirs that it has saved projects in? Or, maybe just the last one? Bob ---------------------------------------------------------------------- wes12 · 2005-04-14 07:58 Quote from: "Vincent"It would be a small fix, if I could reproduce it. .. So, can you give exact steps to reproduce this error? Then I can give it a try. Vincent - The exact steps don't seem to produce the same result on your system.  I'm only clicking Project/New Project or File/New, and then choosing Application. But when I checked again, this problem doesn't seem to occur on Win98SE, only Win2KPro. Perhaps from Guest comments above it also occurs on XP? I'll try to find a cause for the bug on my W2K system. Quote from: "BobD"So, I guess this bug does not affect my situation. I'm using Laz 0.9.4 beta on Linux. Bob - At one point I reached a similar situation to yours when trying to save a project with this bug. I think that your problem is caused by something that Lazarus lets you do when it shouldn't, rather than a outright bug. ---------------------------------------------------------------------- Marc · 2005-04-14 08:38 In the early days it depended on how you configured your Codetools options - space this was fixed last year, maybe it got reintroduced ---------------------------------------------------------------------- wes12 · 2005-04-14 08:58 Marc - Thanks for the tip. Looks like the bug slipped back in! My system generates:   { $ I Unit1.Lrs} I checked my Codetools options/Space. In space before I only had number checked. When I unchecked it, I got:   {$ I Unit1.Lrs} which was better, but not correct. In space after, when I  unchecked number, I got:   {$I Unit1.Lrs} Bug indentified!! ---------------------------------------------------------------------- waituntilthis · 2019-09-30 06:56 Quote from: Marc on April 06, 2005, 05:39:35 pmthe compiler is not the issue here, I still work with the 1.9.8 version Look under project -> project options   which form is auto created as first. That form will show thanks marc! I was searching for this answer since i'm also new but I couldn't find anything about it, so you've been a great help!