Errors, bugs, questions - page 216

 
Vigor:

I've encountered a call stack overflow problem (so I think).

After calling a method of one of the objects , see example below. The code is simplified, just the gist. Class CClass1 is a base class and list1 has different objects which are descendants of this class and their init functions are implemented differently. So, in one class where the init function fetches such a list (to put it simply, it initializes a nested interface, a panel in the panel) after returning from init in the line

there is an error

2010.12.02 00:21:00 test1 (EURUSD,H1) Invalid pointer access in 'Container.mqh' (74,10)

I.e. pointer t is dead.

When debugging, there is no such error, after method call the pointer is "alive", nested interfaces are created and Expert Advisor works further.

This is the only way around the error:

#property stacksize pointer achieved nothing.

It is hard to say anything for sure. You need the source code.

Try to write a request to servicedesk.

Общайтесь с разработчиками через Сервисдеск!
Общайтесь с разработчиками через Сервисдеск!
  • www.mql5.com
Ваше сообщение сразу станет доступно нашим отделам тестирования, технической поддержки и разработчикам торговой платформы.
 

I came back from holiday, started terminals, updated to 360 build and one indicator stopped working...

I read the changes: 6. MQL5: Fixed processing of click event on a chart.

Now when you click on a graphical object two events are generated at once: CHARTEVENT_OBJECT_CLICK + CHARTEVENT_CLICK, while before there was only one CHARTEVENT_OBJECT_CLICK, which allows to simulate a double click

Will it always be like this or is it a bug?

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Типы событий графика
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Типы событий графика
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Типы событий графика - Документация по MQL5
 
AlexSTAL:

Came back from holiday, started the terminals, updated to 360 build and one indicator stopped working...

reading in changes: 6. MQL5: Fixed processing of click event on a chart.

Now when you click on a graphical object two events are generated at once: CHARTEVENT_OBJECT_CLICK + CHARTEVENT_CLICK, while before there was only one CHARTEVENT_OBJECT_CLICK, which allows to simulate a double click

Will it always be like this or is it a bug?

This was done intentionally.
 

Once again I hit the wall of impossibility,

I need to pass a parameter to the constructor, so that the class will be initialized with certain parameters,

how do I get around this problem? What do you recommend?

 
Urain:

Once again I hit the wall of impossibility,

I need to pass a parameter to the constructor for the class to be initialized with certain parameters,

How do I get around this problem?


к

well, i don't see any other way out

class test{
  private:
    bool inited;
    int value;  
  public:
    void test(){
      inited = false;
    }
    
  bool Set( int passed ){
    value = passed;
    return(true);
  }
  bool Init( int passed ){
    if ( Set( passed ) ){
      inited = true;
      return(true);
    }
    return(false);
  }
  int Get( ){
    if( !inited ){
      Print("Объект неинициализирован");
      return(-1);
    }
    return(value);
  }
};

void OnStart()
  {
  
  
  test var;
  if( !var.Init(1)){
    Print("Ошибка инициализации объекта");
    return;
}
  Print(var.Get());
  
  test var2;
  Print( var2.Get() );
  }

and, of course, you have to put the Inits in the right order in the case of inherited classes

I wish they would write an article about error handling in complex projects,Print and return as here is not the solution.

 
gdtt:

Well, I don't see any other way out.

And, of course, you need to put the Inits in the right order in the case of inherited classes

In general, I would like them to write an article on error handling in complex projects, Print and return as here is not the solution.

That is, to create a pre-constructor that would complete the constructing process, and which in turn displays an initialization flag.

In general, it's a good solution, but there are some inconveniences. We have to poll each function with initialization flag, and with large number of class functions, it's not convenient.

What if we have to change something, all the functions would have to be rewritten.

SZ I have edited the code, fixed the typo.

class test
  {
private:
   bool              inited;
   int               value;
public:
                     test(void){inited=false;};
   bool Set(int passed){value=passed;return(true);};
   bool Init(int passed)
     {
      if(Set(passed))inited=true;    
      return(inited);
     };
   int Get()
     {
      if(!inited)
        {
         Print("Объект неинициализирован");
         return(-1);
        }        
      return(value);
     };
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {

   test var;
   var.Init(1);
   Print(var.Get());

   test var2;
   Print(var2.Get());
  }
 
Urain:

I.e. create a pre-constructor that would complete the construction process, and which in turn sets an initialisation flag.

In general, it's cool, but there are some inconveniences. We will have to query each function for the initialization flag, and with a large number of class functions, this is not convenient.

The code has a large number of class functions, and this is not convenient.

SZ I have edited the code, fixed the oversight.

well, if there was a constructor, it wouldn't mean that the initialization was successful. in any case, you need to verify the fact of initialization

of course you can check it once:

void OnStart()
  {

   test var;
   if( ! var.Init(1)){
     // здесь какято обрабтка
     return;
   };
   Print(var.Get());

   test var2;
   Print(var2.Get());
  }

But if you use your own code, you can make it a rule to check the fact of initialization at the time of call, and if it will be used by others, you cannot write in instructions: "you must use only this construction, otherwise I cannot guarantee for consequences". No, you have to check for initialization in class methods anyway.

 

To the developers.

Immediately after the restart of the new build


PS

Update of terminal installed in different folder was successful, symbols are in list (but there were no open charts before update)...

 

Tell me if this is a bug or if it's not allowed.

ENUM_ORDER_TYPE Signal[21];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   ArrayInitialize(Signal,WRONG_VALUE);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+

It gives an error

'ArrayInitialize' - no one of the overloads can be applied to the function call 
 
sergey1294:

Please tell me if this is a bug or not allowed.

You will get an error


Most likely, the point is that ArrayInitialize() is intended to fill only arrays of a certain type, numeric to be exact (most likely int or double).

Because the array has type ENUM_ORDER_TYPE call of ArrayInitialize will cause an error, saying that this method of call is not allowed.

In my opinion, there are two options in this case:

1. to change the array type ENUM_ORDER_TYPE into int, at the same time taking it into account in the code (at least order types can be easily represented as int);

2. Independently implement "initialization" of the array.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5