[evolution] Fix e_mail_display_get_selection_plain_text_sync()
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Fix e_mail_display_get_selection_plain_text_sync()
- Date: Mon, 24 Oct 2016 12:27:27 +0000 (UTC)
commit f4c03b4ac22c25dd041073dd7d10dbc5e9fc7401
Author: Tomas Popela <tpopela redhat com>
Date: Mon Oct 24 14:15:48 2016 +0200
Fix e_mail_display_get_selection_plain_text_sync()
Fix couple of issues with e_mail_display_get_selection_plain_text_sync()
* Call the right Web extension method
* Fix a FIXME WK2 comment
* Change the return type to gchar * instead of const gchar * and adapt
the code. Previously we were return a string that belonged to the
GVariant, that contained the result of a DBus call to Web extension.
The problem was that string was freed even before we return it from
the function as it was freed with g_variant_unref().
src/mail/e-mail-display.c | 17 +++++++++--------
src/mail/e-mail-display.h | 2 +-
src/mail/e-mail-reader-utils.c | 2 +-
src/plugins/mail-to-task/mail-to-task.c | 15 +++++++++++----
4 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index f26a188..073002f 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -2461,7 +2461,7 @@ e_mail_display_set_status (EMailDisplay *display,
g_free (str);
}
-const gchar *
+gchar *
e_mail_display_get_selection_plain_text_sync (EMailDisplay *display,
GCancellable *cancellable,
GError **error)
@@ -2469,18 +2469,17 @@ e_mail_display_get_selection_plain_text_sync (EMailDisplay *display,
GDBusProxy *web_extension;
g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
-/* FIXME WK2
- if (!webkit_web_view_has_selection (WEBKIT_WEB_VIEW (display)))
+
+ if (!e_web_view_is_selection_active (E_WEB_VIEW (display)))
return NULL;
-*/
+
web_extension = e_web_view_get_web_extension_proxy (E_WEB_VIEW (display));
if (web_extension) {
GVariant *result;
- const gchar *text_content = NULL;
result = e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (
web_extension,
- "GetDocumentContentText",
+ "GetSelectionContentText",
g_variant_new (
"(t)",
webkit_web_view_get_page_id (
@@ -2491,9 +2490,11 @@ e_mail_display_get_selection_plain_text_sync (EMailDisplay *display,
error);
if (result) {
- g_variant_get (result, "(&s)", &text_content);
+ gchar *text;
+
+ g_variant_get (result, "(s)", &text);
g_variant_unref (result);
- return text_content;
+ return text;
}
}
diff --git a/src/mail/e-mail-display.h b/src/mail/e-mail-display.h
index 3670f91..1a75ba4 100644
--- a/src/mail/e-mail-display.h
+++ b/src/mail/e-mail-display.h
@@ -94,7 +94,7 @@ GtkAction * e_mail_display_get_action (EMailDisplay *display,
const gchar *action_name);
void e_mail_display_set_status (EMailDisplay *display,
const gchar *status);
-const gchar * e_mail_display_get_selection_plain_text_sync
+gchar * e_mail_display_get_selection_plain_text_sync
(EMailDisplay *display,
GCancellable *cancellable,
GError **error);
diff --git a/src/mail/e-mail-reader-utils.c b/src/mail/e-mail-reader-utils.c
index 6f80eba..e95f743 100644
--- a/src/mail/e-mail-reader-utils.c
+++ b/src/mail/e-mail-reader-utils.c
@@ -2507,7 +2507,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
if (src_is_html)
selection = e_web_view_get_selection_content_html_sync (web_view, NULL, NULL);
else
- selection = g_strdup (e_mail_display_get_selection_plain_text_sync (display, NULL, NULL));
+ selection = e_mail_display_get_selection_plain_text_sync (display, NULL, NULL);
if (selection == NULL || *selection == '\0')
goto whole_message;
diff --git a/src/plugins/mail-to-task/mail-to-task.c b/src/plugins/mail-to-task/mail-to-task.c
index 71f2b58..108b71b 100644
--- a/src/plugins/mail-to-task/mail-to-task.c
+++ b/src/plugins/mail-to-task/mail-to-task.c
@@ -814,7 +814,7 @@ typedef struct {
ECalClientSourceType source_type;
CamelFolder *folder;
GPtrArray *uids;
- const gchar *selected_text;
+ gchar *selected_text;
gboolean with_attendees;
}AsyncData;
@@ -1021,6 +1021,8 @@ do_mail_to_event (AsyncData *data)
g_ptr_array_unref (uids);
g_object_unref (folder);
+ if (data->selected_text)
+ g_free (data->selected_text);
g_object_unref (data->client_cache);
g_object_unref (data->source);
g_free (data);
@@ -1058,11 +1060,11 @@ text_contains_nonwhitespace (const gchar *text,
return p - text < len - 1 && c != 0;
}
-static const gchar *
+static gchar *
get_selected_text (EMailReader *reader)
{
EMailDisplay *display;
- const gchar *text = NULL;
+ gchar *text = NULL;
display = e_mail_reader_get_mail_display (reader);
@@ -1071,9 +1073,14 @@ get_selected_text (EMailReader *reader)
text = e_mail_display_get_selection_plain_text_sync (display, NULL, NULL);
- if (text == NULL || !text_contains_nonwhitespace (text, strlen (text)))
+ if (!text)
return NULL;
+ if (!text_contains_nonwhitespace (text, strlen (text))) {
+ g_free (text);
+ return NULL;
+ }
+
return text;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]