The module browser draws the Widget but it does not instantiate the Module. I had a lot of module browser crashes when migrating my code, and putting a check in all the draw methods eg: if(module) {...} fixed the crash.
could you perhaps post a link to an example?, because i have looked and don’t see any reference to a pointer to the module in the modules i have found that crash so far.
Here’s a random example, from mscHack’s Envy-9. I’ve stripped out a lot of code to leave just the lines that illustrate the suggested fix:
struct SEQ_Envelope_8_Widget : ModuleWidget
{
SEQ_Envelope_8_Widget( SEQ_Envelope_8 *module )
{
setModule(module);
if( module ) // <--- This is the important piece. Without it...
{
module->m_bInitialized = true; // ...this will crash.
}
}
};
The problem that people are suggesting you have is that you’re not checking for the module pointer being valid before following it.
(Note that ModuleWidget has a member variable called module as well, so this code could equally be elsewhere in your ModuleWidget, not just in the constructor.)
Ok 21 of 26 modules loading and not crashing the browser.
4 out of the 5 remaining modules would seem to have some pointer to the module issue but I don’t see any explicit reference that looks like the way it has been described. I’ll have a look at some code in other modules and see if i can nut it out.
I have migrated all of the modules @chrtlnghmstr has done , i’ll work on adding his bug fixes and skin changes when i get the last few modules working.
If anyone is in a desperate hurry for the 21 working modules i can post a pre release windows binary for use in the meantime.
There is no check if the module exists. I’d recommend
add the MentalCounters module as a member variable of the NumberDisplayWidget3
instantiate this member in the ModuleWidget code
in the draw method of NumberDisplayWidget3, check for the existence of the module before attempting to read module->count_limit
The first module I made was basically a copy of your Patch Matrix, plus scenes. I started from your code, including the NumberDisplayWidget3 and I kept the name! Check out line 317 and beyond to see an example of what I’m suggesting:
I think i see the problem, i was looking in the draw method not the widget constructor itself, derp.
Scenes for the switch matrix? great idea.
I’m working on another set of modules and it has a development of the switch matrix in it.
I’ve added a switch to each vertical channel that changes the mode so it can function as an or gate, a selector or a summing mixer, it superceeds the old switch matrix, adding scenes to that would be a useful feature.
I’ve looked at your code and see what you have changed and have added that to the code but I’m getting errors about it not finding the module
your instructions are in computer gobble-de-gook speak and i don’t understand what you mean them
sorry.
src/MentalCounters.cpp: In member function ‘virtual void NumberDisplayWidget3::draw(const rack::widget::Widget::DrawArgs&)’:
src/MentalCounters.cpp:140:8: error: ‘module’ was not declared in this scope; did you mean ‘modfl’?
140 | if(module) {
| ^~~~~~
| modfl
src/MentalCounters.cpp: In constructor ‘MentalCountersWidget::MentalCountersWidget(MentalCounters*)’:
src/MentalCounters.cpp:176:11: error: ‘struct NumberDisplayWidget3’ has no member named ‘module’
176 | display->module = module;
| ^~~~~~
src/MentalCounters.cpp:193:13: error: ‘struct NumberDisplayWidget3’ has no member named ‘module’
193 | display_2->module = module;
Great to hear! Good luck with the rest of the modules, I’m looking forward to using them again. As I mentioned, I got my start developing for Rack by reading/understanding and modifying your code - I’m very glad that I could return the favor somewhat.
Thanks man, I’m flattered, glad to share, this is how we make a better world, by making things and sharing them freely without concern for financial gain.
That my code has been used and copied and added to is a real buzz for me, I really didn’t expect it would be so widely copied and used as a reference.
i don’t think the 3 way switch is actually needed, if you can detect whether something is connected to the select input then you can just ignore the state of the switch when something is connected. I don’t think it was possible to detect whether an input was connected or not when i wrote it originally.