Branch: refs/heads/master Author: Frank Lanitz frank@frank.uvena.de Committer: GitHub noreply@github.com Date: Sat, 08 Apr 2017 14:38:55 UTC Commit: 300a9117e11ab1602007a83500dd1cfe0df4e725 https://github.com/geany/geany-plugins/commit/300a9117e11ab1602007a83500dd1c...
Log Message: ----------- Merge pull request #555 from techee/prjorg_crash_fix
projectorganizer: Make sure project is open before trying to expand the tree
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).
plugins-commits@lists.geany.org