Author Topic: Error when adding a new file (to a project)  (Read 13807 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Error when adding a new file (to a project)
« on: November 21, 2005, 07:17:38 pm »
Dear all,

I am having troubles adding a new file to a project. Whenever I try it I receive an error message: "An unhandled exception occurred. Press "Abort" to [...]". If I press "abort" I immediately receive the following error message:
Code
An exception has been raised!
The application encountered an error at sdk\configmanager.cpp, on line 504.
The error message is:
The Configuration key 16 (child of node "editor" in namespace "editor") does not meet the standard for variable naming.
Variables names are required to start with a letter.
After that C::B freezes. If I press ignore I can continue working, but (of course) the file is not being created. I am using the CVS version as of today, Windows XP OS with wxWidgets 2.6.1. Does anybody else encounter the same problem?

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

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error when adding a new file (to a project)
« Reply #1 on: November 21, 2005, 07:25:01 pm »
Yes, the devs were just discussing this issue. We'll try to fix it ASAP.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Error when adding a new file (to a project)
« Reply #2 on: November 21, 2005, 07:38:12 pm »
Yes, the devs were just discussing this issue. We'll try to fix it ASAP.
Great! You are so faaaaast! :D

By the way: I don't now, if it's related, but if I choose "File" -> "New File" and click "Cancel" in the "Save as" dialog appearing, the C::B title suddenly shows "*Untitled 2" as document. Even if there is no new document...

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

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error when adding a new file (to a project)
« Reply #3 on: November 21, 2005, 08:10:40 pm »
I suppose that's related, but haven't checked it out. Oh, btw... I was finding out the origin of the exception, but turns out that some C::B code needs to change (some things which were valid, now are not). And I'm at work right now, so I can't work on it until 8PM.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Error when adding a new file (to a project)
« Reply #4 on: November 21, 2005, 08:32:22 pm »
And I'm at work right now, so I can't work on it until 8PM.
:lol: ...in my country it's currently 8:30PM. :lol:
But seriously: Take your time...

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

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Error when adding a new file (to a project)
« Reply #5 on: November 21, 2005, 09:27:28 pm »
I have found at least two illegal keys, although those are not likely the ones causing this particular error.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Error when adding a new file (to a project)
« Reply #6 on: November 21, 2005, 09:36:58 pm »
I got an idea... why not use regedit and search for all the offending keys?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Error when adding a new file (to a project)
« Reply #7 on: November 21, 2005, 09:47:00 pm »
I have been searching for printf, because many offending keys are generated like this:

some_string.Printf("/some/path/%d", integer)

I have also been searching for _T("editor") in order to find all places where that namespace is being used, but that did not reveal anything.

I really wish there was something like __FILE__, __LINE__, or __FUNCTION__  which we could use. But we would need something like __CALLING_FUNCTION__.
I don't know of any such thing, is there? If there is, I could just add it to the exception, and you would know *exactly* where to look.

EDIT:
Never mind, backtrace will do too...
« Last Edit: November 21, 2005, 09:54:56 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Lamego

  • Guest
Re: Error when adding a new file (to a project)
« Reply #8 on: November 21, 2005, 09:49:32 pm »
Here is a backtrace of the crash on linux:

...

#5  0xb7744f11 in std::terminate () from /usr/lib/libstdc++.so.6
#6  0xb774509c in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0xb7e2c46c in ConfigManager::AssertPath (this=0x83377c8, path=@0xbfca01ac)
    at configmanager.cpp:504
#8  0xb7e2d843 in ConfigManager::Read (this=0x83377c8, name=@0xbfca024c,
    str=0xbfca01f8) at configmanager.cpp:644
#9  0xb7e2da40 in ConfigManager::Read (this=0x83377c8, name=@0xbfca024c,
    defaultVal=@0xbfca0254) at configmanager.cpp:624
#10 0xb7e59960 in EditorManager::New (this=0x8335d88) at editormanager.cpp:689
...
Code
643         wxString key(name);
644         TiXmlElement* e = AssertPath(key);
645
646         TiXmlHandle parentHandle(e);
647         TiXmlText *t = (TiXmlText *) parentHandle.FirstChild(_C(key)).FirstC hild("str").FirstChild().Node();
648
(gdb) p name
$2 = (const wxString &) @0xbfca024c: {<wxStringBase> = {
    static npos = 4294967295,
    m_pchData = 0x8c7ad5c "/default_code/7"}, <No data fields>}

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Error when adding a new file (to a project)
« Reply #9 on: November 21, 2005, 09:53:10 pm »
Instead of "/default_code/7" it should say "/default_code/set7". I just found it in Windows too.

Just searched for "default_code" in all project files and found 3 wrongly set.

It seems like this bug is dying now...

Just changed those offending keys and it's working!!!

editorconfigurationdialog.cpp lines 532 and 536
editormanager.cpp line 688
« Last Edit: November 21, 2005, 09:58:14 pm by Ceniza »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Error when adding a new file (to a project)
« Reply #10 on: November 21, 2005, 09:57:52 pm »
Yup, the offender is in 688:
Code
key.Printf(_T("/default_code/%d"), (int)FileTypeOf(ed->GetFilename()));
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Error when adding a new file (to a project)
« Reply #11 on: November 21, 2005, 10:01:47 pm »
editorconfigurationdialog.cpp lines 532 and 536
Those two were fixed ~15 mins ago, and the third is now too. Update and try again.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Error when adding a new file (to a project)
« Reply #12 on: November 21, 2005, 10:24:47 pm »
I really wish there was something like __FILE__, __LINE__, or __FUNCTION__  which we could use. But we would need something like __CALLING_FUNCTION__.
I don't know of any such thing, is there? If there is, I could just add it to the exception, and you would know *exactly* where to look.

If I recall correctly, defaulted arguments are evaluated at the place a function is called. This means that if you add extra arguments defaulting to __FILE__, __LINE__, or __FUNCTION__ you should get their values at the call site.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Error when adding a new file (to a project)
« Reply #13 on: November 21, 2005, 10:40:55 pm »
Unluckily does not work  :(

Code
#include <stdio.h>

void func(const char* x = __FUNCTION__);

int main()
{
func();
return 0;
}

void func(const char *x)
{
printf("called from %s", x);
}

called from
Press ENTER to continue.



Code
#include <stdio.h>

void func(int x = __LINE__);

int main()
{
func();
return 0;
}

void func(int x)
{
printf("called from %d", x);
}

called from 3
Press ENTER to continue.


Not what we need.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Error when adding a new file (to a project)
« Reply #14 on: November 21, 2005, 11:31:22 pm »
Unluckily does not work  :(

Maybe I misremembered then, that or there's a bug in gcc.
Well, if the function has a unique name you could use an ugly :? wrapper macro to add the extra arguments:
Code
#include <stdio.h>

void func(const char* x)
{
printf("called from %s", x);
}
#define func() func(__FUNCTION__)

int main()
{
func();
return 0;
}
which works, but as mentioned you better hope no client code uses other functions/classes/variables with the same name.
« Last Edit: November 21, 2005, 11:34:03 pm by Urxae »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Error when adding a new file (to a project)
« Reply #15 on: November 22, 2005, 10:45:24 pm »
I've just realised that this bug obvioulsy has been fixed in CVS. I'd like to point out that this took only a single day - not even professional support companies are that fast... you rock!

Morten.

Ps.: ...a minor issue remains, but it's cosmetic only:
By the way: I don't now, if it's related, but if I choose "File" -> "New File" and click "Cancel" in the "Save as" dialog appearing, the C::B title suddenly shows "*Untitled 2" as document. Even if there is no new document...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Error when adding a new file (to a project)
« Reply #16 on: November 22, 2005, 11:07:50 pm »
Only 3 hours :)

Ps.: ...a minor issue remains
And this is fixed, too.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Error when adding a new file (to a project)
« Reply #17 on: November 23, 2005, 08:01:10 am »
And this is fixed, too.
Aaah, I see (CVS was a bit behind).

...it's like christmas... :lol:

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