never ending bug ...

 

Trying to delete object: OBJ_TREND

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
  {
        PrintFormat("%s: %d, %f, %s %s", EnumToString((ENUM_CHART_EVENT)id), lparam, dparam, sparam, 
                EnumToString((ENUM_OBJECT)ObjectGetInteger(0, sparam, OBJPROP_TYPE)));

        if(id == CHARTEVENT_OBJECT_DELETE)
            {
                  Print("DELETING ", sparam);
                  if(ObjectGetInteger(0, sparam, OBJPROP_TYPE) == OBJ_TREND)
                    {
                     Print("DELETE ", sparam);
                    }
            }
}

There is NO OBJ_VLINE on the chart !!!

I placed only this object on chart:

 

Give this a try


The issue is that sparam (the object name) may be deleted before the second ObjectGetInteger call.

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
   if(id == CHARTEVENT_OBJECT_DELETE)
   {
      ENUM_OBJECT type = (ENUM_OBJECT)ObjectGetInteger(0, sparam, OBJPROP_TYPE);
      PrintFormat("%s: %d, %f, %s %s", EnumToString((ENUM_CHART_EVENT)id), lparam, dparam, sparam, EnumToString(type));
      
      if(type == OBJ_TREND)
      {
         Print("DELETE ", sparam);
      }
   }
}
 
OK, thanks. But it doesn't work, the rewritten code does not change the result.
This line will never be executed.
Print("DELETE ", sparam);


On the other side, you might be right, the object might have been deleted, so it is not possible to retrieve its property using ObjectGetInteger();

Let's consider this not a bug, but improper usage of deleted object.

Note to myself, never access deleted object.