Good day
I am trying to find a way to avoid memory leaks when using your propertygrid.
My code regarding the problem is:
1)IF I DO THE FOLLOWING THE PROGRAM SHOWS THE PROPERTIES THE FIRST TIME BUT WHEN IT IS CALLED AGAIN TH PROGRAM CRASHES.
IF I REMOVE THE LINE "this->MyPropStore->ItemRemove(0, -1);" THE PROGRAM WORKS BUT AS YOU CAN GUESS THE SAME CATEGORY "Dimensions" SHOWS MANY TIMES
SO I SUSPECT IT’S SOMETHING WITH THE PROPERTY STORE...".MyPropStore"
IS THIS THE PROBLEM? PERHAPS I SHOULD SET THE PROPERTY STORE TO NULL? THEN AGAIN SOME MEMORY ISSUES ARISE...
void MyDialog::LoadPropertyGrid()
{
if (MyPropStore)
this->MyPropStore->ItemRemove(0, -1); // Remove the previous items in the property store
Property *prop = &this->Prop; //bind the properties
CExtPropertyCategory *Dimensions = new CExtPropertyCategory(); //Create a category
LayerProp *Layer = new LayerProp(prop); //create a value
Dimensions->ItemInsert (Layer); //insert it in the category
this->MyPropStore.ItemInsert(Dimensions, -1) //Store the category in the dialog variable MyPropStore
GridControl.PropertyStoreSet(&this->MyPropStore); //Insert the dialog variable property store in the grid control
}
2)IF I DO THE FOLLOWING THE PROGRAM WORKS FINE, BUT HAS TONS OF MEMORY LEAKS
I HAVE TRIED TO REDUCE THEM, BUT I AM UNABLE TO FIND A NICE WAY TO DELETE THE LOCALY-CREATED POINTERS
void MyDialog::LoadPropertyGrid()
{
if (MyPropStore)
this->MyPropStore->ItemRemove(0, -1); // Remove the previous items in the property store
Property *prop = &this->Prop; //bind the properties
CExtPropertyStore *PropStore = new CExtPropertyStore;
CExtPropertyCategory *Dimensions = new CExtPropertyCategory(); //Create a category
LayerProp *Layer = new LayerProp(prop); //create a value
Dimensions->ItemInsert (Layer); //insert it in the category
PropStore.ItemInsert(Dimensions, -1) //Store the category in the local variable PropStore
GridControl.PropertyStoreSet(PropStore); //Insert the localy created property store in the grid control
}
Thanx in advance for any help you can provide
Stakon.