[Kde-bindings] rbuic problem ?

Richard Dale Richard_Dale at tipitina.demon.co.uk
Fri Oct 8 01:26:33 UTC 2004


On Thursday 07 October 2004 22:35, Richard Dale wrote:
> On Thursday 07 October 2004 16:46, Thibauld Favre wrote:
> > Also, I'm not sure that generating *by default* attr_reader attribute
> > accessors for rbuic generated class is a good idea. attr_reader is useful
> > for certain things but it should not be generated automatically as it
> > basically breaks the encapsulation paradigm of OOP.
> > If I want some of my instances variables to be reachable outside my
> > class, I can do it myself by specifying exactly which ones I want to be
> > accessible. I don't know what the majority is thinking but I'm really for
> > removing this feature. Or maybe just put it as an rbuic option, something
> > like
> > "--make-variables-visible" as I must admit it can be useful sometimes if
> > you design it like this and don't want to have to manually add an
> > attr_reader for each of your instance variables.
>
> The warnings are when there is an existing method with the same name at the
> attribute accessor. Not all the instance variables had attribute accessors
> generated - the layout managers didn't for instance. I think the main
> widgets should be visible from outside, I don't think that breaks
> encapsulation. But if there is an attr_reader method, a method with the
> same name shouldn't be generated to suppress the warning.
I've tried generating a C++ .h and .cpp file from ContratsDlgUI.ui and compile 
it, and I get:

ContratsDlgUi.h:143: declaration of `virtual void ContratsDlgUi::nextExp()'
ContratsDlgUi.h:72: conflicts with previous declaration `
   KPushButton*ContratsDlgUi::nextExp'
ContratsDlgUi.h:144: declaration of `virtual void ContratsDlgUi::nextSup()'
ContratsDlgUi.h:104: conflicts with previous declaration `
   KPushButton*ContratsDlgUi::nextSup'
ContratsDlgUi.h:145: declaration of `virtual void ContratsDlgUi::nextProd()'
ContratsDlgUi.h:134: conflicts with previous declaration `
   KPushButton*ContratsDlgUi::nextProd'

As opposed to the rbuic:

On Thursday 07 October 2004 16:46, Thibauld Favre wrote:
> ./ContratsDlgUi.rb:836: warning: method redefined; discarding old nextExp
> ./ContratsDlgUi.rb:840: warning: method redefined; discarding old nextSup
> ./ContratsDlgUi.rb:844: warning: method redefined; discarding old nextProd

So I'm not sure this is a bug in rbuic because you get a compile error in C++ 
generated code too for the same reason. I think Qt Designer should prevent 
you from defining an instance variable and slot with the same name.

-- Richard



More information about the Kde-bindings mailing list