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
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Problem in wxStringTokenizer for release build

Post by Widgets »

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/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Problem in wxStringTokenizer for release build

Post by doublemax »

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
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 534
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Re: Problem in wxStringTokenizer for release build

Post by Widgets »

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/11 64-bit & Mint 21.1
MSVC Express 2019/2022
wxWidgets 3.2.2
Post Reply