Problems reading from IOChannel
- From: "Javier Aranega" <javi aranega gmail com>
- To: gtkmm-list gnome org
- Subject: Problems reading from IOChannel
- Date: Mon, 11 Sep 2006 13:03:46 +0200
Hi!
I have a problem using Glib::IOChannel in my application, sometimes when I try to read from de IOChannel I have this exception (
ILLEGAL_SEQUENCE)
glibmm-CRITICAL **:
unhandled exception (type Glib::Error) in signal handler:
domain: g_convert_error
code : 1
what : Hay una secuencia de bytes no válida en la entrada de conversión
I use IOChannel like this:
*Case 1: Trying to read a text file
using namespace Glib;
IOStatus estado;
ustring linea;
ustring textomodelo;
RefPtr<IOChannel> io;
try {
io = IOChannel::create_from_file(parametros.getCadenaFicheroModelo(), "r");
estado = IO_STATUS_NORMAL;
textomodelo = "";
while (estado!=IO_STATUS_EOF){
estado = io->read_line(linea);
textomodelo+=linea;
}
} catch (FileError e){
std::cout<<"No existe el fichero de modelo"<<std::endl;
}
The file that I try to read is a text file with ascii characters.
*Case 2: Using IOChannel with pipes to send/receive text between processes, in this case sometimes I get the
BROKEN_PIPE exception
channelMidi2Som = Glib::IOChannel::create_from_fd(pipe_m2s_padre[0]);
channelSalida = Glib::IOChannel::create_from_fd(pipe_padre_clas[1]);
channelClasificador = Glib::IOChannel::create_from_fd(pipe_clas_padre[0]);
//Recibo, almaceno y reenvio los datos de m2s
while (estado!=Glib::IO_STATUS_EOF){
estado = channelMidi2Som->read_line(linea);
if (estado!=Glib::IO_STATUS_EOF) {
almacenaMuestrasm2s(linea);
channelSalida->write(linea);
//std::cout<<"Linea m2s: "<<linea<<std::endl;
}
resultadoMidi2Som+=linea;
}
channelSalida->close(true);
channelMidi2Som->close(true);
wait(NULL);
//Recibo y almaceno los datos del clasificador
estado = Glib::IO_STATUS_NORMAL;
while (estado!=Glib::IO_STATUS_EOF){
estado = channelClasificador->read_line(linea);
if (estado!=Glib::IO_STATUS_EOF) {
almacenaMuestrasClasificador(linea, parametros.getTipoClasificador());
std::cout<<"Linea Clasificador: "<<linea<<std::endl;
}
resultadoClasificador+=linea;
}
channelClasificador->close(true);
This code work well in the most of the cases, but sometimes I get this
exception, I guess that could be some problem with the characters that
I read, but I don't understand because sometimes works sometimes I get
the exception if I work with normal characters (ascii). I have tried
some validate methods, but it doesn't work. How I could know what
really causes the problem? Someone have idea of how to fix that
problem? Any suggestion?
Thanks in advance.
Javi Aránega
U. de Alicante
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]