cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic vector in custom container

feelingoflight
Associate III

Hello.

I'm trying to create custom container with any number of elements.

I created custom container which contains Scrollable Container and List Layout.

I want to dynamically add elements to List Layout. Elements are simple containers which contains text area with 1 wildcard.

I dont know how many elements can be added in my custom container.

But if i use std::vector in my custom container to add elements with push_back, i always get hardfault in tick() of backPorchExited() (HAL.hpp).

But if i allocate, for example, 20 elemnts of vector in constructor of custom container, and then add them in List Layout, everything is going well.

What is the problem and what is the right way to do what i want?

Thank you.

HardFault code example:

class ItemsListContainer : public ItemsListContainerBase

{

public:

 ItemsListContainer();

 virtual ~ItemsListContainer() {}

 virtual void initialize()

{

 ItemsListContainerBase::initialize();

}

 virtual void add_item(const char* a_item_text)

{

a_items.push_back(TextContainer());

list_layout.add(a_items.back());

list_layout.invalidate();

}

private:

 std::vector<TextContainer> a_items;

}

0 REPLIES 0