Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, January 2008
some puzzeling problem with Qt-snaphot


Message 1 in thread

Hi,

I tried to use one of the current Qt snaphots for X11 in order to get the
new GraphicsView stuff (embedded widgets and the like). 
When I compile my application with the snapshot, it malfunctions in
certains ways. I traced one of the crashes back and the puzzeling thing is
that std::atof from stdlib.h, when compiling with the snapshot, doesn't
extract a float from the c-string. While with the 4.3.3 version c-strings
like "0.43" get correctly extracted, with the snapshot it just returns 0
or 1 if the string was "1".

Now this sounds kind of stupid as the Qt-snaphot shouldn't have anything
to do with stdlib.h, but if I compile it against 4.3.3 it just works as
it's supposed to.

Has anybody an idea what this is about, or what I'm doing wrong ? Because
I gave up now trying to find a reason (for this particular error) and
would wait for the final release of 4.4, but couldn't proceed until then
doing the parts of my application which look better if I don't have to use
the qgraphicswidgetitem-workaround from the GraphicsView-blog.

any help or ideas - what to check further - are appreciated

Michael

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 2 in thread

Hi,

On Thursday 17 January 2008, Michael Berg wrote:

> Has anybody an idea what this is about, or what I'm doing wrong ? Because
> I gave up now trying to find a reason (for this particular error) and
> would wait for the final release of 4.4, but couldn't proceed until then
> doing the parts of my application which look better if I don't have to use
> the qgraphicswidgetitem-workaround from the GraphicsView-blog.
>
> any help or ideas - what to check further - are appreciated

I recently had some similar strange things - which I cured by doing
make clean && make

-- 
 [ signature omitted ] 

Message 3 in thread

>> Has anybody an idea what this is about, or what I'm doing wrong ?  
>> Because
>> I gave up now trying to find a reason (for this particular error) and
>> would wait for the final release of 4.4, but couldn't proceed until then
>> doing the parts of my application which look better if I don't have to  
>> use
>> the qgraphicswidgetitem-workaround from the GraphicsView-blog.
>>
>> any help or ideas - what to check further - are appreciated
>
> I recently had some similar strange things - which I cured by doing
> make clean && make

:-) Unfortunately something like that didn't work.

The crazy (maybe crazy/stupid me) thing is that compiling against 4.3.3  
makes atof do the right thing. So I was hoping that some (probably more  
knowledgeable in the Linux/Qt business) guys (eg. from Trolltech) have an  
idea. Because the error is so senseless I'm not even sure it will go away  
in the 4.4 release version - which kind of implies it could be my mistake.

Michael


To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 4 in thread

On Thursday 17 January 2008, Michael Berg wrote:

> The crazy (maybe crazy/stupid me) thing is that compiling against 4.3.3
> makes atof do the right thing. So I was hoping that some (probably more
> knowledgeable in the Linux/Qt business) guys (eg. from Trolltech) have an
> idea. Because the error is so senseless I'm not even sure it will go away
> in the 4.4 release version - which kind of implies it could be my mistake.

Can you provide a short testprogram which shows that behaviour ?
So I could try it here with my snaphot.

-- 
 [ signature omitted ] 

Message 5 in thread

Martin,

thanks for your help. I do appreciate it.

> Can you provide a short testprogram which shows that behaviour ?

Unfortunately not. This belongs to the category, that I don't know what's  
happening. I tried to make a short test today along the lines of "int  
main(int, char**){cout << std::atof("0.43")}", but this (of course one is  
tempted to say) worked in all cases (as there is no Qt involved). So it  
must be some kind of interaction between "whatever". Maybe I spend  
tomorrow some time to strip that part of my app down until the error  
vanishes and I can isolate it.

> So I could try it here with my snaphot.

Thanks again. :-)


Michael




To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 6 in thread

