Skip to content

Perform all GTK interactions on the tray loop thread - #9

Merged
cgutman merged 1 commit into
LizardByte:masterfrom
cgutman:fix_thread_usage
Jan 11, 2024
Merged

cgutman merged 1 commit into
LizardByte:masterfrom
cgutman:fix_thread_usage

Conversation

@cgutman

@cgutman cgutman commented Jan 10, 2024 •

Copy link
Copy Markdown

Description

GTK is not thread-safe, so we must only interact with GTK objects when running in our tray loop thread. However, it's not a simple as calling g_main_context_invoke() and returning, since many callers populate struct tray fields with variables located on the stack before calling tray_update(). To avoid those variables going out of scope, we block in tray_update() until the tray loop has processed our callback.

I tested the reproducer in LizardByte/Sunshine#1878 (comment) and was no longer able to reproduce the issue after applying this change.

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@cgutman
cgutman merged commit 2bf1c61 into LizardByte:master Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant