Login Page - Create Account

Support Board


Date/Time: Tue, 21 Jan 2025 10:55:44 +0000



Post From: Persistent Variables Set Before SetDefaults() are Getting Reset

[2018-08-07 16:40:09]
BlakJak - Posts: 108
Hi,

I am setting a persistent variable (actually a pointer to an object I use in my study) at the start of the main function call. I do this because I need some info from the object to setup my defaults.

The problem I am finding is that when the code re-enters and tries to get the pointer to class Study back after the SetDefaults has been run, it is set to NULL again. Why and is there a way around this?

SCSFExport scsf_BidAskBubbles(SCStudyInterfaceRef sc)
{
  Study* p_Study = (Study*)sc.GetPersistentPointer(PersistentVarKeys::STUDY_PTR);

  if (sc.LastCallToFunction)
  {
    if (p_Study != NULL)
    {
      delete p_Study;
      sc.SetPersistentPointer(PersistentVarKeys::STUDY_PTR, NULL);
    }
    return;
  }

  if (p_Study == NULL)
  {
    p_Study = (Study*)new Study(sc);

    if (p_Study != NULL)
      sc.SetPersistentPointer(PersistentVarKeys::STUDY_PTR, p_Study);
    else
      return;
  }

  if (sc.SetDefaults)
  {
...