[Kde-bindings] Qt::StandardItemModel#item_prototype= causes crashe in qtruby

Richard Dale rdale at foton.es
Tue Apr 14 16:38:23 UTC 2009


On Friday 10 April 2009 08:58:37 Stefano Crocco wrote:
> Using Qt::StandardItemModel#item_prototype= and
> Qt::StandardItemModel#horizontal_header= causes ruby to crash. Here's the
> code causing the crash:
>
> require 'Qt4'
>
> app = Qt::Application.new []
> m = Qt::StandardItemModel.new
> proto = Qt::StandardItem.new ''
> proto.flags = Qt::ItemIsEnabled
> m.set_item_prototype proto
> m.horizontal_header_labels = %w[x y]
> app.exec
>
> If I comment out the call to horizontal_header_labels=, everything works
> correctly.
>
> Here's a backtrace from the crash
>
> #0  QStandardItemModel::setHorizontalHeaderLabels (this=0x820a8a8,
> labels=@0x8213270) at itemviews/qstandarditemmodel.h:254 #1  0xb783f6c8 in
> xcall_QStandardItemModel (xi=<value optimized out>, obj=0x820a8a8,
> args=0x8213218) at
> /var/tmp/paludis/kde-base-smoke-scm/work/smoke_build/smoke/qt/x_14.cpp:7507
> #2  0xb75d30f7 in QtRuby::MethodCall::callMethod (this=0xbfd6c2c8) at
> /home/stefano/tmp/kdebindings/ruby/qtruby/src/marshall_types.h:148 #3 
> 0xb75d0eb8 in QtRuby::MethodCallBase::next (this=0xbfd6c2c8) at
> /home/stefano/tmp/kdebindings/ruby/qtruby/src/marshall_types.cpp:458 #4 
> 0xb75a2ece in marshall_QStringList (m=0xbfd6c2c8) at
> /home/stefano/tmp/kdebindings/ruby/qtruby/src/handlers.cpp:1220 #5 
> 0xb75d0efe in QtRuby::MethodCallBase::next (this=0xbfd6c2c8) at
> /home/stefano/tmp/kdebindings/ruby/qtruby/src/marshall_types.cpp:454 #6 
> 0xb7598811 in method_missing (argc=2, argv=0xbfd6c6c0, self=3060539400) at
> /home/stefano/tmp/kdebindings/ruby/qtruby/src/Qt.cpp:888 #7  0xb7fa4235 in
> call_cfunc (func=0xb75983f0 <method_missing(int, unsigned long*, unsigned
> long)>, recv=3060539400, len=136393392, argc=2, argv=0x8213270) at
> eval.c:5749 #8  0xb7faf018 in rb_call0 (klass=3083401740, recv=3060539400,
> id=4057, oid=4057, argc=2, argv=0xbfd6c6c0, body=0xb7c8f8e0, flags=<value
> optimized out>) at eval.c:5904 #9  0xb7faf159 in rb_call (klass=3083401740,
> recv=3060539400, mid=4057, argc=2, argv=0xbfd6c6c0, scope=1, self=6) at
> eval.c:6151 #10 0xb7fafa35 in rb_funcall2 (recv=136393392, mid=4057,
> argc=2, argv=0xbfd6c6c0) at eval.c:6287 #11 0xb7fb51be in method_missing
> (obj=3060539400, id=4994062, argc=1, argv=0xbfd6c7b0, call_status=0) at
> eval.c:5729 #12 0xb7faf24b in rb_call (klass=3083530020, recv=3060539400,
> mid=19508, argc=1, argv=0xbfd6c7b0, scope=0, self=3084507480) at
> eval.c:6130 #13 0xb7faa3fb in rb_eval (self=3084507480, n=<value optimized
> out>) at eval.c:3474 #14 0xb7fba7a3 in ruby_exec_internal () at eval.c:1641
> #15 0xb7fba7e3 in ruby_exec () at eval.c:1661
> #16 0xb7fba818 in ruby_run () at eval.c:1671
> #17 0x080487a5 in main (argc=136393392, argv=0xb7ee116b, envp=0x7000000) at
> main.c:48
The crash is because you need to implement the clone() method in your 
Qt::StandardItem:

require 'Qt4'

class MyStandardItem < Qt::StandardItem
  def clone
    return MyStandardItem.new('')
  end
end

app = Qt::Application.new []
m = Qt::StandardItemModel.new
proto = MyStandardItem.new ''
proto.flags = Qt::ItemIsEnabled
m.set_item_prototype proto
m.horizontal_header_labels = %w[x y]
app.exec

-- Richard




More information about the Kde-bindings mailing list