diff options
author | Daniel Boles <dboles.src@gmail.com> | 2019-01-06 15:56:57 -0800 |
---|---|---|
committer | Daniel Boles <dboles.src@gmail.com> | 2019-01-07 20:46:08 +0000 |
commit | d7193eaf8be8d54f15031dc1024ce57e1aa86f33 (patch) | |
tree | 8679c435d075da82e74fc90ce3258a47f670d3bf /gtk/gtksearchenginequartz.c | |
parent | b52dea7a10fbba1a3c5cdda3fe3a304279156dd3 (diff) | |
download | gtk+-d7193eaf8be8d54f15031dc1024ce57e1aa86f33.tar.gz |
[GtkSearchEngineQuartz] Resolve the path to a GtkFile* for the hit list.
Instead of a char* path, which the search_hit parser doesn't expect,
causing a crash.
Closes: $https://gitlab.gnome.org/GNOME/gtk/issues/815
Diffstat (limited to 'gtk/gtksearchenginequartz.c')
-rw-r--r-- | gtk/gtksearchenginequartz.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gtk/gtksearchenginequartz.c b/gtk/gtksearchenginequartz.c index da90c4d56b..972983aa3d 100644 --- a/gtk/gtksearchenginequartz.c +++ b/gtk/gtksearchenginequartz.c @@ -78,23 +78,31 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GT for (i = submitted_hits; i < [ns_query resultCount]; i++) { id result = [ns_query resultAtIndex:i]; - char *result_path; + const char *result_path; + GFile *file; + GtkSearchHit *hit; - result_path = g_strdup_printf ("file://%s", [[result valueForAttribute:@"kMDItemPath"] cString]); - hits = g_list_prepend (hits, result_path); + result_path = [[result valueForAttribute:@"kMDItemPath"] UTF8String]; + file = g_file_new_for_path (result_path); + + hit = g_new (GtkSearchHit, 1); + hit->file = file; + hit->info = NULL; + + hits = g_list_prepend (hits, hit); } _gtk_search_engine_hits_added (engine, hits); - g_list_free (hits); + g_list_free_full (hits, (GDestroyNotify) _gtk_search_hit_free); - submitted_hits = [ns_query resultCount]; + submitted_hits += [ns_query resultCount]; /* The beagle backend stops at 1000 hits, so guess we do so too here. * It works pretty snappy on my MacBook, if we get rid of this limit * we are almost definitely going to need some code to submit hits * in batches. */ - if (submitted_hits > 1000) + if (submitted_hits > 25) [ns_query stopQuery]; } |