acttext = clutter_text_new_full("Monospace 20", (gchar*)data , &white);
==> to split these lines:
clutter_text_set_font_name(CLUTTER_TEXT(acttext), "Monospace 20");
clutter_text_set_color(CLUTTER_TEXT(acttext), &white);
// clutter_text_set_text() will raise pango problem, cause segmentation fault
clutter_text_set_text(CLUTTER_TEXT(acttext), "text");

the result is: in thread function the text will have pango problem.
But if you had already used/load such " Monospace 20" font in main thread 
(clutter_text_new_full and clutter_actor_get_width), it'll be ok in the new 
thread.
So the clutter library may not thread safe.

Mit freundlichen Grüßen / Best regards
BeQIK

Charles
RBAC/CM/ESW1-CN

-----Original Message-----
From: clutter-app-devel-list-boun...@clutter-project.org 
[mailto:clutter-app-devel-list-boun...@clutter-project.org] On Behalf Of 
david.sale.75
Sent: Saturday, May 12, 2012 1:29 PM
To: clutter-app
Subject: Can not get actor width in the thread ?

Hi, all:

I write a test demo, use clutter_actor_get_width() get actor width, it is 
correct
if in the main thread call, but incorrect in then new thread.
used  clutter-1.6.20 and pango-1.28.4 and glib2-2.28.6

Pango:ERROR:pango-layout.c:3743:pango_layout_check_lines: assertion failed: 
(!layout->log_attrs)
The code is what problem? have any error?  Tks.

#include <glib.h>
#include <clutter/clutter.h>
ClutterActor *gStage, *acttext=NULL;
ClutterColor white = {255, 255, 255, 255};
ClutterColor black = {0, 0, 0, 0};

static gpointer test(gpointer data)
{
gfloat ww;
if (acttext)
clutter_container_remove_actor(CLUTTER_CONTAINER(gStage), acttext);
acttext = clutter_text_new_full("Monospace 20", (gchar*)data , &white);
clutter_text_set_single_line_mode(CLUTTER_TEXT(acttext), TRUE);
clutter_container_add_actor(CLUTTER_CONTAINER(gStage), acttext);
clutter_actor_set_position(acttext, 100, 100);

//why not get width
//if use clutter_actor_get_width(acttext);
//Pango:ERROR:pango-layout.c:3743:pango_layout_check_lines: assertion failed: 
(!layout->log_attrs)
clutter_actor_get_width(acttext);
g_print("act width: %d \n", acttext);

}

int main(int argc, char* argv[])
{
GThread *threadid;
gchar text[128];
g_thread_init(NULL);
clutter_threads_init();
clutter_init(&argc, &argv);

gStage = clutter_stage_get_default();
clutter_actor_set_size(gStage, 600, 400);
clutter_stage_set_color(CLUTTER_STAGE(gStage), &black);
clutter_actor_show(gStage);
sprintf(text, "TEST TEST TEST TEST");
threadid = g_thread_create(test, (gpointer)text, FALSE, NULL);

clutter_main();

}

--------------
david.sale.75
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list@clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list
_______________________________________________
clutter-app-devel-list mailing list
clutter-app-devel-list@clutter-project.org
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to