Lazarus

Free Pascal => General => Topic started by: yurkad on March 17, 2017, 01:15:13 pm

Title: [SOLVED] Changes in one project influences another project
Post by: yurkad on March 17, 2017, 01:15:13 pm
Hello!

Windows XP, Lazarus 1.6.0

In some folder I have folders folder1 and folder2. Folder folder1 has laz1.lpi project and folder folder2 has laz2.lpi project.

  Folder
      folder1
          laz1.lpi
      folder2
          laz2.lpi

Both projects are very similar and contains almost equal names of units.

After I add some unit in Code edit window of laz1.lpi then close laz1.lpi and open laz2.lpi,  this unit will appear in code edit window of laz2.lpi too. Same with delete some unit from laz1.lpi or from laz2.lpi.

The real names of  laz1.lpi and  laz2.lpi are the same.

Can be avoided this?

Thanks  :D
Title: Re: Changes in one project influences another project
Post by: JuhaManninen on March 17, 2017, 02:32:16 pm
Your projects refer to each other somehow.
Maybe the other project's folder is in the search path of the other one and you edit a wrong file. See the file's location in editor statusbar.
You also could have inherited a form somehow from another form.

Check the unit search paths of both projects.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 02:42:10 pm
Each project has reference to same packs.

Sorry, but I do not know what is "unit search paths" in your answer.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 03:11:45 pm
Perhaps "paths" is this:
http://wiki.freepascal.org/images/2/21/CompilerOptions-Paths.png (http://wiki.freepascal.org/images/2/21/CompilerOptions-Paths.png)

These paths are the same in both my projects.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 03:22:20 pm
I changed path of folder for search strings in files in laz1.lpi.
But then in laz2.lpi this path was changed too.
Title: Re: Changes in one project influences another project
Post by: Handoko on March 17, 2017, 03:39:00 pm
Maybe the projects are using unit files that come from same location. Please see the image I provide. Note: I use Linux so the path separator is different with Windows.

To show up the Project Inspector:
Lazarus main menu > Project > Project Inspector.

On my example, you can see there are 2 units (unidebug and unifile) that are come from other folder. You can know it because the path are started with ".." (2 dots). It means the units are not placed on the project's folder.

Using unit file that is not placed on the project folder can be tricky (except the units that come from installed packages). I have to do it because several of my projects need those same units. But as I said it is tricky, I frequently messed up the codes. Until I was familiar with them, now I am careful enough not to cause problem.

So, maybe you can check your project inspector to make sure they aren't using any of unit that from other folder.
Title: Re: Changes in one project influences another project
Post by: bylaardt on March 17, 2017, 04:21:08 pm
arbitrary paths in fpc.cfg?
-Fu -Fi -Fl?
Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 04:38:19 pm
bylaardt, thank by answer

I am sorry, but I do not have enough knowledge for understand it.

Perhaps you're right.

Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 04:53:12 pm
Handoko, thanks by detailed and clear explanation. I understood it. Thank by image too.

In Project Inspector there is no some path. Only names. In both projects.

I made following experiment:
Added new folder folder3 thus:

  Folder
   ...folder1
   ......laz1.lpi
   ...folder2
   ......laz2.lpi
  Folder3

Then renamed folders folder1 y folder2 thus:

  Folder
   ...folder11
   ......laz1.lpi
   ...folder21
   ......laz2.lpi
  Folder3

Then put all content of folder21 to folder Folder3 (for avoid [..])

So finally I have following:

  Folder
   ...folder11
   ......laz1.lpi
   ...folder21
   ......laz2.lpi
  Folder3
  ...laz2.lpi

I am thinking, that this structure breaks any type of references between both projects.

Here are results:

1. Compilation of folder11 was good. So I think, that laz1.lpi from folder11 have not dependences with laz2.lpi of Folder3.

2. Compilation of folder3 was good. So I think, that laz2.lpi from folder3 have not dependences with laz1.lpi of Folder11.

3. The problem (between  laz1.lpi from folder11 and  laz2.lpi from folder3 ) persists.

Again: Each project has same Required Packages and same own name.


Title: Re: Changes in one project influences another project
Post by: Handoko on March 17, 2017, 05:20:13 pm
Halo, after some inspections I now found something that maybe the cause of your problem.

Try to open your project file but use only notepad (or wordpad). There you can see the filename is mentioned in the *.lpi file. For example, my project file is project1.lpi. In that files, it has this line:

Code: Pascal  [Select][+][-]
  1.         <Filename Value="project1.lpr"/>

I guess you're thinking what I think. Simply renaming the project file is not enough. Inside the file, the file name is hardcoded, you need to manually edit it too.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 09:42:21 pm
Thanks, Handoko.

Yes, I can see this line by using of wordpad. What I must make with .lpi file?

I did not change name of project. I did change only folder names.

********************
Here is another question.
I can open laz2.lpi with wordpad and edit list of units. By sample I delete two last blocks

<Unit3>
...
</Unit3>
and
<Unit4>
...
</Unit4>.

 After this I save wordpad and open laz2.lpi as Lazarus project.
And I see that nothing changed.

By other words the changes in laz2.lpi have no effect (within limits).
And other thing:  Editor Window does not show several units. By in laz2.lpi they esists.

Clarify: After add/delete units by using of Editor Window the file  laz2.lpi has changes corresponding.

But simple by open and close laz1.lpi and open laz2.lpi the content of units in project laz2.lpi does not corresponding to content of units of file laz2.lpi.

