Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-01

Opening non existing files and (not) adding them to the project

15 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth

Hello together!

Working with 1.6RC2 I noticed a - for me - very serious problem and wonder whether I've missed some option.
Back in 1.4.x when I opened a non-existing file and I confirmed that I want to have it created the file was not added to project or the project's mainfile. This is wonderful and I use it to quickly create testcases for the compiler (which don't need their own project and are compiled from the command line or from the compiler running debugged in the IDE anyway). Now with 1.6RC2 I noticed that such files are added to the uses clause of the main program file and the project inspector.
Is there some option I have missed to change this behavior? Because not only meeses this up the compiler project, but CodeTools don't like it as well as the files I add this way are usually program files, thus they shouldn't be in the uses section anyway.
If there isn't the this should be changed preferably before the release of 1.6 as otherwise that version will be useless for me (or I'll have to patch out that code myself).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160117/e8edb400/attachment.html>

Reply by email

Bart
to Sven Barth
Sven Barth wrote
Is there some option I have missed to change this behavior? Because not only meeses this up the compiler project, but CodeTools don't like it as well as the files I add this way are usually program files, thus they shouldn't be in the uses section anyway.

Odd.

ProjectOptions->Miscallaneous-> "Main unit has uses section containing all units of a project".
Uncheck and save as default compiler options?

Would have expected that to be a global setting.

Bart

Reply by email

Sven Barth
to Bart
"Bart" wrote 15 lines
On 1/17/16, Sven Barth wrote: > Is there some option I have missed to change this behavior? Because not > only meeses this up the compiler project, but CodeTools don't like it as > well as the files I add this way are usually program files, thus they > shouldn't be in the uses section anyway. Odd. ProjectOptions->Miscallaneous-> "Main unit has uses section containing all units of a project". Uncheck and save as default compiler options? Would have expected that to be a global setting.

That solves at least one part of the issue. The new file is however still added to the project which is not good.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160117/4a78aaef/attachment-0001.html>

Reply by email

ListMember
to Sven Barth: Hello together! Working with 1.6RC2 I noticed a - for me - very serious problem and wonder
Sven Barth wrote
when I opened a non-existing file and I confirmed that I want to have it created the file was not added to project or the project's mainfile.

But, isn't this how Delphi has been doing it all these years.

1) When you create a new unit, it automatically gets added to the project.

2) When you decide to save the project, you're asked whether you want to save the newly added (not saved yet) units. If not, it is removed from the project and you lose its contents.

3) If you want to exclude the newly created unit, you remove it from the project. In that case, IDE asks you whether you wish to save that file (or lose it).

Do you still/really want a 'non-standard' behavior?

Reply by email

Juha Manninen
to Sven Barth: Hello together! Working with 1.6RC2 I noticed a - for me - very serious problem and wonder
Sven Barth wrote 5 lines
Back in 1.4.x when I opened a non-existing file and I confirmed that I want to have it created the file was not added to project or the project's mainfile. [...] Now with 1.6RC2 I noticed that such files are added to the uses clause of the main program file and the project inspector.

You cannot open a non-existing file, meaning that you cannot use the File -> Open dialog for it. There is now a "FileMustExist" or similar flag. I remember it fixed some bug but don't remember which one. IMO it is logical because you can by definition only open existing files. If a file does not exist, you must create it instead. The right fix could be to ask if a newly created file should be added to project which means useless questions for most people. Or, maybe the best way is to create a file somewhere else (editor, file manager, cmd line etc), then open it. Even an empty file can be opened.

Juha

Reply by email

Mattias Gaertner
to Juha Manninen
[...] You cannot open a non-existing file, meaning that you cannot use the File -> Open dialog for it. There is now a "FileMustExist" or similar flag. I remember it fixed some bug but don't remember which one.

That would be a regression.
It is one of the oldest features of the IDE.

Mattias

Reply by email

