albertosottile / darkdetect

Detect OS Dark Mode from Python
Other
178 stars 18 forks source link

FIX: Avoid segfaults #10

Closed larsoner closed 3 years ago

larsoner commented 3 years ago

Similar to @HetDaftary I also see problems when using darkdetect as part of a Qt application in Linux:

Current thread 0x00007f4e2f45e740 (most recent call first):
  File "/home/larsoner/python/darkdetect/darkdetect/_linux_detect.py", line 17 in theme
  File "/home/larsoner/python/mne-python/mne/viz/backends/_qt.py", line 533 in _detect_theme
  File "/home/larsoner/python/mne-python/mne/viz/backends/_qt.py", line 445 in _window_set_theme
  File "/home/larsoner/python/mne-python/mne/viz/_brain/_brain.py", line 483 in __init__
  File "/home/larsoner/python/mne-python/mne/viz/_3d.py", line 1862 in _plot_stc
  File "/home/larsoner/python/mne-python/mne/viz/_3d.py", line 1780 in plot_source_estimates
  File "<decorator-gen-153>", line 24 in plot_source_estimates
  File "/home/larsoner/python/mne-python/mne/source_estimate.py", line 651 in plot
  File "/home/larsoner/Desktop/plot_dics.py", line 126 in plot_approach
  File "/home/larsoner/Desktop/plot_dics.py", line 138 in <module>
Segmentation fault (core dumped)

I just tried using multiprocessing and still see segfaults. On this branch I don't get segfaults. So it seems that initializing / using GTK at the same time as Qt can be problematic, so this solution seems safer.

albertosottile commented 3 years ago

LGTM, thanks for fixing this. I will merge this now and release it on PyPI soon.