Title: Re: Changes in one project influences another project
Post by: JuhaManninen on March 17, 2017, 10:26:58 pm
yurkad, you do things in a very difficult way.
If you create new projects using the IDE as you are supposed to do, there will be no such problems.
You should use your capacity for real programming challenges instead of such self-made useless problems.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 17, 2017, 10:43:19 pm
yurkad, you do things in a very difficult way.
You are absolutely right.

If you create new projects using the IDE as you are supposed to do, there will be no such problems.
You should use your capacity for real programming challenges instead of such self-made useless problems.

It is very good advice.
I wanted to help find some bug.
But now taking into account that you are Global Moderator and Hero Member I will fulfill your advice.
Thanks.


*********************************
Please, this page is closed.
Title: Re: Changes in one project influences another project
Post by: JuhaManninen on March 18, 2017, 11:26:25 am
I wanted to help find some bug.
Ok, if there is a bug then I misunderstood you.
My impression was that you had copied the project files in a way they are not meant to be copied, resulting wrong references somewhere.
Copying source code between projects in editor is rather safe, as well as copying a Pascal unit file. Copying the project files is different and not recommended.
Anyway, if there is bug then we need clear steps to reproduce it.

One more thing about Lazarus projects and packages (this whole thread should be in Lazarus section):
Project's unit search path (-FU) should not point to external shared code.
For shared code you should always create a Lazarus package!
This is different from Delphi. There packages have their paths added to a global search path, used by all projects. It pollutes the namespace also for projects that don't use a certain package.
In Lazarus a project gets a dependency for a package. The package is found even if it is not installed in IDE because its location is remembered after it is opened once in the IDE.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 18, 2017, 10:52:22 pm
Ok.

Thanks by good explanation, JuhaManninen.
Title: Re: Changes in one project influences another project
Post by: Martin_fr on March 19, 2017, 12:13:51 am
Rereading your post:
Quote
After I add some unit in Code edit window of laz1.lpi then close laz1.lpi and open laz2.lpi,  this unit will appear in code edit window of laz2.lpi too. Same with delete some unit from laz1.lpi or from laz2.lpi.
Is this about units OPEN in the EDITOR window?

Because that differs from "ADDED to PROJECT".

Did you actually test, if the IDE modifies the lpi in the "other" directory?

- Backup both lpi
- work on one project
- save and close.
- use a diff tool to see if the other lpi was modified.

------------------------
The windows open in the editor, are stored in the session (and you can open files, that do NOT belong to the project, yet will be remembered).

The session can be stored either:
- as part of the lpi
- as lps file in the project folder
- as lps file in the global lazarus conf dir (primary config path)

And in the last case, if both projects have the same name, that will mean they share a session.

Go to menu: Project > Project Options
then page: Project Options > Session
And it will show where your session goes.
Title: Re: Changes in one project influences another project
Post by: Martin_fr on March 19, 2017, 12:16:37 am
Off topic / but about copying projects
Most of the time coping the folder will work.
A better way to get a clean copy, is using "Publish project" from the menu.
Title: Re: Changes in one project influences another project
Post by: Handoko on March 19, 2017, 02:57:36 am
Something that yurkat said interest me:

Quote
The real names of  laz1.lpi and  laz2.lpi are the same.

That makes me think of an issue that I ever made. I ever copied/pasted a project and renamed the copied project file (.lpi) manually (all those things done using file manager). Then weird things happened. Lesson learned, so if I want to duplicate project to a new name, now I always use:

Lazarus main menu > Project > Save Project As

I guess yurkad's issue is the same as the thing I did.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 19, 2017, 10:47:25 pm
Martin_fr, thanks!

Quote
Is this about units OPEN in the EDITOR window?
Yes, it is

Quote
Because that differs from "ADDED to PROJECT".
Yes, it is thus.

Quote
Did you actually test, if the IDE modifies the lpi in the "other" directory?
I did not understand this.

Quote
- Backup both lpi
- work on one project
- save and close.
- use a diff tool to see if the other lpi was modified.
Sorry, but I cannot make this already. According of advice of JuhaManninen I made new project, which is working correctly and then I deleted both folders.

Quote
The windows open in the editor, are stored in the session (and you can open files, that do NOT belong to the project, yet will be remembered).

The session can be stored either:
- as part of the lpi
- as lps file in the project folder
- as lps file in the global lazarus conf dir (primary config path)

And in the last case, if both projects have the same name, that will mean they share a session.
It is very useful information.
I deleted  lps file in the project folder. By this my case is:
Quote
lps file in the global lazarus conf dir (primary config path)
Unfortunately I did not know about the existence of this file in the global lazarus conf dir.
So the cause of this problem was that both projects share a session thru lps file in the global lazarus conf dir.
Thank you again, Martin_fr. The problem is solved!

Quote
Go to menu: Project > Project Options
then page: Project Options > Session
And it will show where your session goes.
I acknowledge that the real cause of this problem was my irresponsibility for using Lazarus. I should have studied so many things before, how to use it correctly! Including about session.

Quote
Off topic / but about copying projects
Most of the time coping the folder will work.
A better way to get a clean copy, is using "Publish project" from the menu.
This is the key advice to duplicate project in Lazarus. Many thanks!
Title: Re: Changes in one project influences another project
Post by: yurkad on March 19, 2017, 10:58:26 pm
Thank you, Handoko.

I hope that my previous post can be answer for you also.
Title: Re: Changes in one project influences another project
Post by: yurkad on March 19, 2017, 11:08:14 pm
The problem definirively is solved.

I apologize to all who wrote in this page and to all who read it.
You lost so much time just because I did not fulfill an obvious rule:
Before using a thing you have to study the rules of how to use it correctly.
TinyPortal © 2005-2018