atof is depending on setlocale - maybe 4.4 sets a locale that has something else than "." as the decimal point? (like the german locale, where you would have "0,43" instead of "0.43".

This is just a wild guess, hope it helps.

Cheers,
Peter

> -----Ursprüngliche Nachricht-----
> Von: Michael Berg [mailto:michael.berg@xxxxxx] 
> Gesendet: Donnerstag, 17. Januar 2008 15:43
> An: qt4-preview-feedback@xxxxxxxxxxxxx
> Betreff: some puzzeling problem with Qt-snaphot
> 
> Hi,
> 
> I tried to use one of the current Qt snaphots for X11 in 
> order to get the
> new GraphicsView stuff (embedded widgets and the like). 
> When I compile my application with the snapshot, it malfunctions in
> certains ways. I traced one of the crashes back and the 
> puzzeling thing is
> that std::atof from stdlib.h, when compiling with the 
> snapshot, doesn't
> extract a float from the c-string. While with the 4.3.3 
> version c-strings
> like "0.43" get correctly extracted, with the snapshot it 
> just returns 0
> or 1 if the string was "1".
> 
> Now this sounds kind of stupid as the Qt-snaphot shouldn't 
> have anything
> to do with stdlib.h, but if I compile it against 4.3.3 it 
> just works as
> it's supposed to.
> 
> Has anybody an idea what this is about, or what I'm doing 
> wrong ? Because
> I gave up now trying to find a reason (for this particular error) and
> would wait for the final release of 4.4, but couldn't proceed 
> until then
> doing the parts of my application which look better if I 
> don't have to use
> the qgraphicswidgetitem-workaround from the GraphicsView-blog.
> 
> any help or ideas - what to check further - are appreciated
> 
> Michael
> 
> To unsubscribe - send "unsubscribe" in the subject to 
> qt4-preview-feedback-request@xxxxxxxxxxxxx
> 
> 

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 7 in thread

> atof is depending on setlocale - maybe 4.4 sets a locale that has  
> something else than "." as the decimal point? (like the german locale,  
> where you would have "0,43" instead of "0.43".
>
> This is just a wild guess, hope it helps.
>
> Cheers,
> Peter

Cool, that sounds like a good possibility. This would explain the a "1"  
getting a 1 and the "0.43" getting a 0.
I gonna check it tomorrow.

Thanks a lot.

Michael

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 8 in thread

Hi,

> I tried to use one of the current Qt snaphots for X11 in order to get the
> new GraphicsView stuff (embedded widgets and the like). 
> When I compile my application with the snapshot, it malfunctions in
> certains ways. I traced one of the crashes back and the puzzeling thing is
> that std::atof from stdlib.h, when compiling with the snapshot, doesn't
> extract a float from the c-string. While with the 4.3.3 version c-strings
> like "0.43" get correctly extracted, with the snapshot it just returns 0
> or 1 if the string was "1".

I think "0" is correct under a German locale:
	0.43 -> 0
	0,43 -> 0,43

The behavior is correct with Qt 4.4, it used to be broken with Qt 4.3, and the 
broken behavior has been fixed. That's maybe not what you wanted to hear...

> [...]
> any help or ideas - what to check further - are appreciated


The only way to modify the result of atof I'm aware of (short of memory 
errors, broken coprocessor, etc.) is modifying the locale.

I ran the following command in the 4.3 and 4.4 branches:
	fgrep setlocale src/*/*/*.cpp
and found one less occurrence of setlocale in 4.4 in qcoreapplication.cpp:
	setlocale(LC_NUMERIC, "C");

This was removed just a few months ago and the relevant comment is:
	The numerical locale being the POSIX locale in
	QCoreApplication::init() seems to be a largely
	historical consideration, which was necessary
	before the introduction of QLocale in Qt 3.3.
	Problems can consequently arise when Qt is used
	in conjunction with 3rd party libraries which
	respect the system numerical locale.

--
 [ signature omitted ] 

Message 9 in thread

> The behavior is correct with Qt 4.4, it used to be broken with Qt 4.3, and 
> the 
> broken behavior has been fixed. That's maybe not what you wanted to hear...

It doesn't matter much what I want to hear. :-) I have to do what works.

> The only way to modify the result of atof I'm aware of (short of memory 
> errors, broken coprocessor, etc.) is modifying the locale.
> 
> I ran the following command in the 4.3 and 4.4 branches:
> 	fgrep setlocale src/*/*/*.cpp
> and found one less occurrence of setlocale in 4.4 in qcoreapplication.cpp:
> 	setlocale(LC_NUMERIC, "C");
> 
> This was removed just a few months ago and the relevant comment is:
> 	The numerical locale being the POSIX locale in
> 	QCoreApplication::init() seems to be a largely
> 	historical consideration, which was necessary
> 	before the introduction of QLocale in Qt 3.3.
> 	Problems can consequently arise when Qt is used
> 	in conjunction with 3rd party libraries which
> 	respect the system numerical locale.

So thanks a lot to everybody who made suggestions and helped. It's
really that simple. In 4.4 the locale is set completely to
the system depending values (in my case de_DE.utf8).

http://www.cplusplus.com/reference/clibrary/clocale/setlocale.html
tells that setlocale(LC_NUMERIC, "C") is there to make things predictable.
So the 4.4 policy is now that only the current locale settings matter and
the developer has to take care of that before doing any parsing (with atof
for example).
So can I expect it will stay that way ? Because the reasoning in the
webpage makes some sense, so does the above comment. And I guess this can
cause quite some trouble with existing libraries in either way - just
because people (like me until now) didn't conciously take care of locale
settings. (Which is - of course - no excuse, so probably the 4.4
way is in the end the correct one.)

Michael

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx