addListener(this) rvalue error


#1

Firstly I am not that experienced so maybe this is a bit of a dumb question, but have been sent over some code by someone hired to create a plugin, they have gone away on a holiday so I’m unable to get hold of them to try and find a solution for this. so any help would be gratefully appreciated

A couple of days ago the code was working, I am trying to build in Xcode, but am getting the following error.

Cannot initialise a parameter of type ‘juce::Button::Listener *’ with an rvalue of ‘MainViewComponent *’

the line causing the error is

button_barLength->addListener(this);

any help to resolve this would be great.


#2

Can you verify that MainViewComponent inherits juce::Button::Listener?
If your MainViewComponent is created with projucers GUI editor, a save might have overwritten your changes you did to the header file.
To make a Projucer GUI Component inherit from multiple classes, add them in the “class” section into the field “parent classes” separated with commata.


#3

Thanks for that, it’s fixed it.

It seems when ProJucer opens up the .cpp file it is rewriting the header file and removing everything in the the parent classes.