Sven Barth
to Juha Manninen: You cannot open a non-existing file, meaning that you cannot use the File -> Open dialog…
"Juha Manninen" wrote
On Sun, Jan 17, 2016 at 4:30 PM, Sven Barth
> Back in 1.4.x when I opened a non-existing file and I confirmed that I

want

> to have it created the file was not added to project or the project's

mainfile.

> [...] > Now with 1.6RC2 I noticed that such files are added to the uses clause

of

Show quoted text 7 lines
> the main program file and the project inspector. You cannot open a non-existing file, meaning that you cannot use the File -> Open dialog for it. There is now a "FileMustExist" or similar flag. I remember it fixed some bug but don't remember which one. IMO it is logical because you can by definition only open existing files. If a file does not exist, you must create it instead.

Don't shock me like that, Juha.

The IDE actively asks me whether I want to create a new file if I open a non existing one and it should definitely stay that way.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160118/82d24a7a/attachment-0001.html>

Reply by email

Sven Barth
to ListMember: But, isn't this how Delphi has been doing it all these years. 1) When you create a new…
"ListMember" wrote
On 2016-01-17 16:30, Sven Barth wrote: > > when I opened a non-existing file and I confirmed that I want to have it

created the file was not added to project or the project's mainfile.

Show quoted text 7 lines
But, isn't this how Delphi has been doing it all these years. 1) When you create a new unit, it automatically gets added to the project. 2) When you decide to save the project, you're asked whether you want to

save the newly added (not saved yet) units. If not, it is removed from the project and you lose its contents.

3) If you want to exclude the newly created unit, you remove it from the

project. In that case, IDE asks you whether you wish to save that file (or lose it).

Do you still/really want a 'non-standard' behavior?

I don't care what Delphi does. I care about what Lazarus has done for years and what I have relied upon. For me this *is* standard behavior.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160118/000c4cb7/attachment.html>

Reply by email

Juha Manninen
to Sven Barth: want mainfile. of Don't shock me like that, Juha. The IDE actively asks me whether I want…
Sven Barth wrote
Don't shock me like that, Juha. The IDE actively asks me whether I want to create a new file if I open a non existing one and it should definitely stay that way.

Ok, you and Mattias are right.
The OpenDialog in TMainIDE.mnuOpenClicked has no ofFileMustExist flag. I got confused with changes I made for Delphi converter dialogs.

Anyway the file open dialogs in GTK2 and QT don't respect the omitted ofFileMustExist flag. They behave like it was set. That is another bug clearly.
I got the question about creating a new file only using Windows version of Lazarus.

Can you find what revision caused the original problem you described?

Juha

Reply by email

Mattias Gaertner
to Juha Manninen
[...] Anyway the file open dialogs in GTK2 and QT don't respect the omitted ofFileMustExist flag. They behave like it was set. That is another bug clearly.

It works here on GTK2/Ubuntu. I can choose a non existing file.

Mattias

Reply by email

Juha Manninen
to Mattias Gaertner
Mattias Gaertner wrote
It works here on GTK2/Ubuntu. I can choose a non existing file.

I guess you mean you can type a name of a non existing file. You cannot choose it because by definition it does not exist.

I have Xubuntu 15.10 with XFCE now. Can it make a difference? The window manager of XFCE behaves strangely sometimes. I can test with another distro later.

Juha

Reply by email

Sven Barth
to Juha Manninen: Ok, you and Mattias are right. The OpenDialog in TMainIDE.mnuOpenClicked has no…
"Juha Manninen" wrote
Can you find what revision caused the original problem you described?

Seems like it was more PEBKAC than anything else.
The thing is I normally use this when I work with the compiler and there I add my tests to a directory parallel to the project directory. However when I found this "problem" I had a different project in this test directory open (cause I needed to debug it), but I added a test in the same directory.
Now while looking for the changed revision I found out that Lazarus applies a heuristic when to add a file to the project. Part of the decisions is the above mentioned difference and it seems to have been like that at least since 1.3 times (that's what I had accessible right now). So there was nothing changed at all and I merely stumbled upon my own stupidity -.-

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160118/65d2691c/attachment-0001.html>

Reply by email