Trying to create a resizable AudioProcessorEditor - having issues

This is my first JUCE project.  I would like to create a resizable AudioProcessorEditor window.


In my PluginEditor.h file I have created the following private pointers:

    ResizableCornerComponent* resizeCorner;
    ComponentBoundsConstrainer* resizeConstrainer;

And in my PluginEditor.cpp file I have the following in the constructor:

    resizeConstrainer = new ComponentBoundsConstrainer();
    resizeCorner = new ResizableCornerComponent(this, resizeConstrainer);
    //resizeConstrainer->setSizeLimits(200, 100, 800, 600);

... and the following in the resized() method:

resizeCorner->setBounds(10, 20, 30, 40);

My DAW is BitWig.  When I load the VST, it crashes.  However it crashes so quickly that I have no opportunity to attach my IDE's debugger, so I can't set breakpoints or debug it.


Does anybody either (1) see anything wrong with my code above?  or (2) have any advice for debugging crashes on startup (with no opportunity to attach debugger)?


My project compiles/loads/runs just fine if I leave out the resizing code, so I know it at least works without it.


I have read the following post, but didn't find anything useful:

1 Like

the problem is that you create some stuff and never delete it. 


ResizableCornerComponent* resizeCorner;
ComponentBoundsConstrainer* resizeConstrainer;


ScopedPointer<ResizableCornerComponent> resizeCorner;
ScopedPointer<ComponentBoundsConstrainer> resizeConstrainer;

you also want to change the resize to somehting like that :
resizeCorner->setBounds (getWidth()-30, getHeight-40, 30, 40);

have a look at the JuceDemoPlugin, it's all in there I think

Hmmm, I made those changes and still experience a crash.  Any way to debug it?  I don't have the ability to attach my debugger, since it crashes immediately upon running.  Is there a best-practice way of getting the code to "pause" for a while so I can attach my debugger?


Thanks for your help!

well, you should configure your ide to build and run the executable directly, so that you don't have to attach the debugger afterward.

But this is a VST (dll) which is loaded by a DAW.  I don't know of any way to launch it as an independent executable.

you have to configure you ide to launch the DAW. something like :

xcode : product->scheme->edit scheme : executable

visual : debug->properties->debug->command

try putting the resize call AFTER addAndMakeVisible.  

When you say "the resize call", are you talking about the call to setSizeLimits() ?


Has someone gotten something similar to work?

…gotten what to work?
a) attaching a debugger?
b) a resizable AudioProcessorEditor?

both yes btw.

The issue regarding the title of the post, so b) A resizable AudioProcessorEditor. How did you go about it?

…can you describe the problems you are having?

Well, I want to be able to resize my AudioProcessorEditor so that I can allow different sizes for my plugin. There is no good example left in the demo plugins on how to do this so I went here to look. The code in this post gives me the same seg fault as @loneboat describes above.

I figure that you have to include two new member variables

ScopedPointer<ResizableCornerComponent> resizeCorner;
ScopedPointer<ComponentBoundsConstrainer> resizeConstrainer;

in the PluginEditor which you then instantiate in the constructor function. This works when run after compiling. When I do a setBounds call inside the Editor resized function the program however crashes.

I did this almost a year ago and I used that strategy. You see it here in my layout class:

But time has passed, there is now a built in constrainer you can use:
AudioProcessorEditor::setResizable (true, true);

Maybe try that one, before you add your own constrainer…