ofxUI icon indicating copy to clipboard operation
ofxUI copied to clipboard

removeWidget crash

Open wasawi opened this issue 11 years ago • 13 comments

Hi I was trying to remove widgets and couldnt find the way to do it...

This will crash on the SimpleExample project. Put this line on keyPressed:

case 'r': { gui->removeWidget("RED"); } break;

wasawi avatar Feb 25 '14 21:02 wasawi

Hey there wasawi. Try overwriting the function removeWidget(string) in ofxUICanvas with this: void ofxUICanvas::removeWidget(string _name) { ofxUIWidget *w = getWidget(_name); if(w != NULL) { removeWidget(w); delete w; } }

and take out the delete widget on the last line of removeWidget(ofxUIWidget*)

NHAS avatar Feb 28 '14 23:02 NHAS

Unfortunately this doesn't fix the removeWidgets() (note the 's') crash.

NHAS avatar Feb 28 '14 23:02 NHAS

will address this over the weekend, keep commenting on this thread until its fixed :) thanks guys!

On Fri, Feb 28, 2014 at 3:14 PM, NHAS [email protected] wrote:

Unfortunately this doesn't fix the removeWidgets() (note the 's') crash.

Reply to this email directly or view it on GitHubhttps://github.com/rezaali/ofxUI/issues/184#issuecomment-36404518 .

Skype: syedrezaali Cell: +1.305.773.5983 Site: www.syedrezaali.com

rezaali avatar Feb 28 '14 23:02 rezaali

Thanks very much for the quick reply !

NHAS avatar Feb 28 '14 23:02 NHAS

Thanks! :)

On Fri, Feb 28, 2014 at 3:20 PM, NHAS [email protected] wrote:

Thanks very much for the quick reply ! Also just wanted to make a note that void removeWidget(ofxUIWidget_) also crashs. But if you take the delete widget line out of void removeWidget(ofxUIWidget_) and add it to void removeWidget(string) like so:

void ofxUICanvas::removeWidget(string

_name) { ofxUIWidget *w = getWidget(_name); if(w != NULL) { removeWidget(w); delete w; } }

it doesnt crash

Reply to this email directly or view it on GitHubhttps://github.com/rezaali/ofxUI/issues/184#issuecomment-36404962 .

Skype: syedrezaali Cell: +1.305.773.5983 Site: www.syedrezaali.com

rezaali avatar Feb 28 '14 23:02 rezaali

Thank you very much @NHAS and @rezaali for the fast reply! I still don't understand why removeWidget(ofxUIWidget*) is crashing I have experienced difficulties on cycling through widgets not only to remove them but also to retrieve their value... I will report If i see a consistent bug.

But there must be something more to fix when removing widgets: I'm creating a bunch of dropDownLists with several labels each. When I delete one dropDownList, the labels on the other menus disappear as well. (not all of them but most of them... strange.. )

Well thank you very much for this addon @rezaali, I'm learning a lot with it! I really think you have done the best UI around! I will be working with it for a while so I'll try give you more input.

wasawi avatar Mar 01 '14 01:03 wasawi

@rezaali you said to keep commenting on this till the issue is fixed so here I am, commenting...

NHAS avatar Mar 05 '14 04:03 NHAS

FYI, clearToggles() crashes too because of this. :(

UPDATE: Looks like I can bypass the issue with clearToggles() by removing the last line in: void ofxUICanvas::removeWidget(ofxUIWidget *widget)

comment out: delete widget;

ghost avatar Mar 19 '14 18:03 ghost

thanks for the reminders guys, getting on this this week.

rezaali avatar Mar 19 '14 19:03 rezaali

sorry for the crashes!

rezaali avatar Mar 19 '14 19:03 rezaali

hi reza, see my update above. i appear to be working now. :)

ghost avatar Mar 19 '14 19:03 ghost

I also confirm that commenting out the line ofxUICanvas.cpp:1034 ( i.e. delete widget; ) fixes the crash in DynamicDropDownExample. Thanks to @jasonrwalters

ghost avatar May 14 '14 17:05 ghost

I run into the same problem and can confirm that commenting out the "delete widget;" line from ofxUICanvas::removeWidget() is a quick fix.

I never studied in depth how ofxUICanvas points its widgets, so I'm wondering: is ths a real fix or are we simply leaking memory?

naus3a avatar Aug 01 '14 13:08 naus3a