rezaali / ofxUI

[DEPRECATED] UI Addon for openFrameworks
http://www.syedrezaali.com/#/ofxui-project-showcase/
519 stars 197 forks source link

removeWidget crash #184

Open wasawi opened 10 years ago

wasawi commented 10 years ago

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;

NHAS commented 10 years ago

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 commented 10 years ago

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

rezaali commented 10 years ago

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 notifications@github.com 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

NHAS commented 10 years ago

Thanks very much for the quick reply !

rezaali commented 10 years ago

Thanks! :)

On Fri, Feb 28, 2014 at 3:20 PM, NHAS notifications@github.com 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

wasawi commented 10 years ago

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.

NHAS commented 10 years ago

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

ghost commented 10 years ago

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;

rezaali commented 10 years ago

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

rezaali commented 10 years ago

sorry for the crashes!

ghost commented 10 years ago

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

ghost commented 10 years ago

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

naus3a commented 10 years ago

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?