[Kde-perl] Can't debug PQT app ...
Germain Garand
kde-perl@mail.kde.org
Sun, 22 Dec 2002 03:01:12 +0000
Le Jeudi 19 D=E9cembre 2002 08:51, Ashley Winters a =E9crit :
> --- Germain Garand <germain@ebooksfrance.com> wrote:
> > Properly informed people could even turaround by assigning
> > this->{'foo'}
> > instead of foo...
> > That one will do great as a new FAQ entry :-D
>
> Heh. If you want to really get rid of lvalue subs, it's perfectly
> possible.
Hey I certainly didn't mean to criticize attributes : they are absolutely=
=20
fantastic, you had a wonderful idea - it's the thing I like better in the=
new=20
syntax !
With them you've got a perfect view, at first glance, of what belongs to =
the=20
object... gorgeous.
Though tied scalar would perform well, I think they lack this immediately=
=20
identifiable aspect.... it would be too bad.
Anyway, after digging in perl source, I've found a very simple way to res=
tore=20
a correct behaviour for all debuggers :
setting CvNODEBUG_on() in installattribute is all what we needed :-)
Problem was : since every call to a sub (even lvalue) is redirected to th=
e sub=20
DB::sub defined in the debugger, the LVALUE context was lost.
I've just done a whole debugging session with ptkdb (great stuff..should =
be=20
rewritten with Qt, but great stuff nevertheless)
Cheers,
Germain
> Here goes:
>
> package Qt::attr::tie;
>
> # example class -- never tried
>
> sub TIESCALAR {
> # for something like use Qt::attr qw(name)
> # call like tie $foo, 'Qt::attr::tie', 'name'
> my $class =3D shift;
> my $attr =3D shift;
> return bless \$attr, $class;
> }
>
> sub FETCH {
> my $self =3D shift;
> my $this =3D getThis();
> return $this->{$$self};
> }
>
> sub STORE {
> my $self =3D shift;
> my $val =3D shift;
> my $this =3D getThis();
> $this->{$$self} =3D $val;
> }
>
> Even $this could be supported. Here's a short example from the
> tutorials:
>
> # ...
> use Qt::attr qw(slider label);
> # ...
> sub init {
> my $lcd =3D Qt::LCDNumber(2, $this, "lcd");
> $slider =3D Qt::Slider(&Horizontal, $this, "slider");
> $slider->setRange(0, 99);
> # ...
> }
>
> I propose Qt::attr for the "new" version. I'm not sure if Qt::attr
> would introduce a tied $this by default, since "this" wouldn't be an
> lvalue sub anymore.
>
> Pretty easy to do. Anyone have programming time to burn? :)
>
> Ashley Winters
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@mail.kde.org
> http://mail.kde.org/mailman/listinfo/kde-perl