[maemo-commits] [maemo-commits] r17541 - in projects/haf/trunk/sapwood: . tests
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Fri Feb 27 17:17:09 EET 2009
- Previous message: [maemo-commits] r17540 - in projects/haf/trunk/sapwood: . tests
- Next message: [maemo-commits] r17542 - in projects/haf/trunk/sapwood: . engine
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: herzi Date: 2009-02-27 17:17:05 +0200 (Fri, 27 Feb 2009) New Revision: 17541 Added: projects/haf/trunk/sapwood/tests/large-window.c projects/haf/trunk/sapwood/tests/large-window.gtkrc Modified: projects/haf/trunk/sapwood/ChangeLog projects/haf/trunk/sapwood/tests/Makefile.am Log: 2009-02-27 Sven Herzberg <herzi at lanedo.com> About NB#103175 - Sapwood crashes when large windows trigger BadAlloc errors Added a testcase * tests/Makefile.am: build and run the testcase * tests/large-window.c (text_view_mapped), (main), * tests/large-window.gtkrc: the testcase files Modified: projects/haf/trunk/sapwood/ChangeLog =================================================================== --- projects/haf/trunk/sapwood/ChangeLog 2009-02-27 15:16:58 UTC (rev 17540) +++ projects/haf/trunk/sapwood/ChangeLog 2009-02-27 15:17:05 UTC (rev 17541) @@ -1,5 +1,16 @@ 2009-02-27 Sven Herzberg <herzi at lanedo.com> + About NB#103175 - Sapwood crashes when large windows trigger BadAlloc + errors + + Added a testcase + + * tests/Makefile.am: build and run the testcase + * tests/large-window.c (text_view_mapped), (main), + * tests/large-window.gtkrc: the testcase files + +2009-02-27 Sven Herzberg <herzi at lanedo.com> + Properly execute tests against the correct modules * tests/Makefile.am: also use the script from the demos folder Modified: projects/haf/trunk/sapwood/tests/Makefile.am =================================================================== --- projects/haf/trunk/sapwood/tests/Makefile.am 2009-02-27 15:16:58 UTC (rev 17540) +++ projects/haf/trunk/sapwood/tests/Makefile.am 2009-02-27 15:17:05 UTC (rev 17541) @@ -12,6 +12,11 @@ double_free_CPPFLAGS=$(AM_CPPFLAGS) $(GIO_CFLAGS) -I$(top_srcdir)/engine double_free_LDADD=$(LDADD) $(GIO_LIBS) +TEST_PROGS+=large-window +large_window_SOURCES=large-window.c +large_window_CPPFLAGS=$(AM_CPPFLAGS) -I$(top_srcdir)/engine -DTOP_SRCDIR=\""$(top_srcdir)"\" +large_window_LDADD=$(LDADD) + EXTRA_DIST+=\ sapwood-wrapper \ $(NULL) Added: projects/haf/trunk/sapwood/tests/large-window.c =================================================================== --- projects/haf/trunk/sapwood/tests/large-window.c 2009-02-27 15:16:58 UTC (rev 17540) +++ projects/haf/trunk/sapwood/tests/large-window.c 2009-02-27 15:17:05 UTC (rev 17541) @@ -0,0 +1,91 @@ +/* This file is part of sapwood + * This file was a part of hildon examples + * + * Copyright (C) 2008,2009 Nokia Corporation, all rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include <gtk/gtk.h> + +static GtkTextBuffer *buffer = NULL; + +static void +text_view_mapped (GtkWidget* widget) +{ + GError* error = NULL; + GMappedFile* file = g_mapped_file_new (TOP_SRCDIR G_DIR_SEPARATOR_S "COPYING", FALSE, &error); + gint i; + + if (error) + { + g_warning ("error opening file: %s", + error->message); + g_error_free (error); + return; + } + + for (i = 0; i < 14; i++) + { + GtkTextIter iter; + gtk_text_buffer_get_end_iter (buffer, &iter); + + gtk_text_buffer_insert (buffer, &iter, + g_mapped_file_get_contents (file), + g_mapped_file_get_length (file)); + } + + g_mapped_file_free (file); +} + +int +main (int argc, + char **argv) +{ + GtkWidget *textview; + GtkWidget *win; + + gtk_rc_add_default_file (TOP_SRCDIR G_DIR_SEPARATOR_S "tests" G_DIR_SEPARATOR_S "large-window.gtkrc"); + gtk_init (&argc, &argv); + + /* Window and vbox to pack everything */ + win = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + /* The text view */ + textview = gtk_text_view_new (); + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); + + /* Pack all widgets */ + gtk_container_set_border_width (GTK_CONTAINER (win), 20); + GtkWidget *pannable_area; + pannable_area = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (pannable_area), GTK_WIDGET (textview)); + gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (pannable_area)); + + /* Connect signals */ + g_signal_connect_after (textview, "realize", + G_CALLBACK (text_view_mapped), NULL); + + g_timeout_add (3000, (GSourceFunc)gtk_main_quit, NULL); + + /* Run example */ + gtk_widget_show_all (win); + gtk_main (); + + return 0; +} + Added: projects/haf/trunk/sapwood/tests/large-window.gtkrc =================================================================== --- projects/haf/trunk/sapwood/tests/large-window.gtkrc 2009-02-27 15:16:58 UTC (rev 17540) +++ projects/haf/trunk/sapwood/tests/large-window.gtkrc 2009-02-27 15:17:05 UTC (rev 17541) @@ -0,0 +1,21 @@ +# Copyright Nokia Corporation 2007 +# Licensed under Creative Commons Attribution-ShareAlike 2.5 license + +pixmap_path "../demos/images" + +style "broken-textview" +{ + GtkWidget::interior-focus = 0 + + engine "sapwood" + { + image + { + function = FOCUS + detail = "textview" + file = "gradient.png" + border = { 29, 29, 34, 34 } + } + } +} +class "GtkTextView" style "broken-textview"
- Previous message: [maemo-commits] r17540 - in projects/haf/trunk/sapwood: . tests
- Next message: [maemo-commits] r17542 - in projects/haf/trunk/sapwood: . engine
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]