Problem in wxStringTokenizer for release build

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Widgets
Super wx Problem Solver
Super wx Problem Solver
Posts: 406
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Problem in wxStringTokenizer for release build

Post by Widgets » Fri Apr 23, 2021 9:25 pm

Working under Win 10 -updated, using MSVC 2019 community edition and wxWidgets 3.1.4
I have run into a curious problem with the following code

Code: Select all

/**
 * Col labels are saved in the INI file as a string of strings separated with '|'
 */
void MyFrame::RestoreColLabels()
{
  wxString        token;                                                                                                 <<<  confirmed for debug & release value
  wxString  wsSource = g_iniPrefs.data[IE_MAIL_GRID_COL_LABELS].dataCurrent.wsVal; <<<  is: Drop|Status|Size|From|Subject|To|Date|Account
  
  m_wasColLabels.Clear();

  wxStringTokenizer tokenizer( wsSource, "|", wxTOKEN_RET_EMPTY );
  size_t nTokens = tokenizer.CountTokens();                                                   <<<<< confirmed count = 8 for debug or release
  while ( tokenizer.HasMoreTokens() )
  {
    wxString token = tokenizer.GetNextToken();
    // process token here
    m_wasColLabels.Add( token );
  }
}
The string I am trying to parse is:

Code: Select all

Labels=Drop|Status|Size|From|Subject|To|Date|Account
When I run the app as a debug version, the tokens are returned as expected.
When I switch the app to run the release version, all tokens are returned empty
Environment: Win 10 64-bit & Mint 10.2
MSVC Express 2017, 2019
wxWidgets 3.1.4
Fight SPAM - report it with wxSR

User avatar
doublemax
Moderator
Moderator
Posts: 16026
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Problem in wxStringTokenizer for release build

Post by doublemax » Fri Apr 23, 2021 10:49 pm

You should check if the two configurations differ in any non debug related setting. E.g. character set.

What type is "wsVal"?
Use the source, Luke!

Widgets
Super wx Problem Solver
Super wx Problem Solver
Posts: 406
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Problem in wxStringTokenizer for release build

Post by Widgets » Sat Apr 24, 2021 12:48 am

I have gone over all settings, but could not find anything that made the least difference.
wsVal is type wxString

Curiously, the number of tokens returned is correct for both debug & release version, but getting the tokens in the loop fails.
Initially I used the default
wxStringTokenizer tokenizer( wsSource, "|" );
which gave me the same result.
Seems I need to step into GetNextToken() with a bit more attention. but that may be too much work for now.

There are a number of other things I may be able to look into and will, but most of these are really just guesses
Environment: Win 10 64-bit & Mint 10.2
MSVC Express 2017, 2019
wxWidgets 3.1.4
Fight SPAM - report it with wxSR

Post Reply