Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 07 Jul 2024 08:31:22 UTC Commit: 8056d620bc067d153197ae5b4b5fae00163c711a https://github.com/geany/geany/commit/8056d620bc067d153197ae5b4b5fae00163c71...
Log Message: ----------- Fix open document check in document_get_from_page()
The check `page_num >= documents_array->len` isn't correct as `documents_array->len` isn't the number of open documents. This array never shrinks and closed documents are only marked as invalid.
Without this patch, when closing a Geany project and the default session doesn't contain any document, the following warning appears: ``` (geany:1740553): Geany-CRITICAL **: 11:02:39.105: document_get_from_notebook_child: assertion 'GTK_IS_BOX(page)' failed ```
The corresponding stack trace when using `--g-fatal-warnings` is: ``` #5 0x0000fffff7c241d0 in document_get_from_notebook_child (page=<optimized out>) at document.c:335 #6 0x0000fffff7c242a4 in document_get_from_page (page_num=<optimized out>) at document.c:361 #7 0x0000fffff7c4b248 in configuration_open_files (session_files=<optimized out>) at keyfile.c:1390 #8 0x0000fffff7c4b354 in configuration_open_default_session () at keyfile.c:1404 #9 0x0000fffff7c5e430 in destroy_project (open_default=1) at project.c:480 #10 0x0000fffff7c5e4d8 in project_close (open_default=1) at project.c:435 ```
This patch fixes that.
Modified Paths: -------------- src/document.c
Modified: src/document.c 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -351,9 +351,10 @@ GeanyDocument *document_get_from_notebook_child(GtkWidget *page) GEANY_API_SYMBOL GeanyDocument *document_get_from_page(guint page_num) { + gint pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)); GtkWidget *parent;
- if (page_num >= documents_array->len) + if (page_num >= pages) return NULL;
parent = gtk_notebook_get_nth_page(GTK_NOTEBOOK(main_widgets.notebook), page_num);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).