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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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: 3353
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: 3353
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
c:\mingw\projects....
and the file base path to be
Code
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: 3353
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: 13413
    • 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

  • Almost regular
  • **
  • Posts: 202
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
<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
<Unit filename="dddd.cpp" />
.
However, when I made "Save As" for this corrected project, all file records in cbp became absolute:
Code
		<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: 3353
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: 3353
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
#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
#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

  • Almost regular
  • **
  • Posts: 202
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: 3353
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

  • Almost regular
  • **
  • Posts: 202
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: 3353
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

  • Almost regular
  • **
  • Posts: 202
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.