Components aren't showing, segfaults in projucer JIT

#1

Hi all,

I’m sure I’m missing something simple, but I can’t figure it out. I’ve got a couple components that aren’t showing. (Using addAndMakeVisible() and setting bounds in resized(), of course.)

So I’ve got a component that takes up the entire window, with two child components each of which have some nested child components. When I go to view any of the child components (all the way to the bottom) using Projucer’s JIT compiler, they’re all displaying correctly. But when I try to view the parent component, I’m getting segfaults (sometimes) and the children aren’t visible at all. Compiling (Xcode) doesn’t cause any crashes or noticeable errors while debugging, but the components still aren’t showing.

Any ideas as to what might be causing this?

0 Likes

#2

segfaults usually mean you’re using a pointer that is pointing to garbage. Don’t use pointers to store your components if you can avoid it. just add them as regular member variables.

0 Likes

#3

I’ve got an OwnedArray that holds pointers to dynamically created child components, but I’m doing checks to ensure that I don’t try to access invalid pointers in the array. That’s the only pointers I’ve got implemented in these classes, so maybe it’s something in juce code that I’m doing wrong?

The component that holds the OwnedArray (and any children added to the array) is set as the viewed component in a viewport. The component creates a new component in the array and adds it as a child when it receives a ValueTreeChildAdded callback… in the JIT, I can hit the button that does this and see that the component gets larger to accommodate the added child components (more room to scroll in the viewport, etc.), but the component in the viewport (and its children) isn’t being painted at all, even when it has no children in the array when it should just be painting a background and a border. Similarly, when compiled, nothing is being painted.

At a show right now; I could post some code later tonight when I’m back at my computer, if anyone could help me make sense of this issue. (Tho I hate to be like “hey babes, dig thru my code with me.” Lol)

0 Likes

#4

no one can help you without seeing some code. but only post the relevant bits. And also, be sure to debug it via breakpoints. if you get a crash at function B, add breakpoints to all of the places that call it and step through to see what happens that is making your pointer be invalid.

0 Likes