attempt to convert text from locale encoding.
2003-06-25 Sven Neumann <sven@gimp.org> * app/text/gimptext-parasite.c (gimp_text_from_gdyntext_parasite): attempt to convert text from locale encoding. * app/vectors/gimpvectors-compat.c (gimp_vectors_compat_new): allow paths with zero points (bug # 115955). * plug-ins/script-fu/script-fu-server.c: if a connection to a client is lost, invalidate file descriptors in the command queue. Plugged a couple of memleaks.
This commit is contained in:

committed by
Sven Neumann

parent
043bfd25b3
commit
4e4b91eda1
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2003-06-25 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/text/gimptext-parasite.c (gimp_text_from_gdyntext_parasite):
|
||||||
|
attempt to convert text from locale encoding.
|
||||||
|
|
||||||
|
* app/vectors/gimpvectors-compat.c (gimp_vectors_compat_new):
|
||||||
|
allow paths with zero points (bug # 115955).
|
||||||
|
|
||||||
|
* plug-ins/script-fu/script-fu-server.c: if a connection to a
|
||||||
|
client is lost, invalidate file descriptors in the command queue.
|
||||||
|
Plugged a couple of memleaks.
|
||||||
|
|
||||||
2003-06-25 Sven Neumann <sven@gimp.org>
|
2003-06-25 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/text/gimptext-xlfd.[ch]: added convenience function
|
* app/text/gimptext-xlfd.[ch]: added convenience function
|
||||||
|
@ -159,9 +159,16 @@ gimp_text_from_gdyntext_parasite (const GimpParasite *parasite)
|
|||||||
|
|
||||||
if (! g_utf8_validate (text, -1, NULL))
|
if (! g_utf8_validate (text, -1, NULL))
|
||||||
{
|
{
|
||||||
g_message (_("Can not convert GDynText layer because it "
|
gchar *utf8_str;
|
||||||
"contains text that is not UTF-8 encoded."));
|
|
||||||
goto cleanup;
|
utf8_str = g_locale_to_utf8 (text, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
g_free (text);
|
||||||
|
|
||||||
|
if (utf8_str)
|
||||||
|
text = utf8_str;
|
||||||
|
else
|
||||||
|
text = g_strdup (_("(invalid UTF-8 string)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
antialias = atoi (params[ANTIALIAS]) ? TRUE : FALSE;
|
antialias = atoi (params[ANTIALIAS]) ? TRUE : FALSE;
|
||||||
|
@ -58,8 +58,8 @@ gimp_vectors_compat_new (GimpImage *gimage,
|
|||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||||
g_return_val_if_fail (name != NULL, NULL);
|
g_return_val_if_fail (name != NULL, NULL);
|
||||||
g_return_val_if_fail (points != NULL, NULL);
|
g_return_val_if_fail (points != NULL || n_points == 0, NULL);
|
||||||
g_return_val_if_fail (n_points > 0, NULL);
|
g_return_val_if_fail (n_points >= 0, NULL);
|
||||||
|
|
||||||
vectors = gimp_vectors_new (gimage, name);
|
vectors = gimp_vectors_new (gimage, name);
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ gimp_vectors_compat_new (GimpImage *gimage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
stroke = gimp_bezier_stroke_new_from_coords (curr_stroke,
|
stroke = gimp_bezier_stroke_new_from_coords (curr_stroke,
|
||||||
curr_coord - curr_stroke ,
|
curr_coord - curr_stroke,
|
||||||
closed);
|
closed);
|
||||||
gimp_vectors_stroke_add (vectors, stroke);
|
gimp_vectors_stroke_add (vectors, stroke);
|
||||||
g_object_unref (stroke);
|
g_object_unref (stroke);
|
||||||
|
@ -243,7 +243,8 @@ script_fu_server_listen (gint timeout)
|
|||||||
else
|
else
|
||||||
tvp = NULL;
|
tvp = NULL;
|
||||||
|
|
||||||
/* Block until input arrives on one or more active sockets or timeout occurs. */
|
/* Block until input arrives on one or more active sockets
|
||||||
|
or timeout occurs. */
|
||||||
server_read = server_active;
|
server_read = server_active;
|
||||||
if (select (FD_SETSIZE, &server_read, NULL, NULL, tvp) < 0)
|
if (select (FD_SETSIZE, &server_read, NULL, NULL, tvp) < 0)
|
||||||
{
|
{
|
||||||
@ -274,11 +275,9 @@ script_fu_server_listen (gint timeout)
|
|||||||
g_hash_table_insert (clientname_ht,
|
g_hash_table_insert (clientname_ht,
|
||||||
GINT_TO_POINTER (new),
|
GINT_TO_POINTER (new),
|
||||||
g_strdup (inet_ntoa (clientname.sin_addr)));
|
g_strdup (inet_ntoa (clientname.sin_addr)));
|
||||||
/*
|
|
||||||
server_log ("Server: connect from host %s, port %d.\n",
|
server_log ("Server: connect from host %s, port %d.\n",
|
||||||
inet_ntoa (clientname.sin_addr),
|
inet_ntoa (clientname.sin_addr),
|
||||||
(unsigned int) ntohs (clientname.sin_port));
|
(unsigned int) ntohs (clientname.sin_port));
|
||||||
*/
|
|
||||||
|
|
||||||
FD_SET (new, &server_active);
|
FD_SET (new, &server_active);
|
||||||
}
|
}
|
||||||
@ -286,18 +285,28 @@ script_fu_server_listen (gint timeout)
|
|||||||
{
|
{
|
||||||
if (read_from_client (i) < 0)
|
if (read_from_client (i) < 0)
|
||||||
{
|
{
|
||||||
|
GList *list;
|
||||||
|
|
||||||
/* Disassociate the client address with the socket */
|
/* Disassociate the client address with the socket */
|
||||||
g_hash_table_remove (clientname_ht, GINT_TO_POINTER (i));
|
g_hash_table_remove (clientname_ht, GINT_TO_POINTER (i));
|
||||||
|
|
||||||
/*
|
|
||||||
server_log ("Server: disconnect from host %s, port %d.\n",
|
server_log ("Server: disconnect from host %s, port %d.\n",
|
||||||
inet_ntoa (clientname.sin_addr),
|
inet_ntoa (clientname.sin_addr),
|
||||||
(unsigned int) ntohs (clientname.sin_port));
|
(unsigned int) ntohs (clientname.sin_port));
|
||||||
*/
|
|
||||||
|
|
||||||
close (i);
|
close (i);
|
||||||
FD_CLR (i, &server_active);
|
FD_CLR (i, &server_active);
|
||||||
}
|
|
||||||
|
/* Invalidate the file descriptor for pending commands
|
||||||
|
from the disconnected client. */
|
||||||
|
for (list = command_queue; list; list = list->next)
|
||||||
|
{
|
||||||
|
SFCommand *cmd = (SFCommand *) command_queue->data;
|
||||||
|
|
||||||
|
if (cmd->filedes == i)
|
||||||
|
cmd->filedes = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,20 +315,8 @@ static void
|
|||||||
server_start (gint port,
|
server_start (gint port,
|
||||||
gchar *logfile)
|
gchar *logfile)
|
||||||
{
|
{
|
||||||
SFCommand *cmd;
|
/* First of all, create the socket and set it up to accept connections. */
|
||||||
|
/* This may fail if there's a server running on this port already. */
|
||||||
/* Set up the clientname hash table */
|
|
||||||
clientname_ht = g_hash_table_new (g_direct_hash, NULL);
|
|
||||||
|
|
||||||
/* Setup up the server log file */
|
|
||||||
if (logfile)
|
|
||||||
server_log_file = fopen (logfile, "a");
|
|
||||||
else
|
|
||||||
server_log_file = NULL;
|
|
||||||
if (server_log_file == NULL)
|
|
||||||
server_log_file = stdout;
|
|
||||||
|
|
||||||
/* Create the socket and set it up to accept connections. */
|
|
||||||
server_sock = make_socket (port);
|
server_sock = make_socket (port);
|
||||||
if (listen (server_sock, 5) < 0)
|
if (listen (server_sock, 5) < 0)
|
||||||
{
|
{
|
||||||
@ -327,6 +324,20 @@ server_start (gint port,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Setup up the server log file */
|
||||||
|
if (logfile && *logfile)
|
||||||
|
server_log_file = fopen (logfile, "a");
|
||||||
|
else
|
||||||
|
server_log_file = NULL;
|
||||||
|
|
||||||
|
if (! server_log_file)
|
||||||
|
server_log_file = stdout;
|
||||||
|
|
||||||
|
/* Set up the clientname hash table */
|
||||||
|
clientname_ht = g_hash_table_new_full (g_direct_hash, NULL,
|
||||||
|
NULL,
|
||||||
|
(GDestroyNotify) g_free);
|
||||||
|
|
||||||
server_log ("Script-fu initialized and listening...\n");
|
server_log ("Script-fu initialized and listening...\n");
|
||||||
|
|
||||||
/* Initialize the set of active sockets. */
|
/* Initialize the set of active sockets. */
|
||||||
@ -340,8 +351,7 @@ server_start (gint port,
|
|||||||
|
|
||||||
while (command_queue)
|
while (command_queue)
|
||||||
{
|
{
|
||||||
/* Get the current command */
|
SFCommand *cmd = (SFCommand *) command_queue->data;
|
||||||
cmd = (SFCommand *) command_queue->data;
|
|
||||||
|
|
||||||
/* Process the command */
|
/* Process the command */
|
||||||
execute_command (cmd);
|
execute_command (cmd);
|
||||||
@ -357,10 +367,6 @@ server_start (gint port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
server_quit ();
|
server_quit ();
|
||||||
|
|
||||||
/* Close the server log file */
|
|
||||||
if (server_log_file != stdout)
|
|
||||||
fclose (server_log_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -374,7 +380,6 @@ execute_command (SFCommand *cmd)
|
|||||||
gboolean error;
|
gboolean error;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
/* Get the client address from the address/socket table */
|
|
||||||
server_log ("Processing request #%d\n", cmd->request_no);
|
server_log ("Processing request #%d\n", cmd->request_no);
|
||||||
time (&clock1);
|
time (&clock1);
|
||||||
|
|
||||||
@ -406,7 +411,7 @@ execute_command (SFCommand *cmd)
|
|||||||
|
|
||||||
/* Write the response to the client */
|
/* Write the response to the client */
|
||||||
for (i = 0; i < RESPONSE_HEADER; i++)
|
for (i = 0; i < RESPONSE_HEADER; i++)
|
||||||
if (write (cmd->filedes, buffer + i, 1) < 0)
|
if (cmd->filedes > 0 && write (cmd->filedes, buffer + i, 1) < 0)
|
||||||
{
|
{
|
||||||
/* Write error */
|
/* Write error */
|
||||||
perror ("write");
|
perror ("write");
|
||||||
@ -414,7 +419,7 @@ execute_command (SFCommand *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < response_len; i++)
|
for (i = 0; i < response_len; i++)
|
||||||
if (write (cmd->filedes, response + i, 1) < 0)
|
if (cmd->filedes > 0 && write (cmd->filedes, response + i, 1) < 0)
|
||||||
{
|
{
|
||||||
/* Write error */
|
/* Write error */
|
||||||
perror ("write");
|
perror ("write");
|
||||||
@ -499,8 +504,9 @@ read_from_client (gint filedes)
|
|||||||
time (&clock);
|
time (&clock);
|
||||||
server_log ("Received request #%d from IP address %s: %s on %s,"
|
server_log ("Received request #%d from IP address %s: %s on %s,"
|
||||||
"[Request queue length: %d]",
|
"[Request queue length: %d]",
|
||||||
cmd->request_no, clientaddr, cmd->command, ctime (&clock),
|
cmd->request_no,
|
||||||
queue_length);
|
clientaddr ? clientaddr : "<invalid>",
|
||||||
|
cmd->command, ctime (&clock), queue_length);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -519,7 +525,7 @@ make_socket (guint port)
|
|||||||
perror ("socket");
|
perror ("socket");
|
||||||
gimp_quit ();
|
gimp_quit ();
|
||||||
}
|
}
|
||||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(v));
|
setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(v));
|
||||||
|
|
||||||
/* Give the socket a name. */
|
/* Give the socket a name. */
|
||||||
name.sin_family = AF_INET;
|
name.sin_family = AF_INET;
|
||||||
@ -559,6 +565,27 @@ server_quit (void)
|
|||||||
for (i = 0; i < FD_SETSIZE; ++i)
|
for (i = 0; i < FD_SETSIZE; ++i)
|
||||||
if (FD_ISSET (i, &server_active))
|
if (FD_ISSET (i, &server_active))
|
||||||
shutdown (i, 2);
|
shutdown (i, 2);
|
||||||
|
|
||||||
|
g_hash_table_destroy (clientname_ht);
|
||||||
|
clientname_ht = NULL;
|
||||||
|
|
||||||
|
while (command_queue)
|
||||||
|
{
|
||||||
|
SFCommand *cmd = (SFCommand *) command_queue->data;
|
||||||
|
|
||||||
|
g_free (cmd->command);
|
||||||
|
g_free (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (command_queue);
|
||||||
|
command_queue = NULL;
|
||||||
|
queue_length = 0;
|
||||||
|
|
||||||
|
/* Close the server log file */
|
||||||
|
if (server_log_file != stdout)
|
||||||
|
fclose (server_log_file);
|
||||||
|
|
||||||
|
server_log_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -576,11 +603,12 @@ server_interface (void)
|
|||||||
GTK_WIN_POS_MOUSE,
|
GTK_WIN_POS_MOUSE,
|
||||||
FALSE, TRUE, FALSE,
|
FALSE, TRUE, FALSE,
|
||||||
|
|
||||||
GTK_STOCK_OK, ok_callback,
|
|
||||||
NULL, NULL, NULL, TRUE, FALSE,
|
|
||||||
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
GTK_STOCK_CANCEL, gtk_widget_destroy,
|
||||||
NULL, 1, NULL, FALSE, TRUE,
|
NULL, 1, NULL, FALSE, TRUE,
|
||||||
|
|
||||||
|
GTK_STOCK_OK, ok_callback,
|
||||||
|
NULL, NULL, NULL, TRUE, FALSE,
|
||||||
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_signal_connect (dlg, "destroy",
|
g_signal_connect (dlg, "destroy",
|
||||||
@ -611,7 +639,6 @@ server_interface (void)
|
|||||||
gtk_widget_show (dlg);
|
gtk_widget_show (dlg);
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
gdk_flush ();
|
|
||||||
|
|
||||||
return sint.run;
|
return sint.run;
|
||||||
}
|
}
|
||||||
@ -620,6 +647,8 @@ static void
|
|||||||
ok_callback (GtkWidget *widget,
|
ok_callback (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
g_free (sint.logfile);
|
||||||
|
|
||||||
sint.port = atoi (gtk_entry_get_text (GTK_ENTRY (sint.port_entry)));
|
sint.port = atoi (gtk_entry_get_text (GTK_ENTRY (sint.port_entry)));
|
||||||
sint.logfile = g_strdup (gtk_entry_get_text (GTK_ENTRY (sint.log_entry)));
|
sint.logfile = g_strdup (gtk_entry_get_text (GTK_ENTRY (sint.log_entry)));
|
||||||
sint.run = TRUE;
|
sint.run = TRUE;
|
||||||
|
Reference in New Issue
Block a user