Since expand_on_idle() is called as an idle function, it can happen it's executed after project is closed in which case it should just return without accessing variables with invalid values.
Should fix crash reported in #549. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/555
-- Commit Summary --
* projectorganizer: Make sure project is open before trying to expand the tree
-- File Changes --
M projectorganizer/src/prjorg-sidebar.c (5)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/555.patch https://github.com/geany/geany-plugins/pull/555.diff
@techee wouldn't it be better to keep track of the source IDs and connect/disconnect them as a project is opened/closed? Seems more future proof, IMO.
@techee The crash is gone. But you have to tell if it's the proper fix or not.
@codebrainz Yeah, it might theoretically happen that one project is closed, another opened afterwards after which the idle function is called still for the first project and expand incorrect paths as a result.
I've just submitted a new patch - instead of saving the source IDs which I'd have to store to some global variable, I just pass the Geany project pointer to the idle function and there check if it's still the same project. Should do the same job.
instead of saving the source IDs which I'd have to store to some global variable
Plugins can now have associated data, so you could just store the handler ID in there with other plugin-wide state. In any case, I'm sure it's fine, my OCD just doesn't like when code doesn't undo this kind of stuff, which is why I'm such a big fan of C++ RAII :)
interoceto approved this pull request.
This patch solves #549
interoceto commented on this pull request.
Sorry, I didn't realize that with this patch a new crash occur when opening a file with no project opened.
Merged #555.
I vererted the merge as on further testing I'm getting
``` Thread 1 "geany" received signal SIGSEGV, Segmentation fault. 0x00007fff898889c2 in expand_path (utf8_expanded_path=0x555556835670 "/tmp/gis_QFVDYY.", select=select@entry=1) at prjorg-sidebar.c:1175 1175 foreach_slist (elem, prj_org->roots) (gdb) bt #0 0x00007fff898889c2 in expand_path (utf8_expanded_path=0x555556835670 "/tmp/gis_QFVDYY.", select=select@entry=1) at prjorg-sidebar.c:1175 #1 0x00007fff89888b4e in expand_on_idle (expand_data=0x55555683cfb0) at prjorg-sidebar.c:1240 #2 0x00007ffff50c76aa in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #3 0x00007ffff50c7a60 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #4 0x00007ffff50c7d82 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #5 0x00007ffff741d3b7 in gtk_main () from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 #6 0x00007ffff79aa107 in main_lib (argc=<optimized out>, argv=<optimized out>) at libmain.c:1233 #7 0x00007ffff4ae22b1 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6 #8 0x00005555555547ba in _start () ``` Please double check (no plugins active)
It crash on an Geany without an open document only instant save from saveactions was activated
Should be fixed in #559. Sorry for not noticing this myself, I just usually have some project open.
github-comments@lists.geany.org