Author Topic: problem with "File/New/File..."  (Read 3607 times)

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
problem with "File/New/File..."
« on: July 07, 2010, 01:46:09 pm »
In some cases C::B creates new file in project with full path to file instead of relative. So, in file property fields "File name (absolute)" and "File name (relative)" are identical. As result, C::B generates really odd  build errors. It may be corrected by direct edit of project file snf temporary cured by deletion of the C:B config. Looks like it is an issue with global C:B configuration file. Any suggestions? 
OS: WinXP SP3.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12911
    • Travis build status
Re: problem with "File/New/File..."
« Reply #1 on: July 07, 2010, 02:43:36 pm »
CB version, please?

I've never seen this kind of behavior, but I'm running CB on linux, most of the time.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #2 on: July 07, 2010, 03:04:15 pm »
CB version, please?

I've never seen this kind of behavior, but I'm running CB on linux, most of the time.
both last releases, 8 & 10, and some  nightly builds.  At my work PC it occurs some times, but not really often- so I ignored it. But now it became really annoying on one PC, from v.8.02.  Migration to v.10 does not help. After some time in all more or less big projects (with sub-dirs) it appear. IMHO, glitches with build originated from ":\" in path, so under linux it may not be so explicit. For exact file it may be corrected by edit of the .sbp.   

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #3 on: April 03, 2020, 02:01:50 pm »
This problem re-appears in C::B 20.03 on Win 10 64b.
In some projects new files always added with absolute path in "File name (relative)" property. What can be the source of such strange behavior?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #4 on: April 03, 2020, 02:57:50 pm »
can you provide a example project?
What kind of path are you using? Any non ascii characters?

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #5 on: April 03, 2020, 09:39:30 pm »
I`ll try to reproduce it on dedicated project. Currently it is "production" project, it cannot be shared.
There are no spaces, non-ascii symbols in path, etc.
I suspect that the problem occurred after I included some already existing files from subfolder. Then, when I wished to make a new *.cpp file, wizard opened this subfolder, I walked from it level up, to the root folder of the project, and then it happened.
 
« Last Edit: April 03, 2020, 10:16:23 pm by nenin »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #6 on: April 04, 2020, 11:50:27 am »
If you can reproduce this, please post a step by step list. Something like this:
1) Open codeblocks
2) Crete a new project
3) Add file XY by clicking Project->Add
ecc...

Thank you!

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #7 on: April 06, 2020, 02:57:32 pm »
At that moment I cannot reproduce that, but I found two strange point in cbp:
1. In list of the virtual folders:
Code: [Select]
<Option virtualFolders="main/;static/" />
typical in projects it looks like
Code: [Select]
<Option virtualFolders="main/;static/;" />
2.  and Extensions:
Code: [Select]
<Extensions />
while it must be at least:
Code: [Select]
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
No other deviations was found so far.
When  I tried to make "Save As" for this project, I  got all source files with full path, and mentioned above deviations was reproduced as well even if they were corrected manually.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12911
    • Travis build status
Re: problem with "File/New/File..."
« Reply #8 on: April 06, 2020, 07:11:59 pm »
Empty extensions is a "feature" of recent builds.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #9 on: April 07, 2020, 01:23:53 pm »
I found that on different computer it work fine on C::B 17 (on my main workstation- not works on both 17 & 20 with the same pattern).
Is there any place (registry, user profile folder...) where C::B can also store project options?
« Last Edit: April 07, 2020, 02:32:04 pm by nenin »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12911
    • Travis build status
Re: problem with "File/New/File..."
« Reply #10 on: April 07, 2020, 07:34:28 pm »
Nope. They are only stored in the project.
Have you compared full build logs for working and non working builds?
Are you sure there aren't differences in global compiler options?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #11 on: April 08, 2020, 07:56:11 am »
Quote
Have you compared full build logs for working and non working builds?
It not related to build, it is situation, when C::B makes the wrong path to new file in project. I dont try even build it because compiler gone crazy when such path was offered. 
Quote
Are you sure there aren't differences in global compiler options?
This installation (which is working) is a clone from defected one from my workstation, ~1 month fresh,   including C::B profile and whole mingw. Nothing was changed in global scope.
I suspect that something wrong might be in default.conf, but cannot find anything.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #12 on: April 08, 2020, 08:20:00 am »
Can you please exactly describe the failing steps and the outcome? I am not sure if i understand the issue...

If you can reproduce this, please post a step by step list. Something like this:
1) Open codeblocks
2) Crete a new project
3) Add file XY by clicking Project->Add
ecc...

Thank you!

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #13 on: April 09, 2020, 07:40:12 am »
Please find attached file with step-by_step explanation.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #14 on: April 09, 2020, 09:14:07 am »
Thank You!
This explains the error perfectly... Now lets try how i can reproduce this...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #15 on: April 09, 2020, 10:20:15 am »
I have tried different methods, until now i am not able to reproduce...
Does this only happen if you use the new file wizard, or does it also happen if you add a existing file to the project, or use the File->New->Empty file menu entry?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #16 on: April 09, 2020, 10:24:37 am »
Quote
Then, when I wished to make a new *.cpp file, wizard opened this subfolder,
For me the wizard always opens the project root folder...

Can you confirm, that all files are children of the project folder?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #17 on: April 09, 2020, 10:26:41 am »
In your PDF in the image is see the Project base path to be
Code: [Select]
c:\mingw\projects....and the file base path to be
Code: [Select]
C:\mingw\projects....So one has a lower case C and one a upper case C ... this can probably lead to the problem...
The question is why is one lower case and one upper case...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #18 on: April 09, 2020, 10:30:48 am »
If i modify the project file by hand and add the full path to the file with lower case drive letter i see the same behavior....

So can you confirm:
1) In your project file (open it with notepad++ for example): Do the failing files have absolute paths with upper or lower case drive letters?
2) Make a copy of the project file and replace the drive letter with the other case. Does the problem goes away?

Can you imagine why the drive letters differ? Have you added the path by copy and paste?

@Devs: Is this probably a wxWidgets path normalization bug? As far as i know widows paths should be case insensitive or not?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12911
    • Travis build status
Re: problem with "File/New/File..."
« Reply #19 on: April 09, 2020, 06:24:15 pm »
You could test this easily using wxFileName and the same functions C::B is using...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #20 on: April 10, 2020, 08:00:37 am »
Quote
Does this only happen if you use the new file wizard,
Yes. I dont use "empty file" option, and I dont remember problems with adding already existed files. 
Quote
Can you confirm, that all files are children of the project folder?
Yes. But looks like that issue appeared after I added already existed files from child folder to project. I added 2 files from sub-folder, then I opened wizard, it proposed to create new file inside this sub-folder (it is actually "rtb" folder in project tree), not in the project root. And then it started...

Quote
Do the failing files have absolute paths with upper or lower case drive letters?
It is it:
Code: [Select]
<Unit filename="C:/mingw/projects/fltk_kikus_v0/dddd.cpp" /> In fresh new project, which is OK, "C"  is big (see attach). 
Quote
Make a copy of the project file and replace the drive letter with the other case. Does the problem goes away?
Strange, but Yes! I did it, opened it in C::B.  If I open and then  "Save"  project with corrected "c", I got normal record
Code: [Select]
<Unit filename="dddd.cpp" />.
However, when I made "Save As" for this corrected project, all file records in cbp became absolute:
Code: [Select]
<Unit filename="c:/mingw/projects/fltk_kikus_v0/main.cpp">
<Option virtualFolder="main/" />

Quote
Have you added the path by copy and paste?
No. I have no idea why it appeared.
Just in case: I`m using Polish Win10. But for sure there are no non-ascii letters in path, etc.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #21 on: April 10, 2020, 09:26:00 am »
Quote
However, when I made "Save As" for this corrected project, all file records in cbp became absolute:
I can not reproduce this. Steps i do:
1) Cerate a project and add a file
2) Close codeblocks
3) Open the project file in Editor, Modify the path to a source file to absolute and use lower case drive letter
4) Open in codeblocks -> path is absolute
5) Close codeblocks
6) Open the project file in text editor, modify the drive letter to upper case, save
7) Open project in codeblocks -> Project tree is working as expected
8) Save project as -> Paths are all relative

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #22 on: April 10, 2020, 10:32:06 am »
I think i have found the problem on the loading side:
in sdk\cbproject.cpp:870
Code: [Select]
#ifdef __WXMSW__
    // for Windows, make sure the filename is not on another drive...
    if (   (local_filename.Length() > 1)
        && (local_filename.GetChar(1) == _T(':'))
        && (fname.GetVolume() != wxFileName(m_Filename).GetVolume()) )
        // (this is a quick test to avoid the costly wxFileName ctor below)
    {
        fname.Assign(filename);
    }
we check if the drive letters are different. As far as i can find drive letters are case insensitive on windows. So we should use a case insensitive comparison here...
Code: [Select]
#ifdef __WXMSW__
    // for Windows, make sure the filename is not on another drive...
    if (   (local_filename.Length() > 1)
        && (local_filename.GetChar(1) == _T(':'))
        && !(fname.GetVolume().IsSameAs(wxFileName(m_Filename).GetVolume(), false)) )
        // (this is a quick test to avoid the costly wxFileName ctor below)
    {
        fname.Assign(filename);
    }
    else if (fname.GetFullPath().StartsWith(_T("\\\\"))) // UNC path
    {
        fname.Assign(filename);
    }
    else
#endif

I have not searched on the file creation site, because i can not reproduce it...

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #23 on: April 10, 2020, 11:29:29 am »
Looks like I made  fresh invalid project.
See attachment.
1.  "tst_cbp_00.cbp"  - aready corrupted, but nothing is visible
2.  "tst_cbp_01.cbp" - cloned and saved after creation of test.cpp by wizard.
3.  "tst_cbp_02.cbp" - tst_cbp_00.cbp  just as it was "Save As"
It started after I just tried do add files from "mingw_thrd\" but canceled operation.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #24 on: April 12, 2020, 08:33:29 pm »
A fix is in trunk. and you can try it in the next nightly...
In the worst case you have to remove and add the problematic files again, but it should fix all during opening the project...

 [r12046]

If you still have the problem, please report back..

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #25 on: April 15, 2020, 07:22:30 am »
Thanks, I`m waiting.
Looks like this issue start to propagate to other projects. Strange...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2850
Re: problem with "File/New/File..."
« Reply #26 on: April 15, 2020, 09:37:05 am »
Thanks, I`m waiting.
Looks like this issue start to propagate to other projects. Strange...
I have the strange feeling, this has something to do with the default "new file" and "open file" settings in the windows registry (out of reach of codeblocks)... But as i mentioned top, this should no longer be a problem with the upcoming nightly...

Offline nenin

  • Multiple posting newcomer
  • *
  • Posts: 120
Re: problem with "File/New/File..."
« Reply #27 on: April 15, 2020, 12:49:20 pm »
It is very likely. I have somehow similar problem with FLTK: application saves somewhere some generic data, like last path used in Open/Save dialog,  and this data may jump out in next run, or not.