Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: Lowkus on May 16, 2018, 11:08:42 pm

Title: wxSmith Couldn't Add New Handler
Post by: Lowkus on May 16, 2018, 11:08:42 pm
When I try to look at the events list in wxSmith, on any of three forms, it is not showing the events that I had created through wxSmith in the past.  If I try to add an event now, wxSmith asks me for an event name and I enter a unique name, then it throws an error "Couldn't Add New Handler".  Querying the search engines for answers, someone said it can happen when the project file points to incorrect files, but I don't see anything wrong (see code).  What is the reason that wxSmith is failing to handle events correctly?  How can I get it working again?

Code
		<Extensions>
<code_completion />
<envvars />
<debugger />
<wxsmith version="1">
<gui name="wxWidgets" src="src\cshpApp.cpp" main="frmTr" init_handlers="necessary" language="CPP" />
<resources>
<wxFrame wxs="wxsmith/frmMa.wxs" src="src/frmMa.cpp" hdr="src/inc/frmMa.h" fwddecl="0" i18n="1" name="frmMa" language="CPP" />
<wxFrame wxs="wxsmith/frmPa.wxs" src="src/frmPa.cpp" hdr="src/inc/frmPa.h" fwddecl="0" i18n="1" name="frmPa" language="CPP" />
<wxFrame wxs="wxsmith/frmTr.wxs" src="src/frmTr.cpp" hdr="src/inc/frmTr.h" fwddecl="0" i18n="1" name="frmTr" language="CPP" />
</resources>
</wxsmith>
</Extensions>
Title: Re: wxSmith Couldn't Add New Handler
Post by: oBFusCATed on May 17, 2018, 12:24:31 am
Can you reproduce this problem on a minimal sample project?
Title: Re: wxSmith Couldn't Add New Handler
Post by: Lowkus on May 17, 2018, 04:10:10 am
I don't get the error when I create a new simple project.
Title: Re: wxSmith Couldn't Add New Handler
Post by: oBFusCATed on May 17, 2018, 09:14:20 am
Can you inspect/compare the projects and see if you can find the thing that causes the problem?
Can you trim your project and post it?
Title: Re: wxSmith Couldn't Add New Handler
Post by: gd_on on May 17, 2018, 01:50:14 pm
I had such a problem on Windows 7, and for me, if I remember well, it was solved by changing the character encoding of sources files to UTF8 and/or making paths to my files containing only standard ascii characters. The problem was apparently caused by accentuated characters (as we have in french).
gd_on
Title: Re: wxSmith Couldn't Add New Handler
Post by: oBFusCATed on May 17, 2018, 06:37:28 pm
gd_on: Can you try to reproduce this problem?
Title: Re: wxSmith Couldn't Add New Handler
Post by: Lowkus on May 18, 2018, 06:19:09 am
I copied the wxs code from the failing project to the good project, it still works in the good project, so the problem can't be in the wxs code.  I'll keep looking for the problem.

Update: Something is telling wxSmith where to find the event code, whatever chunk of code is providing that linkage is the cause of the problem as far as I can tell.  I don't have time to debug it anymore, I'm just going to copy my code to the new project and hook up the form event connections from scratch.
Title: Re: wxSmith Couldn't Add New Handler
Post by: gd_on on May 18, 2018, 09:35:22 am
Sorry, I have not been able to reproduce the problem. :(
I am sure that accentuated character in path is sometimes a problem : for example, if codeblocks source path contains such character, as for example my firstname "Gérard", compilation fails on many "assert" instructions (but this has nothing to do with wxSmith !). No problem, if my path contains "Gerard", so replacing the "é" by a "e".
As said before, I had the same problem a few month ago ("Couldn't Add New Handler"), but apparently not caused by accentuated characters in the path ! Strange : I was almost sure the problem was here ! Sorry.  :-[
gd_on
Title: Re: wxSmith Couldn't Add New Handler
Post by: oBFusCATed on May 18, 2018, 01:03:11 pm
I copied the wxs code from the failing project to the good project, it still works in the good project, so the problem can't be in the wxs code.  I'll keep looking for the problem.

Update: Something is telling wxSmith where to find the event code, whatever chunk of code is providing that linkage is the cause of the problem as far as I can tell.  I don't have time to debug it anymore, I'm just going to copy my code to the new project and hook up the form event connections from scratch.

Have you used a diff tool to compare the two project files? I think all information for wxSmith is stored in the cbp file.
Title: Re: wxSmith Couldn't Add New Handler
Post by: Lowkus on May 19, 2018, 08:04:20 am
I just eyeballed the two files, but there wasn't more than a few lines to compare.  I've gotten the new project working and the old one is in the trash now, if I run into the problem again I might return to the search for the cause.  Somebody who really understands how wxSmith works will probably know how to fix the problem.
Title: Re: wxSmith Couldn't Add New Handler
Post by: bezet on March 27, 2026, 02:06:56 pm
Hello, I confirm that the same problem persists in March 2026 :
After adding a child window/frame using the wxSmith menu 'New Frame', I was unable to create/add any events.
Also components added to this frame return the same error "Couldn't Add New Handler" .
I looked at thevarious files to find any wrong path etc., without success.
Then I created another child frame in the same way, and there is no problem to create events!?
Title: Re: wxSmith Couldn't Add New Handler
Post by: ollydbg on March 27, 2026, 04:19:53 pm
Can you show us a step by step instructions? We need to reproduce this bug in our C::B. Unluckily, I don't know the steps.
Title: Re: wxSmith Couldn't Add New Handler
Post by: Miguel Gimenez on March 27, 2026, 07:41:07 pm
There are only two possible causes of this error:
- There is no // (*Handlers(FrameName) section in the dialog's include file
- An editor for the source file cannot be opened

See wxsEventsEditor::CreateNewFunction() for more information.

In the wxSmith menu there is a submenu (Configure wxSmith for current project) that may help

I would bet for an invalid file name.