Changeset 55245 in webkit


Ignore:
Timestamp:
Feb 25, 2010 10:18:02 AM (14 years ago)
Author:
kov@webkit.org
Message:

2010-02-25 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>

Reviewed by Xan Lopez.

[Gtk] crashed when destroying
https://bugs.webkit.org/show_bug.cgi?id=31271

NULL-check the page before relaying the focus out event, since
this might happen when destroying the widget without destroying
its parent, and we currently crash.

  • tests/testwebview.c: (delayed_destroy): (test_webkit_web_view_destroy): (main):
  • webkit/webkitwebview.cpp: (webkit_web_view_focus_in_event):
Location:
trunk/WebKit/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/gtk/ChangeLog

    r55222 r55245  
     12010-02-25  Gustavo Noronha Silva  <gustavo.noronha@collabora.co.uk>
     2
     3        Reviewed by Xan Lopez.
     4
     5        [Gtk] crashed when destroying
     6        https://bugs.webkit.org/show_bug.cgi?id=31271
     7
     8        NULL-check the page before relaying the focus out event, since
     9        this might happen when destroying the widget without destroying
     10        its parent, and we currently crash.
     11
     12        * tests/testwebview.c:
     13        (delayed_destroy):
     14        (test_webkit_web_view_destroy):
     15        (main):
     16        * webkit/webkitwebview.cpp:
     17        (webkit_web_view_focus_in_event):
     18
    1192010-02-24  Krzysztof Kotlenga <pocek@users.sf.net>
    220
  • trunk/WebKit/gtk/tests/testwebview.c

    r55173 r55245  
    11/*
    22 * Copyright (C) 2008 Holger Hans Peter Freyther
    3  * Copyright (C) 2009 Collabora Ltd.
     3 * Copyright (C) 2009, 2010 Collabora Ltd.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    227227}
    228228
     229gboolean delayed_destroy(gpointer data)
     230{
     231    gtk_widget_destroy(GTK_WIDGET(data));
     232    g_main_loop_quit(loop);
     233    return FALSE;
     234}
     235
     236static void test_webkit_web_view_destroy()
     237{
     238    GtkWidget* window;
     239    GtkWidget* web_view;
     240
     241    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     242    web_view = webkit_web_view_new();
     243
     244    gtk_container_add(GTK_CONTAINER(window), web_view);
     245
     246    gtk_widget_show_all(window);
     247
     248    loop = g_main_loop_new(NULL, TRUE);
     249
     250    g_signal_connect(window, "map-event",
     251                     G_CALLBACK(map_event_cb), loop);
     252    g_main_loop_run(loop);
     253
     254    g_idle_add(delayed_destroy, web_view);
     255    g_main_loop_run(loop);
     256
     257    gtk_widget_destroy(window);
     258}
     259
    229260int main(int argc, char** argv)
    230261{
     
    252283    g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri);
    253284    g_test_add_func("/webkit/webview/adjustments", test_webkit_web_view_adjustments);
     285    g_test_add_func("/webkit/webview/destroy", test_webkit_web_view_destroy);
    254286
    255287    return g_test_run ();
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r55150 r55245  
    77 *  Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
    88 *  Copyright (C) 2008 Nuanti Ltd.
    9  *  Copyright (C) 2008, 2009 Collabora Ltd.
     9 *  Copyright (C) 2008, 2009, 2010 Collabora Ltd.
    1010 *  Copyright (C) 2009 Igalia S.L.
    1111 *  Copyright (C) 2009 Movial Creative Technologies Inc.
     
    677677    WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
    678678
    679     core(webView)->focusController()->setActive(false);
    680     core(webView)->focusController()->setFocused(false);
     679    // We may hit this code while destroying the widget, and we might
     680    // no longer have a page, then.
     681    Page* page = core(webView);
     682    if (page) {
     683        page->focusController()->setActive(false);
     684        page->focusController()->setFocused(false);
     685    }
    681686
    682687    return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
Note: See TracChangeset for help on using the changeset viewer.