Const' is inaccessible


#1

error: void juce::MessageListener::postMessage(juce::Message *) const’ is inaccessible.

within this context:
void ViewComponent::handleMessage(const Message & message)
{
// Nothing to handle within now. Pass it to parent.
const BubbleMessage* pMessage =
dynamic_cast<const BubbleMessage*>(&message);

    if(( NULL != pMessage) && (NULL != getParentComponent()) )
    {      
        // The old message will be deleted, so create a new one.
             BubbleMessage *pNewMessage = pMessage->createCopy();
/*error in this line:*/ getParentComponent()->postMessage(pNewMessage);
    }

}

class BubbleMessage : public Message
{
public:
BubbleMessage(int x, int y, const String & strMessage);
virtual ~BubbleMessage(void);

    int getX() const { return intParameter1; }
    int getY() const { return intParameter2; }
    const String& getMessage() const { return m_strMessage; }
 
    BubbleMessage* createCopy() const;
    //Message * createCopy() const;
private:
    String m_strMessage;

};


#2

What my understanding on this is :
getParentComponent() returns the pointer to Component.
and
Component inherit MessageListener as protected.
so that postmessage() is not accessible.

But the same code is working on VC++ 2008.

I am not able to figure it out .
pls help :?: :?:


#3

Presumably you’re using an old version, because the Component class no longer derives from MessageListener at all.

If you need to receive message objects, you should implement your own MessageListener class - and I’d strongly recommend that you do so by composition of a private dedicated MessageListener class, rather than by making your component handle it.


#4

Thanks for the information.