Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projectorganizer: Make sure project is open before trying to expand the tree #555

Merged
merged 1 commit into from
Apr 8, 2017

Conversation

techee
Copy link
Member

@techee techee commented Mar 30, 2017

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.

…he tree

Since expand_on_idle() is called as an idle function, it can happen it's
executed after project is closed. Before trying to expand paths it now
first checks if the idle call corresponds to the project for which
the idle call was created.

Should fix crash reported in geany#549.
@codebrainz
Copy link
Member

@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.

@kugel-
Copy link
Member

kugel- commented Mar 31, 2017

@techee The crash is gone. But you have to tell if it's the proper fix or not.

@techee
Copy link
Member Author

techee commented Apr 3, 2017

@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.

@codebrainz
Copy link
Member

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 :)

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch solves #549 partially. See below.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't realize that with this patch a new crash occur when opening a file with no project opened.

@frlan
Copy link
Member

frlan commented Apr 8, 2017

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 projects active)

@frlan
Copy link
Member

frlan commented Apr 8, 2017

It crash on an Geany without an open document only instant save from saveactions was activated

@techee
Copy link
Member Author

techee commented Apr 10, 2017

Should be fixed in #559. Sorry for not noticing this myself, I just usually have some project open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants