CompletionProvider: gdk_popup_present: assertion 'wi
Reproduction steps:
- Type any letter.
- In the completion proposals popup select any entry and press the enter key.
- Type any letter.
Problem:
(python3:26929): Gdk-CRITICAL **: 23:50:00.699: gdk_popup_present: assertion 'width > 0' failed
(python3:26929): Gdk-WARNING **: 23:50:02.261: Tried to unmap the parent of a popup
Reproduction example:
#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "4.0")
gi.require_version("GtkSource", "5")
from gi.repository import Gio
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import GtkSource
class ApplicationWindow(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_default_size(600, 300)
source_view = GtkSource.View()
provider = ExampleCompletionProvider()
view_completion = source_view.get_completion()
view_completion.add_provider(provider)
lm = GtkSource.LanguageManager()
textbuffer = GtkSource.Buffer()
source_view.set_buffer(textbuffer)
self.set_child(source_view)
class ExampleCompletionProvider(GObject.GObject, GtkSource.CompletionProvider):
PROPOSALS = ["Foo", "Bar", "Baz"]
def do_display(self, context, proposal, cell):
if cell.props.column == GtkSource.CompletionColumn.TYPED_TEXT:
cell.set_text(proposal.text)
def do_populate_async(self, context, cancellable, callback, data):
task = Gio.Task.new(self, cancellable, callback)
store = Gio.ListStore.new(ExampleProposal)
for proposal in self.PROPOSALS:
store.append(ExampleProposal(proposal))
task.proposals = Gtk.FilterListModel.new(store, None)
task.return_boolean(True)
def do_populate_finish(self, result):
if result.propagate_boolean():
return result.proposals
class ExampleProposal(GObject.Object, GtkSource.CompletionProposal):
def __init__(self, text):
super().__init__()
self.text = text
def on_activate(app):
win = ApplicationWindow(application=app)
win.present()
if __name__ == "__main__":
app = Gtk.Application()
app.connect("activate", on_activate)
app.run(None)
Versions:
gir1.2-gtksource-5: 5.6.1-1
libgtksourceview-5-0: 5.6.1-1