Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Wed, 05 Apr 2017 16:04:05 UTC Commit: adf01d6d239ad5dd17092640ff762453c0a237f1 https://github.com/geany/geany-plugins/commit/adf01d6d239ad5dd17092640ff7624...
Log Message: ----------- projectorganizer: Make sure project is open before trying to expand the 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 #549.
Modified Paths: -------------- projectorganizer/src/prjorg-sidebar.c
Modified: projectorganizer/src/prjorg-sidebar.c 29 lines changed, 20 insertions(+), 9 deletions(-) =================================================================== @@ -48,6 +48,13 @@ typedef enum MATCH_PATTERN } MatchType;
+typedef struct +{ + GeanyProject *project; + GPtrArray *expanded_paths; +} ExpandData; + + static GdkColor s_external_color; static GtkWidget *s_toolbar = NULL; static gboolean s_pending_reload = FALSE; @@ -1210,22 +1217,24 @@ static gboolean expand_path(gchar *utf8_expanded_path, gboolean select) }
-static gboolean expand_on_idle(gpointer ptr) +static gboolean expand_on_idle(ExpandData *expand_data) { GeanyDocument *doc = document_get_current();
- if (ptr) + if (prj_org && geany_data->app->project == expand_data->project && + expand_data->expanded_paths) { - GPtrArray *expanded_paths = ptr; gchar *item; guint i;
- foreach_ptr_array(item, i, expanded_paths) + foreach_ptr_array(item, i, expand_data->expanded_paths) expand_path(item, FALSE); - g_ptr_array_free(expanded_paths, TRUE); + g_ptr_array_free(expand_data->expanded_paths, TRUE); }
- if (!s_follow_editor || !doc || !doc->file_name || !geany_data->app->project || !prj_org) + g_free(expand_data); + + if (!s_follow_editor || !doc || !doc->file_name) return FALSE;
expand_path(doc->file_name, TRUE); @@ -1281,11 +1290,13 @@ static GPtrArray *get_expanded_paths(void)
void prjorg_sidebar_update(gboolean reload) { - GPtrArray *expanded_paths = NULL; + ExpandData *expand_data = g_new0(ExpandData, 1); + + expand_data->project = geany_data->app->project;
if (reload) { - expanded_paths = get_expanded_paths(); + expand_data->expanded_paths = get_expanded_paths();
load_project(); /* we get color information only after the sidebar is realized - @@ -1295,7 +1306,7 @@ void prjorg_sidebar_update(gboolean reload) }
/* perform on idle - avoids unnecessary jumps on project load */ - plugin_idle_add(geany_plugin, (GSourceFunc)expand_on_idle, expanded_paths); + plugin_idle_add(geany_plugin, (GSourceFunc)expand_on_idle, expand_data); }
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).