lgi-devs / lgi-devs/lgi

Gtk tree model overrides are broken

Open
#163 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
491
Forks
81
PR merge metrics
No merged PRs in 30d

Description

The code below hangs:

local Gtk = require('lgi').require('Gtk', '2.0')
local Gdk = require('lgi').Gdk
local GObject = require('lgi').GObject

local model = Gtk.ListStore.newv {
	[1] = GObject.Type.STRING;
}

local item = model:append()
model:set(item, { "A" })

Interrupting the above script reveals that it spends most of its time recursively calling into the following function:

function Gtk.TreeModel:set(iter, values)
   -- Set all values provided by the table
   if Gtk.TreePath:is_type_of(iter) then iter = self:get_iter(iter) end
   self:set_values(iter, treemodel_prepare_values(self, values))
end

which shouldn't be there at all, as the GtkTreeModel interface doesn't actually guarantee that the model is writeable. Only GtkListStore and GtkTreeStore have set* methods.

(Tangentially, it would be nice if I could call Gtk.ListStore.new in Gtk 2.0 just like I can in Gtk 3.0.)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the Gtk.TreeModel:set override shown in the issue and compare it with the methods available on GtkListStore and GtkTreeStore. Run the provided Lua reproduction to confirm the recursive call; done means Gtk.TreeModel no longer exposes the invalid set override and the Gtk.ListStore example no longer hangs. The Gtk 2.0 Gtk.ListStore.new request is a separate tangential concern.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.