Yes, ChannelName is an array that is initialized at program start for them all to be "Velocity". [0] always stays as "Velocity", but [1]+ are assigned values depending on what is available in the database.

That logic seems to work OK, based upon my tests. I didn't want to have to create another flag for this initialization if I didn't have to, but I guess that your proposal would be cleaner and easier to understand.




________________________________
 From: arthare <notifications@github.com>
To: arthare/wifilapper <wifilapper@noreply.github.com> 
Cc: KDJones2 <KDJones2@yahoo.com> 
Sent: Thursday, April 4, 2013 5:03 AM
Subject: Re: [wifilapper] Fixed PlotPrefs initialization logic (#19)
 

In PitsideConsole/PitsideConsole/DlgPlotSelect.cpp:
> @@ -150,9 +150,8 @@ void LoadLaps(ILapReceiver* pReceiver, int m_iRaceId)
>          case WM_INITDIALOG:
>          {
>            //  Initialize all data channels, if not already set by user.
> -          //  Assumes first data channel will be either true or false if user has set things up already
> -          if (!m_sfLapOpts->m_PlotPrefs[1].iPlotView == false && !m_sfLapOpts->m_PlotPrefs[1].iPlotView == true)
> -          {
> +          if (m_sfLapOpts->m_PlotPrefs[1].m_ChannelName[512] == m_sfLapOpts->m_PlotPrefs[0].m_ChannelName[512])
> +		  {
>              InitPlotPrefs(hWnd, lParam); 
This is still pretty weird, but ok.  I'm assuming that m_ChannelName is an array of strings (if it is a TCHAR array or a LPCTSTR array then this probably won't work reliably), and that if the 0th plot pref is the same as the 1st plot pref, you're assuming that things haven't been inited yet.
A better way to do this would be something like
static bool fInitedPlotPrefs = false;
if(!fInitedPlotPrefs)
{
InitPlotPrefs(hWnd,lParam);
fInitedPlotPrefs = true;
}
—
Reply to this email directly or view it on GitHub.