[evolution/gnome-3-16] Bug 746349 - Pasting '\n' into composer produces critical runtime warning



commit f84c2997c59b6aaedf3a73bcab757bd680d4df74
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Mar 18 14:14:21 2015 +0100

    Bug 746349 - Pasting '\n' into composer produces critical runtime warning

 e-util/e-html-editor-view.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 36dae78..3abb28a 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -5977,7 +5977,9 @@ parse_html_into_paragraphs (EHTMLEditorView *view,
                                                WEBKIT_DOM_ELEMENT (child),
                                                "-x-evo-last-br");
                                }
-                       }
+                       } else
+                               create_and_append_new_paragraph (
+                                       selection, document, blockquote, block, "<br>");
                        g_free (truncated);
                        goto end;
                }
@@ -6511,7 +6513,6 @@ fix_structure_after_pasting_multiline_content (WebKitDOMNode *node)
                                NULL);
                first_child = next_child;
        }
-       remove_node (parent);
 }
 
 static void
@@ -6561,7 +6562,6 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
        inner_html = webkit_dom_html_element_get_inner_html (
                WEBKIT_DOM_HTML_ELEMENT (element));
        parse_html_into_paragraphs (view, document, element, current_block, inner_html);
-
        g_free (inner_html);
 
        has_selection = !e_html_editor_selection_is_collapsed (selection);
@@ -6735,14 +6735,10 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
                WEBKIT_DOM_HTML_ELEMENT (element));
        e_html_editor_view_exec_command (
                view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, inner_html);
-       g_free (inner_html);
 
-       inner_html = webkit_dom_html_element_get_inner_text (
-               WEBKIT_DOM_HTML_ELEMENT (element));
-       if (g_str_has_suffix (inner_html, " ")) {
+       if (g_str_has_suffix (inner_html, " "))
                e_html_editor_view_exec_command (
                        view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_TEXT, " ");
-       }
        g_free (inner_html);
 
        g_object_unref (element);
@@ -6817,8 +6813,10 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
                        node = parent;
                } else {
                        node = webkit_dom_node_get_next_sibling (parent);
-                       if (!node)
+                       if (!node) {
                                fix_structure_after_pasting_multiline_content (parent);
+                               remove_node (parent);
+                       }
                }
 
                if (node) {
@@ -6862,8 +6860,17 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
                /* Check if WebKit created wrong structure */
                clone1 = webkit_dom_node_clone_node (WEBKIT_DOM_NODE (paragraph), FALSE);
                clone2 = webkit_dom_node_clone_node (WEBKIT_DOM_NODE (parent), FALSE);
-               if (webkit_dom_node_is_equal_node (clone1, clone2))
+               if (webkit_dom_node_is_equal_node (clone1, clone2)) {
                        fix_structure_after_pasting_multiline_content (paragraph);
+                       if (*html != '\n')
+                               remove_node (parent);
+
+                       webkit_dom_node_insert_before (
+                               parent,
+                               WEBKIT_DOM_NODE (selection_start_marker),
+                               webkit_dom_node_get_last_child (parent),
+                               NULL);
+               }
 
                g_object_unref (clone1);
                g_object_unref (clone2);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]