Re: Glib::ustring::format throws exception



On Thu, 17 Feb 2011 15:26:02 +0100
Yggi Rebuet <yggi hotmail com> wrote:

> 
> 
> 
> Hello.
> The following code throws an exception:
> 
> #include
> 
> int main(int argc, char* argv[])
> {
>     Gtk::Main MainObj(argc, argv);
>     int i = 1;
>     const Glib::ustring label = Glib::ustring::format(i);
>     //or: const Glib::ustring label = Glib::ustring::compose("%1", i);
>     Gtk::Window WindowObj;
>     WindowObj.set_title(label);
>     MainObj.run(WindowObj);
>     return 0;
> }
> 
> The Debugger marks the line "return buf.to_string();" here:
> 
> template
> inline // static
> ustring ustring::format(const T1& a1)
> {
>   ustring::FormatStream buf;
>   buf.stream(a1);
>   return buf.to_string();
> }
> 
> I get an Error from Glib::ConvertError.
> 
> I'm using Windows 7 64bit with MSVC10 and Gtkmm 2.4 32 (Binary
> Package was used). However everything works great except this
> conversion problem. 

Does it work OK if you initialise the locale with
std::locale::global(std::locale("")); ?

I have found that some of the glib conversion functions do not work
correctly without this (although I have to say I don't see why it
should be relevant to this particular case).

Chris


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