[win32] Glib::IOChannel error?



Hi all,

I'm writing a crossplatform program that executes another application
and reads from it's output. I'm using Glib::spawn_async_with_pipes to
solve the process handling and i handle the pipes with Glib::IOChannel.
The problem is that, if the application writes a string to it's output
that contains central-european characters (like: á, é, ü, ő, etc.) than
Glib::IOChannel::read_line throws the following exception:

glibmm-CRITICAL ** :
unhandled exception (type: Glib::Error) in signal handler:
domain: g_convert_error
code: 1
what: invalid byte sequence in conversion input   /the message is
localized so i tried to translate it to english, hope it's fits to the
original message/

I have to use central-european charset, but i don't have any idea, how
to solve this problem. Furthermore i can't catch any exceptions
/Glib::IOChannelError or Glib::ConvertError, nor Glib::Error/, except (...).
This exception thrown only on windows; on linux everything works
perfectly. I'm using MinGW compiler (gcc-4.2.1-sjlj-2,
mingw32-make-3.81, mingwrt-3.15, w32api-3.12, binutils-2.18.50),
gtk-2.14.4-1, gtkmm-2.14.1-3 and windows-1250 charset.

The code:
void ProcessHandler::spawn(const Glib::ArrayHandle<std::string>& argv)
{
  try {
    Glib::spawn_async_with_pipes(Glib::get_current_dir(),
                                 argv,
Glib::SpawnFlags(0)|Glib::SPAWN_SEARCH_PATH,
                                 sigc::slot<void>(),
                                 &child_,&stdin_,&stdout_,&stderr_);
  } catch (Glib::SpawnError& ex) {...}
  } catch (Glib::Error& ex) {...}
  ...
#ifdef WIN32 
  ioch_in_=Glib::IOChannel::create_from_win32_fd(stdin_);
  ioch_out_=Glib::IOChannel::create_from_win32_fd(stdout_);
  ioch_err_=Glib::IOChannel::create_from_win32_fd(stderr_);
#else
  ioch_in_=Glib::IOChannel::create_from_fd(stdin_);
  ioch_out_=Glib::IOChannel::create_from_fd(stdout_);
  ioch_err_=Glib::IOChannel::create_from_fd(stderr_);
#endif
}

Glib::IOStatus ProcessHandler::read_line_from_out(Glib::ustring& str)
{
    try {
        return ioch_out_->read_line(str);
    } catch (Glib::IOChannelError& ex)  {...}
    } catch (Glib::ConvertError& ex)  {...}
    } catch (Glib::Error& ex)  {...}
    } catch (...) {...}

Thanks for any help,
Eszter Kontos


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]