Skip to content

Commit

Permalink
projectorganizer: Make sure project is open before trying to expand t…
Browse files Browse the repository at this point in the history
…he tree

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 geany#549.
  • Loading branch information
techee committed Mar 23, 2017
1 parent 62daca4 commit 922224b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion projectorganizer/src/prjorg-sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ static gboolean expand_on_idle(gpointer ptr)
{
GeanyDocument *doc = document_get_current();

if (!geany_data->app->project || !prj_org)
return FALSE;

if (ptr)
{
GPtrArray *expanded_paths = ptr;
Expand All @@ -1225,7 +1228,7 @@ static gboolean expand_on_idle(gpointer ptr)
g_ptr_array_free(expanded_paths, TRUE);
}

if (!s_follow_editor || !doc || !doc->file_name || !geany_data->app->project || !prj_org)
if (!s_follow_editor || !doc || !doc->file_name)
return FALSE;

expand_path(doc->file_name, TRUE);
Expand Down

0 comments on commit 922224b

Please sign in to comment.