Re: Missing function in Glib::Property ?

Am Freitag 26 September 2008 schrieben Sie:
> On Thu, 2008-09-25 at 00:51 +0200, Johannes Lorenz wrote:
> > Hi,
> >
> > I do not know if this is really a bug, but I better tell you of it. It
> > might also be a fault of mine (sry).
> >
> > I am writing my own cell renderer (inherited from CellRenderer) and want
> > to create a read only property, but it does not work.
> >
> > Glib::Property< MultipleChoiceString > property_mcs_; // property
> > declaration Glib::PropertyProxy< MultipleChoiceString > property_mcs() {
> > return property_mcs_.get_proxy(); } // works
> > Glib::PropertyProxy_ReadOnly< MultipleChoiceString > property_mcs() const
> > { return property_mcs_.get_proxy(); } // error
> >
> > The third line causes an error because calling get_proxy on the property
> > does not keep the property constant.
> Do you mean a compilation error? Does the mutable keyword help?

It was a real compiler error. Mutable would help (even if it would not be a good way of coding IMHO). Using mutable, I can add a const to the function returning Glib::PropertyProxy_ReadOnly and the const error disappears.

However. the problem is still, that the get_proxy() function returns a PropertyProxy, which cannot be casted to PropertyProxy_ReadOnly, because they only have the same base, but none inherits from the other. gcc 4.2.1 says:

gui_gtkmm/opt_treeview.h:64: error: conversion from ‘Glib::PropertyProxy<MultipleChoiceString>’ to non-scalar type ‘Glib::PropertyProxy_ReadOnly<MultipleChoiceString>’ requested

I think, a constant get_proxy function should be added to properties if there is no solution to this cast problem.

> >  Maybe, one should add a function for a Property that returns a
> > PropertyProxy_ReadOnly? How else could this problem be solved?
> >
> > Thank you for answers in advance,
> > Johannes

Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen:

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]