Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rack crashing when opening module browser #11

Closed
catronomix opened this issue Jun 20, 2019 · 12 comments
Closed

Rack crashing when opening module browser #11

catronomix opened this issue Jun 20, 2019 · 12 comments
Assignees

Comments

@catronomix
Copy link
Owner

catronomix commented Jun 20, 2019

In latest commit: d13ba25

I thought I did what this means I should do, but still rack crashes...
I put the if (module){...} check around all the occurences where module->... was used :/

1.9
Your ModuleWidgets must gracefully handle a NULL module argument, otherwise Rack will crash when the Module Browser attempts to display your module. createParam() etc. gracefully handle NULL, but if you’ve written custom widgets with a module pointer, make sure you check if (module) ... before accessing the pointer.
@Coirt
Copy link

Coirt commented Jun 20, 2019

https://github.com/catronomix/catro-modulo/blob/1.0.0/src/CatroModulo_CM-4.cpp#L106

There is another way to do it which does draw the display. This is the way I have done it on my own displays

//LCD display
		if (module != NULL){
			NumDisplayWidget *display = new NumDisplayWidget();
			display->box.pos = Vec(7.0 , 21.0);
			display->box.size = Vec(61.1 , 20.4);
			display->value = &module->bpm_display;
			addChild(display);
		}

My source: https://github.com/Coirt/Bark/blob/master/src/Clamp.cpp#L206

@JerrySievert
Copy link
Contributor

JerrySievert commented Jun 20, 2019

you're crashing here:

		if (module){
		recball->recball_x = &module->recball_x;
		recball->recball_y = &module->recball_y;
		}else{
			*recball->recball_x = 178.1;
			*recball->recball_y = 89.5;
		}

in CM3_RecBall you're defining the floats as pointers:

	float *recball_x;
	float *recball_y;

you're making an invalid assignment, and crashing on null.

specifically:

*recball->recball_x = 178.1;
recball->recball is at best NULL, and at worst some random memory location, so setting it to a value is not something you can do.

@catronomix
Copy link
Owner Author

Ok I see... I should put the default values directly in the constructor of CM3_RecBall then. Will try it out.

@catronomix
Copy link
Owner Author

https://github.com/catronomix/catro-modulo/blob/1.0.0/src/CatroModulo_CM-4.cpp#L106

There is another way to do it which does draw the display. This is the way I have done it on my own displays

//LCD display
		if (module != NULL){
			NumDisplayWidget *display = new NumDisplayWidget();
			display->box.pos = Vec(7.0 , 21.0);
			display->box.size = Vec(61.1 , 20.4);
			display->value = &module->bpm_display;
			addChild(display);
		}

My source: https://github.com/Coirt/Bark/blob/master/src/Clamp.cpp#L206
@Coirt , doesn't that cause the widget not to be visible in the preview image generated inside the module browser?

@JerrySievert
Copy link
Contributor

@CATronix gimme a minute and I'll have a PR for you to fix at least this one, should give you a pattern to use.

@JerrySievert
Copy link
Contributor

I opened a PR for the first fix, which should act as a pattern - you'll see an additional change that I made, but you'll want to apply the same if (module) check when you use the component, like you did for the other component. this fixes the issue, but you need to make the change in all places you use these components.

from there, they should show up in the module browser.

@Coirt
Copy link

Coirt commented Jun 21, 2019

@Coirt , doesn't that cause the widget not to be visible in the preview image generated inside the module browser?

It does yes. What I also do is placehold a replica of the display in the panel.svg this will show in the browser when the module loads the widget is drawn on top of it.

https://github.com/Coirt/Bark/blob/master/res/BarkClamp.svg

@catronomix
Copy link
Owner Author

Cool thx, I understand what's happening there I think. Will apply it to everything and test it out :)

@JerrySievert
Copy link
Contributor

it will help you to get a debugger up and running (check out @almostEric's suggestion on the other thread on where to look), it was easy for me to figure out where it was crashing in a debugger, but I'm on macOS, and was running lldb.

@catronomix
Copy link
Owner Author

It's working, thanks so much!
image

@catronomix
Copy link
Owner Author

@JerrySievert 's solution worked a charm! I think I can even revert to limiting the checks on accessing the module pointer so the widgets can still draw, if not, I'll use the mimicking graphics inside the panel background trick :) In any case it's a success :D

@JerrySievert
Copy link
Contributor

awesome! happy to help.

just shout if you need anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants