* * *

Author Topic: [SOLVED] Changes in one project influences another project  (Read 1894 times)

yurkad

  • Full Member
  • ***
  • Posts: 107
[SOLVED] Changes in one project influences another project
« 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
« Last Edit: March 19, 2017, 11:11:47 pm by yurkad »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2916
  • I like bugs.
Re: Changes in one project influences another project
« Reply #1 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.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #2 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.
« Last Edit: March 17, 2017, 02:43:42 pm by yurkad »

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #3 on: March 17, 2017, 03:11:45 pm »
Perhaps "paths" is this:
http://wiki.freepascal.org/images/2/21/CompilerOptions-Paths.png

These paths are the same in both my projects.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #4 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.

Handoko

  • Hero Member
  • *****
  • Posts: 1194
  • My goal: build my own game engine using Lazarus
Re: Changes in one project influences another project
« Reply #5 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.

bylaardt

  • Full Member
  • ***
  • Posts: 214
Re: Changes in one project influences another project
« Reply #6 on: March 17, 2017, 04:21:08 pm »
arbitrary paths in fpc.cfg?
-Fu -Fi -Fl?

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #7 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.


yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #8 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.


« Last Edit: March 17, 2017, 05:05:33 pm by yurkad »

Handoko

  • Hero Member
  • *****
  • Posts: 1194
  • My goal: build my own game engine using Lazarus
Re: Changes in one project influences another project
« Reply #9 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.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #10 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.

« Last Edit: March 17, 2017, 10:01:02 pm by yurkad »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2916
  • I like bugs.
Re: Changes in one project influences another project
« Reply #11 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.

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #12 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.
« Last Edit: March 17, 2017, 10:50:40 pm by yurkad »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2916
  • I like bugs.
Re: Changes in one project influences another project
« Reply #13 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.
« Last Edit: March 18, 2017, 11:45:51 am by JuhaManninen »

yurkad

  • Full Member
  • ***
  • Posts: 107
Re: Changes in one project influences another project
« Reply #14 on: March 18, 2017, 10:52:22 pm »
Ok.

Thanks by good explanation, JuhaManninen.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus