User forums > General (but related to Code::Blocks)
Distributing CB 20.03 compiled with debug configuration?
(1/1)
KodamaDeveloped:
CB20.03, Win10/mingw64.
Isn't distributing CB 20.03 compiled with any debug configuration that's probably __WXDEBUG__?
After I upgraded to 20.03, if a tool assigned in [Tools+] menu outputs a message containing non-ascii characters to [Tool Output] window, CB complains with [wxWidgets Debug Alert] dialog as the following many times.
../../src/common/string.cpp(1176): assert "c < 0x80" failed in FromAscii(): Non-ASCII value passed to FromAscii().
I know the window cannot show non-ascii characters correctly because it uses wxString::FormAscii in its PipedProcessCtrl::SyncOutput function. However, I don't like to see unnecessary dialogs popping up.
Thank you.
oBFusCATed:
wxAsserts are thing which should be reported and fixed. This is our first release with wx3.x, so we've decided to stick with them enabled.
The asserts dialog has a checkbox, so it is shown once per assert per session.
What are the exact steps to reproduce the problem?
KodamaDeveloped:
Thank you, I believe I understand the situation.
To reproduce the problem...
- By [Tools+|Configure Tool] open [User-defined Tools] dialog.
- Click [New] to assign a new tool to [Tools+].
- Enter "TestApp" to both [Tool Name] and [Tools Menu Path] text boxes.
- Select "Tools Output Window" from [Output to] drop down list.
- Enter a file name of any console application which outputs other than ascii characters to stdout, to [Command line] text box.
- [OK] to close the dialog.
- Execute [Tools+|TestApp]
The TestApp could be the following for example. It outputs a UTF-8 string. The [wxWidgets Debug Alert] dialog pops up 21 times if you don't check the checkbox, because I think the string has 7 characters, all of which are 3 code length (3 bytes).
--- Code: ---#include <iostream>
int main()
{
std::cout<<"\u3053\u3093\u306B\u3061\u306F\u4E16\u754C"<<std::endl;
return 0;
}
--- End code ---
I believe the problem is in PipedProcessCtrl::SyncOutput(plugins\contrib\ToolsPlus\PipedProcessCtrl.cpp:152, CB17.12). wxString is constructed from a given string by wxString::FromAscii function which only handles ascii characters. Although I've not understood why the function is called for each byte.
KodamaDeveloped:
--- Quote from: KodamaDeveloped on May 25, 2020, 02:28:13 pm ---Although I've not understood why the function is called for each byte.
--- End quote ---
OK, wxString::FromAscii does check each byte... (src\common\string.cpp:1161, wxWidgets 3.1.0)
--- Code: ---wxString wxString::FromAscii(const char *ascii, size_t len)
{
if (!ascii || len == 0)
return wxEmptyString;
wxString res;
{
wxStringInternalBuffer buf(res, len);
wxStringCharType *dest = buf;
for ( ; len > 0; --len )
{
unsigned char c = (unsigned char)*ascii++;
wxASSERT_MSG( c < 0x80,
wxT("Non-ASCII value passed to FromAscii().") );
*dest++ = static_cast<wxStringCharType>(c);
}
}
return res;
}
--- End code ---
Navigation
[0] Message Index
Go to full version