News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Saving a file without an extension

Started by sethjackson, November 21, 2006, 05:46:33 PM

Previous topic - Next topic

sethjackson

Recently I saved some files that didn't have an extension on the end (*.cpp, *.txt etc.).
I did File -> New -> Empty file. (added the file to the active project)
I typed in foo as the filename, but C::B saved the file as foo.a.c.
I would expect C::B to tack one extension on the end, but not two (Actually it would be nice if C::B just saved it as foo (no extension), but that is another story).

Is this supposed to happen?

BTW after looking at the code I think the problem (I'm assuming this is a problem) is somewhere in cbEditor::SaveAs(). Maybe with the wxFileDialog.........

MortenMacFly

#1
Agreed. That's weired. It seems to be related to the number of file extensions (wildcards). If you reduce this, it works properly again. I checked the wildcard string - it get's computed correctly though. So I'd say it's not our fault, but I wouldn't implement a hack around checking to see if the last wildcard (which is always "all files" is selected and then remove the additional file extensions. Let's hope it get's fixed in an upcoming wxWidgets release.
With regards, Morten.

Edit: I just found this piece of code inside wxWidgets:

            wxString::size_type nDot = m_wildCard.find(_T("*."));
            if ( nDot != wxString::npos )
                nDot++;
            else
                nDot = 0;

We *do* have file masks that do not have a dot, e.g. "*Makefile" and "*.py;*SConstruct;*SConscript". MAybe it's our fault...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

#2
Bingo!!! "Python files|*.py;*SConstruct;*SConscript|" is the culprit. Adding this to any wxFileDialog will result in the strange behaviour for "All files". You can try with using for a wildcard masks:

Filters = _T("AngelScript files|*.as|Batch files|*.bat;*.cmd;*.nt|Make files|*Makefile;*.mak|Python files|*.py;*SConstruct;*SConscript|All files|*.*");

This won't work if you select "All files".
So - I'd say we have to fix the file masks (I believe the originate from the lexers)!
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

MortenMacFly

now it has begun to become *really* weired: I've removed the extensions accordingly but: no success! Then I tried again my little demo example with the following wildcard:

Wildcard=AngelScript files|*.as|Batch files|*.bat;*.cmd;*.nt|Make files|*.mak|Python files|*.py|All files|*.*

Which result's in illegal file extensions! Now where is the issue here? As soon as you remove any of these extensions (e.g. "AngelScript files|*.as" it will work again. But this combination (although it's fully correct) won't work.

Somebody out there who has a glue what's going on here???

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Game_Ender

There is a bug somewhere in the wxWidgets dialog and wildcards parsing.  Last time I used it was with wxMac 2.6.3 with STL enabled.  Which meant that wxString throws exceptions if you index them wrong, and everything time I tried to use the wildcard features it threw an index out of range exception.  I didn't have to make up a patch, so I just worked around it.  Debugging into wxWidgets or running it threw valgrind will probably reveal the error.  Either that or it is supposed to be used a certain way and we aren't using it that way.

sethjackson

#5
I wish I did have some code "glue" or even a clue as to what is going on. :P

Quote from: MortenMacFly on November 22, 2006, 07:54:41 PM

Wildcard=AngelScript files|*.as|Batch files|*.bat;*.cmd;*.nt|Make files|*.mak|Python files|*.py|All files|*.*


Are you sure that code is right? I thought all the filters had to have a semi-colon after them......
That example doesn't......

http://wxwidgets.org/manuals/2.6.3/wx_wxfiledialog.html#wxfiledialog

EDIT:

Oh oh oh I see it (I think).

Batch files|*.bat;*.cmd;*.nt

Der Meister

I don't think so. The example in the documentation you mentioned has them, too:

"BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

MortenMacFly

Quote from: sethjackson on November 23, 2006, 01:34:31 AM
Oh oh oh I see it (I think).
Batch files|*.bat;*.cmd;*.nt
Nope, this works properly - you can try by just removing the Python file extension it'll suddenly work.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]