[Kde-perl] Memory fault when inserting QTableItem into QTable
Oliver Kreuer
okreuer at PSI.de
Fri Jul 9 10:33:29 CEST 2004
Hello Richard,
I appended two example scripts with input files.
Script "table_fault.pl" reproduces the memory fault whereas
"table_ok.pl" contains a work around. The work around is not very
pleasant so I'm still interested why this memory fault occurs.
Due to bug #924345 the work around has to use takeItem insted of removeRow.
Oliver
Richard Dale wrote:
> On Monday 05 July 2004 14:42, Oliver Kreuer wrote:
>
>>Hello,
>>
>>I've written the following small Perl/Qt program:
>>
>>...
>>table = Qt::Table(frame6, "table");
>>table->setNumRows( int(0) );
>>table->setNumCols( int(0) );
>>table->setReadOnly( 1 );
>>table->setSelectionMode( &Qt::Table::NoSelection() );
>>table->setLeftMargin(0);
>>...
>>open (FILE,"table_example.one") or die;
>>while (defined (my $line = <FILE>))
>>{
>> chomp($line);
>> push (@lines,$line);
>>
>> clearTable();
>>
>> table->setNumCols(1);
>> table->horizontalHeader()->setStretchEnabled(1);
>> table->horizontalHeader()->setLabel(0,"Eine Spalte",-1);
>> table->setNumRows(scalar(@lines));
>>
>> my $row = 0;
>> foreach my $element (@lines)
>> {
>>
>>table->setItem($row,0,Qt::TableItem(table,&Qt::TableItem::Never,"
>>$element"));
>> $row++;
>> }
>>}
>>
>
> Shouldn't the code above look something like this? I'm not sure if that is the
> cause of the problem - would you be able to post a complete program/input
> file that reproduces the bug?
>
> open (FILE,"table_example.one") or die;
> while (defined (my $line = <FILE>))
> {
> chomp($line);
> push (@lines,$line);
>
>
> }
> clearTable();
> table->setNumCols(1);
> table->horizontalHeader()->setStretchEnabled(1);
> table->horizontalHeader()->setLabel(0,"Eine Spalte",-1);
> table->setNumRows(scalar(@lines));
>
> my $row = 0;
> foreach my $element (@lines)
> {
>
> table->setItem($row,0,Qt::TableItem(table,&Qt::TableItem::Never,"
> $element"));
> $row++;
> }
> _______________________________________________
> Kde-perl mailing list
> Kde-perl at kde.org
> https://mail.kde.org/mailman/listinfo/kde-perl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: table_example.one
Url: http://mail.kde.org/pipermail/kde-perl/attachments/20040709/cbc5f2ac/table_example-0002.cc
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: table_example.two
Url: http://mail.kde.org/pipermail/kde-perl/attachments/20040709/cbc5f2ac/table_example-0003.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: table_fault.pl
Type: application/x-perl
Size: 4095 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-perl/attachments/20040709/cbc5f2ac/table_fault-0001.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: table_ok.pl
Type: application/x-perl
Size: 4735 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-perl/attachments/20040709/cbc5f2ac/table_ok-0001.pl
More information about the Kde-perl
mailing list