Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • gtk gtk
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1.6k
    • Issues 1.6k
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 296
    • Merge requests 296
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • gtkgtk
  • Issues
  • #2066

Gtk-CRITICAL when calling gtk_clipboard_store during unrealize of GtkPaned

Firstly, apologies in advance if I have done something wrong in this bug report, I have not contributed to gtk or Gnome before.

I discovered this issue while fixing this bug in the Xfce project's thunar file browser.

The problem is as follows: if a GtkPaned object contains as a descendant a widget which calls gtk_clipboard_store during its unrealize process, a Gtk-CRITICAL is emitted. The attached testcase program testcase.c illustrates this problem: simply run the program and the Gtk-CRITICAL appears when you close the window.

The bug is caused by the GtkPaned responding badly to a signal while in a partly unrealize-d state. The signal is received because gtk_clipboard_store runs a g_main_loop. In more detail, the function gtk_paned_unrealize destroys the GtkPaned's priv->handle member and sets this pointer to NULL, before chaining up to the gtk_widget_real_unrealize function, which unrealizes the GtkPaned's descendant widgets before calling gtk_widget_set_realized to mark the GtkPaned as unrealized. The problem occurs if one of these descendants calls gtk_clipboard_store while being unrealized (as happened in the original thunar bug, and as happens in the testcase), as gtk_clipboard_store runs a g_main_loop. This ultimately causes the function gtk_paned_state_flags_changed to be called on the GtkPaned. Now gtk_paned_state_flags_changed has a block of code which is only run if the GtkPaned is marked as realized, which it still is, as noted above. But this block then assumes that the GtkPaned's priv->handle member is a valid pointer, and calls gdk_window_set_cursor on it. gdk_window_set_cursor then emits a Gtk-CRITICAL, since it has been called on a NULL pointer.

Although I don't know much about Gtk internals, this bug seems fairly simple to solve, and a bug report is always better if it includes a fix, so I have prepared a small patch bugfix.patch against the gtk-3-24 branch to fix it (it just adds a simple check to gtk_paned_state_flags_changed). I know that Gnome is not so keen on patches these days, but as it is such a small change it didn't seem worth the bother of me setting up an account to submit a pull-request and so on.

Assignee
Assign to
Time tracking