[Kde-bindings] SMOKE copy constructor problem
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Tue Jun 8 05:15:34 UTC 2004
I've had a problem with copy constructors with SMOKE. A copy constructor is
added for a Smoke class, even if the original C++ class didn't have one,
according to the following rule:
# If the class has no explicit copy constructor, and it can be copied,
# generate the copy constructor.
if ( !$classNode->{HasCopyConstructor}
&& $classNode->{CanBeCopied}
&& $classNode->{CanBeInstanciated} ) {
...
}
QListViewItem and KListViewItem have these additional constructors, but it
causes problems with ruby. I tried a QListViewItem example in PerlQt and that
worked ok, even though it found ambiguous method calls:
perl listview.pm
Ambiguous method call for :
QListViewItem::QListViewItem(QListViewItem)
Candidates are:
QListViewItem* QListViewItem::QListViewItem(QListViewItem*)
QListViewItem* QListViewItem::QListViewItem(const QListViewItem&)
Taking first one...
In ruby it fails and won't run because ambiguous calls are an error.
But both ruby and perl won't work with KListViewItems because the copy
constructor expects a 'const KListViewItem&' argument, while all the normal
constructors expect a parent QListViewItem to be passed. So the copy
constructor will get called instead of the correct one that expects a parent.
I would expect this PerlKDE code won't work:
my $kListView = KDE::ListView(this, "");
$kListView->addColumn("Content");
$kListView->setSorting(-1);
my $item0 = KDE::ListViewItem($kListView);
$item0->setText(0, "Root");
$item0->setOpen(1);
my $item3 = KDE::ListViewItem($item0);
$item3->setText(0, "Level 1, Third Item");
my $item1 = KDE::ListViewItem($item0);
$item1->setText(0, "Level 1, First Item");
my $item2 = KDE::ListViewItem($item0, $item1);
$item2->setText(0, "Level 1, Second Item");
I haven't got PerlKDE setup, so I can't try it out and confirm, but I think
these autogenerated copy constructors should be removed from the Smoke
runtime as they're more trouble than they're worth.
-- Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: listview.pm
Type: text/x-perl
Size: 179 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20040608/c8afe23d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyListView.pm
Type: text/x-perl
Size: 846 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20040608/c8afe23d/attachment-0001.bin>
More information about the Kde-bindings
mailing list