Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Mon, 31 Jul 2023 11:40:20 UTC
Commit: 35d556ede85efb358d1cac156dd0fc8d44b20201
https://github.com/geany/geany/commit/35d556ede85efb358d1cac156dd0fc8d44b20…
Log Message:
-----------
Fix crash closing directory from the openfiles sidebar
When the openfiles sidebar shows documents as a tree, closing a
document can lead to sever re-layout of the view (e.g. collapsing
directory nodes together). This makes walking the tree and closing
documents at the same time highly tricky, as nodes might be shifting as
we go.
This lead to invalid memory access, and unexpected results, when
closing some tree structures.
One example of Valgrind showing how bad things are:
==917061== Invalid read of size 8
==917061== at 0x5B31345: g_node_nth_child (gnode.c:1052)
==917061== by 0x50A7361: gtk_tree_store_iter_nth_child (gtktreestore.c:793)
==917061== by 0x491DB76: on_openfiles_document_action_apply (sidebar.c:1330)
==917061== by 0x491DC0C: on_openfiles_document_action (sidebar.c:1347)
==917061== by 0x5A833AF: g_closure_invoke (gclosure.c:832)
==917061== by 0x5A96075: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==917061== by 0x5A9CBF4: g_signal_emit_valist (gsignal.c:3549)
==917061== by 0x5A9CDBE: g_signal_emit (gsignal.c:3606)
==917061== by 0x50D7833: gtk_widget_activate (gtkwidget.c:7845)
==917061== by 0x4F8A935: gtk_menu_shell_activate_item (gtkmenushell.c:1375)
==917061== by 0x4F8AC70: gtk_menu_shell_button_release (gtkmenushell.c:791)
==917061== by 0x4DFBCB3: _gtk_marshal_BOOLEAN__BOXEDv (gtkmarshalers.c:130)
==917061== Address 0x9bcdc20 is 32 bytes inside a block of size 40 free'd
==917061== at 0x484317B: free (vg_replace_malloc.c:872)
==917061== by 0x5B3068B: g_nodes_free (gnode.c:123)
==917061== by 0x5B3068B: g_node_destroy (gnode.c:143)
==917061== by 0x50AA8F2: gtk_tree_store_remove (gtktreestore.c:1229)
==917061== by 0x491F851: sidebar_openfiles_remove_iter (sidebar.c:959)
==917061== by 0x491F8AE: openfiles_remove (sidebar.c:972)
==917061== by 0x491FA6C: sidebar_remove_document (sidebar.c:1027)
==917061== by 0x48D0B5B: remove_page (document.c:733)
==917061== by 0x48D29C0: document_remove_page (document.c:787)
==917061== by 0x48D29FC: document_close (document.c:695)
==917061== by 0x491DAED: document_action (sidebar.c:1299)
==917061== by 0x491DB47: on_openfiles_document_action_apply (sidebar.c:1322)
==917061== by 0x491DB9E: on_openfiles_document_action_apply (sidebar.c:1332)
==917061== Block was alloc'd at
==917061== at 0x48407B4: malloc (vg_replace_malloc.c:381)
==917061== by 0x5B2C678: g_malloc (gmem.c:130)
==917061== by 0x5B45011: g_slice_alloc (gslice.c:1074)
==917061== by 0x5B305BD: g_node_new (gnode.c:110)
==917061== by 0x50AAF0B: gtk_tree_store_insert_before (gtktreestore.c:1375)
==917061== by 0x491E725: tree_add_new_dir (sidebar.c:654)
==917061== by 0x491E89A: get_parent_for_file (sidebar.c:840)
==917061== by 0x491E995: sidebar_openfiles_add_iter (sidebar.c:869)
==917061== by 0x491F5C7: sidebar_openfiles_add (sidebar.c:901)
==917061== by 0x48D0CE4: document_create (document.c:662)
==917061== by 0x48D3840: document_open_file_full (document.c:1349)
==917061== by 0x48D3C81: document_open_file (document.c:914)
Fix this by decoupling tree walking from closing documents. We now do
two passes: first we collect documents to work on walking the tree as
before, and only then we perform the action on each node of the list.
Fixes #3527.
Modified Paths:
--------------
src/sidebar.c
Modified: src/sidebar.c
27 lines changed, 19 insertions(+), 8 deletions(-)
===================================================================
@@ -1313,24 +1313,28 @@ static void document_action(GeanyDocument *doc, gint action)
}
-static void on_openfiles_document_action_apply(GtkTreeModel *model, GtkTreeIter iter, gint action)
+/* Collects all documents under a given iter, filling @doc_array */
+static void on_openfiles_document_action_collect(GtkTreeModel *model, GtkTreeIter *iter,
+ GPtrArray *doc_array)
{
GeanyDocument *doc;
- gtk_tree_model_get(model, &iter, DOCUMENTS_DOCUMENT, &doc, -1);
+ gtk_tree_model_get(model, iter, DOCUMENTS_DOCUMENT, &doc, -1);
if (doc)
{
- document_action(doc, action);
+ g_ptr_array_add(doc_array, doc);
}
else
{
/* parent item selected */
GtkTreeIter child;
- gint i = gtk_tree_model_iter_n_children(model, &iter) - 1;
- while (i >= 0 && gtk_tree_model_iter_nth_child(model, &child, &iter, i))
+ if (gtk_tree_model_iter_children(model, &child, iter))
{
- on_openfiles_document_action_apply(model, child, action);
- i--;
+ do
+ {
+ on_openfiles_document_action_collect(model, &child, doc_array);
+ }
+ while (gtk_tree_model_iter_next(model, &child));
}
}
}
@@ -1344,7 +1348,14 @@ static void on_openfiles_document_action(GtkMenuItem *menuitem, gpointer user_da
gint action = GPOINTER_TO_INT(user_data);
if (gtk_tree_selection_get_selected(selection, &model, &iter))
- on_openfiles_document_action_apply(model, iter, action);
+ {
+ GPtrArray *doc_array = g_ptr_array_new();
+
+ on_openfiles_document_action_collect(model, &iter, doc_array);
+ for (guint i = 0; i < doc_array->len; i++)
+ document_action(g_ptr_array_index(doc_array, i), action);
+ g_ptr_array_free(doc_array, TRUE);
+ }
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Sun, 08 Oct 2023 13:53:17 UTC
Commit: 337daf7619f7029c6fe09511fa84905e9f7f1bda
https://github.com/geany/geany/commit/337daf7619f7029c6fe09511fa84905e9f7f1…
Log Message:
-----------
Update geany.txt with the required GTK version
Modified Paths:
--------------
doc/geany.txt
Modified: doc/geany.txt
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -103,7 +103,7 @@ Installation
Requirements
------------
-You will need the GTK (>= 2.24) libraries and their dependencies
+You will need the GTK (>= 3.24) libraries and their dependencies
(Pango, GLib and ATK). Your distro should provide packages for these,
usually installed by default. For Windows, you can download an installer
from the website which bundles these libraries.
@@ -120,7 +120,7 @@ Source compilation
------------------
Compiling Geany is quite easy.
-To do so, you need the GTK (>= 2.24) libraries and header files.
+To do so, you need the GTK (>= 3.24) libraries and header files.
You also need the Pango, GLib and ATK libraries and header files.
All these files are available at http://www.gtk.org, but very often
your distro will provide development packages to save the trouble of
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Sat, 07 Oct 2023 19:54:04 UTC
Commit: e9127911bc89c8cba0a4ecbd5c450efcc4b08a52
https://github.com/geany/geany/commit/e9127911bc89c8cba0a4ecbd5c450efcc4b08…
Log Message:
-----------
Fix missing return value in copy_tags()
Actually make this function not return anything as no caller seem to
need it, and it's not entirely trivial to return a useful value (it
could return the number of copied tags, but it'd have to be computed,
which is not useful if not used).
Modified Paths:
--------------
src/tagmanager/tm_workspace.c
Modified: src/tagmanager/tm_workspace.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -740,12 +740,12 @@ static gboolean is_workspace_tag(TMTag *tag, CopyInfo *info)
}
-static guint copy_tags(GPtrArray *dst, TMTag **src, guint src_len, GHashTable *name_table,
+static void copy_tags(GPtrArray *dst, TMTag **src, guint src_len, GHashTable *name_table,
gint num, gboolean (*predicate) (TMTag *, CopyInfo *), CopyInfo *info)
{
guint i;
- g_return_val_if_fail(src && dst, 0);
+ g_return_if_fail(src && dst);
for (i = 0; i < src_len && num > 0; i++)
{
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Jiří Techet <techet(a)gmail.com>
Committer: Jiří Techet <techet(a)gmail.com>
Date: Mon, 15 May 2023 21:18:23 UTC
Commit: 2fd242b94c41f9254b2288fdb39a1c20d819b53d
https://github.com/geany/geany/commit/2fd242b94c41f9254b2288fdb39a1c20d819b…
Log Message:
-----------
For C/C++ only mark tag as local if it originates from a source file
Modified Paths:
--------------
src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -119,7 +119,7 @@ static gboolean init_tag(TMTag *tag, TMSourceFile *file, const tagEntryInfo *tag
tag->name = g_strdup(tag_entry->name);
tag->type = type;
- tag->local = tag_entry->isFileScope;
+ tag->local = tag_entry->isFileScope && file->trust_file_scope;
tag->flags = tm_tag_flag_none_t;
if (isTagExtraBitMarked(tag_entry, XTAG_ANONYMOUS))
tag->flags |= tm_tag_flag_anon_t;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).