Cairo-Dock / cairo-dock-core

Core part of Cairo-Dock project.
http://glx-dock.org
GNU General Public License v3.0
186 stars 46 forks source link

Help: make cairo_dock_show_tips work properly #17

Closed mtasaka closed 4 months ago

mtasaka commented 4 months ago

A. cairo_dock_show_tips() calls _cairo_dock_get_next_tip(pTips) , which uses pTips->pCategoryCombo , so this must be properly created (initialized) before calling _cairo_dock_get_next_tip(pTips).

B. In _cairo_dock_get_next_tip() (or _cairo_dock_get_previous_tip()), g_key_file_get_comment() is called to retrieve comment. According to the specification: https://docs.gtk.org/glib/method.KeyFile.get_comment.html The above call does not remove the leading whitespace ('#' comment marker is removed). So currently due to the leading newline, currently *cKeyComment == CAIRO_DOCK_WIDGET_EXPANDER never matches, so currently _cairo_dock_get_next_tip() causes infinite loop.

So skip reading whitespace, as this is shown in cairo_dock_parse_key_comment().

C. The buffer returned by g_key_file_get_comment() must be handled by g_free in _cairo_dock_get_previous_tip() (as _cairo_dock_get_next_tip() already does).

mtasaka commented 4 months ago

Currently,

Shows the following messages infinitely:

g_signal_handlers_unblock_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
invalid (NULL) pointer instance
g_signal_handlers_block_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
invalid (NULL) pointer instance
g_signal_handlers_unblock_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
invalid (NULL) pointer instance
g_signal_handlers_block_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
gtk_combo_box_set_active: assertion 'GTK_IS_COMBO_BOX (combo_box)' failed
invalid (NULL) pointer instance
g_signal_handlers_unblock_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
invalid (NULL) pointer instance
g_signal_handlers_block_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
gtk_combo_box_set_active: assertion 'GTK_IS_COMBO_BOX (combo_box)' failed

The above assertion failure itself is due to the above issue A. The infinite loop is due to the above B. Also a small memory leak is happening due to C.

dkondor commented 4 months ago

Hi, thank you! I've also encountered this issue and have a similar fix for B and C in #16 here: https://github.com/Cairo-Dock/cairo-dock-core/pull/16/commits/f85b4392be8cd2577e62c1d7acf9ef2e88a480e9 however, I haven't figured our issue A. Could you perhaps separate the fix into two commits (A and B/C) so that it is easier to avoid a merge conflict? I can then merge this together with #16

mtasaka commented 4 months ago

Sorry for delay.

Thank you for comments! I will split this PR into 2.

mtasaka commented 4 months ago

split into #18 and #19 .