Fix crash in open selector

Resolves: #2007602
This commit is contained in:
Ray Strode 2021-09-27 15:13:12 -04:00
parent d2de330fc9
commit f970b49d41
2 changed files with 99 additions and 1 deletions

View File

@ -0,0 +1,91 @@
From 624af5fed418c2be0939f42e75c4e9c4744d98d7 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 27 Sep 2021 15:07:52 -0400
Subject: [PATCH] open-selector: Fix crash introduced in GDateTime port
commit acf14cc04f1e66c4c726d9a0b193bf39a28ca8b0 moved FileItems
over to using GDateTime instead of GTimeVal.
This reduced code complexity pretty nicely, but it unfortunately
introduced a bug, where the sort_items_by_mru function was treating
the FileItems themselves as GDateTime objects. That bug causes a
crash when opening files.
This commit fixes the problem by using the ->accessed members
instead of the file items themselves.
Closes: https://gitlab.gnome.org/GNOME/gedit/-/issues/465
---
gedit/gedit-open-document-selector.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gedit/gedit-open-document-selector.c b/gedit/gedit-open-document-selector.c
index bc3d0548d..e46f01568 100644
--- a/gedit/gedit-open-document-selector.c
+++ b/gedit/gedit-open-document-selector.c
@@ -285,61 +285,61 @@ create_row (GeditOpenDocumentSelector *selector,
filter_regex,
(const gchar *)item->path,
(const gchar *)item->name,
&dst_path,
&dst_name);
}
else
{
dst_path = g_markup_escape_text (item->path, -1);
dst_name = g_markup_escape_text (item->name, -1);
}
gtk_list_store_append (selector->liststore, &iter);
gtk_list_store_set (selector->liststore, &iter,
URI_COLUMN, uri,
NAME_COLUMN, dst_name,
PATH_COLUMN, dst_path,
-1);
g_free (dst_path);
g_free (dst_name);
}
static gint
sort_items_by_mru (FileItem *a,
FileItem *b,
gpointer unused G_GNUC_UNUSED)
{
g_assert (a != NULL && b != NULL);
- return g_date_time_compare (b, a);
+ return g_date_time_compare (b->accessed, a->accessed);
}
static GList *
compute_all_items_list (GeditOpenDocumentSelector *selector)
{
GList *recent_items;
GList *home_dir_items;
GList *desktop_dir_items;
GList *local_bookmarks_dir_items;
GList *file_browser_root_items;
GList *active_doc_dir_items;
GList *current_docs_items;
GList *all_items = NULL;
/* Copy/concat the whole list */
recent_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->recent_items);
home_dir_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->home_dir_items);
desktop_dir_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->desktop_dir_items);
local_bookmarks_dir_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->local_bookmarks_dir_items);
file_browser_root_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->file_browser_root_items);
active_doc_dir_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->active_doc_dir_items);
current_docs_items = gedit_open_document_selector_copy_file_items_list ((const GList *)selector->current_docs_items);
if (selector->all_items)
{
gedit_open_document_selector_free_file_items_list (selector->all_items);
selector->all_items = NULL;
}
all_items = g_list_concat (all_items, recent_items);
--
2.32.0

View File

@ -15,7 +15,7 @@
Name: gedit
Epoch: 2
Version: 41~alpha
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Text editor for the GNOME desktop
License: GPLv2+ and GFDL
@ -63,6 +63,9 @@ Requires: desktop-file-utils >= 0.22-6
Obsoletes: gedit-collaboration < 3.6.1-6
Obsoletes: gedit-plugin-zeitgeist < 3.35.90
Patch10001: 0001-open-selector-Fix-crash-introduced-in-GDateTime-port.patch
%description
gedit is a small, but powerful text editor designed specifically for
the GNOME desktop. It has most standard text editor functions and fully
@ -165,6 +168,10 @@ desktop-file-validate $RPM_BUILD_ROOT%{_datadir}/applications/org.gnome.gedit.de
%{_datadir}/vala/
%changelog
* Mon Sep 27 2021 Ray Strode <rstrode@redhat.com> - 41~alpha-2
- Fix crash in open selector
Resolves: #2007602
* Wed Aug 04 2021 Kalev Lember <klember@redhat.com> - 2:41~alpha-1
- Update to 41.alpha