This is the piece of code that makes ruby to crash:
<code>
def load_plists
#return
@ui.lists_tv.clear
DBIntf::connection.execute( "SELECT * FROM plists ORDER BY
LOWER(sname)" ) do |row|
@ui.lists_tv.addTopLevelItem(Qt::TreeWidgetItem.new {
setText(0, row[0]); setText(1, row[1]) })
end
end
</code>
I added the order by statement to get rid from the sort in the tree
view. The tree view comes from a qtdesigner ui file and is used as a
list
view, there are no children and only 16 entries in the sqlite3 plists
table.
In another similar case, slightly more complex, i have 2000+ entries and
it works even if sort is enabled but only if the code is surrounded with
GC.enable/disable:
<code>
def load_entries
clear
GC.disable
has_compile = false
DBIntf::connection.execute(generate_sql) do |row|
map_row_to_entry(row, Qt::TreeWidgetItem.new)
has_compile = true if row[ROW_REF] == "0"
end
unless @mc.main_filter.empty?
unless has_compile
map_row_to_entry(["0", "Compilation"],
Qt::TreeWidgetItem.new)
end
end
GC.enable
return self
end
</code>
In this case, the class inherits a treeview.
Thanks for the links and your help.
marco
--
Posted via http://www.ruby-forum.com/.