Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » Property Grid problems with delete Property Store Collapse All
Subject Author Date
Takis Takoglou Apr 8, 2009 - 4:12 AM

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.


 


 


 


 


 


 


 

Takis Takoglou Apr 9, 2009 - 4:30 AM

Thanx for the advice!


I have encountered yet another problem:

I am using  SelectionProperties.ItemInsert()     // SelectionProperties is a CExtPropertyStore variable

to put in the grid several values and categories.



// I insert values into Categories

Category1->ItemInsert (value5);

Category1->ItemInsert (value6);

Category2->ItemInsert (
value7);


// I insert values and categories in the propertystore

SelectionProperties.ItemInsert(value1)

SelectionProperties.ItemInsert(value2)

SelectionProperties.ItemInsert(category1)  //A category containing 2 values

SelectionProperties.ItemInsert(value3)

SelectionProperties.ItemInsert(category2 //A category containing 1 value

SelectionProperties.ItemInsert(value4)





// Insert PropertyStore in the Property Grid

GridControl.PropertyStoreSet(&SelectionProperties);


When the program runs one would expect to see in the propertgrid the following:


value1

value2

+Category1

--value5

--value6

value3

+Category2

--value7

value4


But what i get is:

value1

+Category2

--value7

+Category1

--value5

--value6

value2

value3

value4



I made some further tests and this is the same when i use ItemInsert(valuex, some_value) and the results are the same.

In particular it seems like the Category2 "refuses" to get under value 3 ?

Plz let me know i f i am doing something wrong when using the PropertyStore



Thanx in advance

Stakon.


 


 


 


 


 


 

Technical Support Apr 9, 2009 - 12:29 PM

Please use the CExtPropertyItem::ExpandedSet() method for changing expanded states of property categories and compound property values.

Takis Takoglou Apr 10, 2009 - 5:03 AM

No that was not the issue,


but fortunately i discovered that the problem was fixed with the


GridControl.GetActiveGrid()->m_bSortedCategories = false;

GridControl.GetActiveGrid()->m_bSortedValues  = false;


Apparently the properties were sorted by default and that caused the funny placement...

Technical Support Apr 8, 2009 - 6:45 AM

The CExtPropertyGridCtrl property grid control displays the properties defined in a CExtPropertyStore property store tree. But the property grid uses the property store as externally managed data. The property grid never deletes the property store and its items. Please ensure the property store tree is destroyed after the property grid control. The property grid control should never use the property store which is already deleted. So, if you are changing the property store on the fly and deleting the old property store, then you should assign the NULL property store first (CExtPropertyGridCtrl::PropertyStoreSet()).