Skip Menu |

This queue is for tickets about the Prima CPAN distribution.

Report information
The Basics
Id: 56238
Status: resolved
Priority: 0/
Queue: Prima

People
Owner: Nobody in particular
Requestors: wb [...] sao.pl
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: prima [...] prima.eu.org
Subject: Is it bug in Prima::Notebooks?
Date: Sat, 3 Apr 2010 00:00:35 +0200
To: bug-Prima [...] rt.cpan.org
From: Waldemar Biernacki <wb [...] sao.pl>
Prima is really very good. Thank you Dmitry and other authors! I found some problem with the module Prima::Notebooks.: there in the module Prima::Notebooks is a function "move_widget", which in fact results in removing all existing widgets in a notebook page and saving only the last widget. I think the result should be simple to add additional widgets to the page. Details: sub move_widget { my ( $self, $widget, $newPage) = @_; my ( $page, $number) = $self-> contains_widget( $widget); return unless defined $page; @{$self-> {widgets}-> [$newPage]} = splice( @{$self-> {widgets}-> [$page]}, $number, 1); $self-> repaint if $self-> {pageIndex} == $page || $self-> {pageIndex} == $newPage; } but I think it should be as follows: sub move_widget { my ( $self, $widget, $newPage) = @_; my ( $page, $number) = $self-> contains_widget( $widget); return unless defined $page; ###################### instead lines: # @{$self-> {widgets}-> [$newPage]} = # splice( @{$self-> {widgets}-> [$page]}, $number, 1); ###################### should be these lines: my @prev_widgets = @{$self-> {widgets}-> [$newPage]}; @{$self-> {widgets}-> [$newPage]} = ( @prev_widgets, splice( @{$self-> {widgets}-> [$page]}, $number, 1)); ################################################## $self-> repaint if $self-> {pageIndex} == $page || $self-> {pageIndex} == $newPage; } There should be also revisted remain functions in the module. My system: # Prima 1.28 # perl -v This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi (with 40 registered patches, see perl -V for more detail) Copyright 1987-2009, Larry Wall # uname -a Linux borsuk 2.6.32-2-amd64 #1 SMP Fri Feb 12 00:01:47 UTC 2010 x86_64 GNU/Linux Regards! Waldemar Biernacki
Hi Waldemar, Yes, I think you're right, the code in question is incorrect. Did you test the proposed patch, does it work for you? If yes, I'm going to commit a shorter version: return unless defined $page and $page != $newPage; push @{$self-> {widgets}-> [$newPage]}, splice( @{$self-> {widgets}-> [$page]}, $number, 1); Thanks again! /dk
Subject: Re: [rt.cpan.org #56238] Is it bug in Prima::Notebooks?
Date: Sat, 3 Apr 2010 14:23:57 +0200
To: bug-Prima [...] rt.cpan.org
From: Waldemar Biernacki <wb [...] sao.pl>
Dnia sobota 03 kwiecień 2010 o 00:21:33 napisałeś: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=56238 > > > Hi Waldemar, > > Yes, I think you're right, the code in question is incorrect. > Did you test the proposed patch, does it work for you?
Yes I did, it works. Show quoted text
> If yes, I'm going to commit a shorter version: > > return unless defined $page and $page != $newPage; > push @{$self-> {widgets}-> [$newPage]}, splice( @{$self-> {widgets}-> > [$page]}, $number, 1);
Your version of the patch is better and also working :) Next related issue. There is a function "delete_page": Original definition: sub delete_page { my ( $self, $at, $removeChildren) = @_; $removeChildren = 1 unless defined $removeChildren; $at = -1 unless defined $at; $at = $self-> {pageCount} - 1 if $at < 0 || $at >= $self-> {pageCount}; my @r = splice( @{$self-> {widgets}}, $at, 1); $self-> {pageCount}--; $self-> pageIndex( $self-> pageIndex ); if ( $removeChildren) { $$_[0]-> destroy for @{$r[0]}; } } I dont see any widgets destroying in the "if ( $removeChildren ) {...} " condition. I put another destroyin and it works. I do not know the subtils of such a construction like "$$_[0]-> destroy for @{$r[0]};" and really dont know why it does not work for me. My proposition is as follows (I add some new lines here, please read lower about it): sub delete_page { my ( $self, $at, $removeChildren) = @_; $removeChildren = 1 unless defined $removeChildren; $at = -1 unless defined $at; $at = $self-> {pageCount} - 1 if $at < 0 || $at >= $self-> {pageCount}; if ( $removeChildren) { for ( $self-> widgets_from_page( $at ) ) { $_-> destroy; } } for ( my $i = $at; $i < $self-> {pageCount} - 1; $i++ ) { for ( $self-> widgets_from_page( $i + 1 ) ) { $self-> move_widget( $_, $i ); $self-> widget_set( $_, visible => 1, autoEnableChildren => 1, enabled => 1, geometry => gt::Default, ); } } #1 my @r = splice( @{$self-> {widgets}}, $at, 1); $self-> {pageCount}--; $self-> pageIndex( $self-> pageIndex ); #2 if ( $removeChildren) { #3 $$_[0]-> destroy for @{$r[0]}; #4 } } I put another lines instead of existing because of the following reasons. I understand that @r should catch an array of $at'th page widgets to be destroy at lines $2-#4, and this splice operation should clear the $at'th element of @{$self-> {widgets}} and immidiately shift all upper page widgets one position left. But for the reasons unknown to me it does not work. Therefore I wrote my lines. Maybe I have wrong vision what the function do so please excuse me. I would be very glad if the problem could be clarify to me as I have big hope with using Prima library. Thank you Dmitry!
changes committed, will appear in 1.29