[Kde-bindings] QtRuby: segfault when using Qt::ForegroundRole

Robert Riemann robert.riemann at physik.hu-berlin.de
Mon Jul 26 11:36:20 UTC 2010


On Monday 26 July 2010 10:11:48 Legolgo wrote:
> Hi everyone,
> 
> I started using qtruby a few days ago and so far it's been great.
> But I stumbled upon a bug that causes a segfault.
> 
> As I just started using Qt and the qtruby binding I don't know if I'm
> doing something wrong with my custom model or if it's a bug of the binding.
> 
> Here is some minimal code that reproduce the error:
> 
> require "Qt4"
> 
> class TaskListModel < Qt::StandardItemModel
> 
>      def initialize(parent = nil)
>          super(parent)
>      end
> 
>      def data(index, role)
>          if !index.valid?
>              return Qt::Variant.new
>          end
>          if role == Qt::DisplayRole
>              item = item(index.row)
>              return Qt::Variant.new(item.text)
>          end
>          #this role cause a segfault, sometimes you have to wait a
> little bit or try to edit rows
>          if role == Qt::ForegroundRole
>              return Qt::Brush.new()
>          end
> 
>          return Qt::Variant.new
> 
>      end
> 
> 
> end
> 
> app = Qt::Application.new(ARGV)
> @widget = Qt::ListView.new()
> 
> @model = TaskListModel.new
> @widget.setModel(@model)
> #fill model with some data
> ["toto", "tata", "tutu"].each do |desc|
>      item = Qt::StandardItem.new
>      item.text = desc
>      @model.appendRow(item)
> end
> 
> @widget.show()
> app.exec()
> 
> I'm using the libQt4-ruby from ubuntu 10.04 with ruby 1.8


You are probably right. I remember the same problem with the ForegroundRole.
First I thought this might me resolved using newer versions (ruby kde from 
trunk and ruby1.9), but it is not.
The code crashes also for me in 1 of 5 runs directly at the beginning. I got 
the following error:

/tmp/aa.rb:42: [BUG] Segmentation fault
ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]

-- control frame ----------
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC  :method_missing
c:0003 p:0133 s:0007 b:0007 l:001708 d:000000 EVAL   /tmp/aa.rb:42
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001708 d:001708 TOP   
---------------------------

line 42. is widget.show


Best regards,
Robert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20100726/77a38a61/attachment.sig>


More information about the Kde-bindings mailing list