Problem with "locale.h"

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
darwusch
Posts: 23
Joined: 2004-03-19 12:57

Problem with "locale.h"

Post by darwusch » 2004-08-19 16:41

Very strange what's happening here...
When I set the "open public hubs at startup" on, it just doesn't do it.
The setting is set to off when I restart DC++ and look in the settings !

Both when I use the 0.4032 version and when I compile it myself.

But...

When I comment the line
setlocale(LC_ALL, "");
in Util.cpp

and compile it, the public hub window opens on startup,
but then the hub list is not downloaded...
The list keeps "downloading" the hublist (there is no data coming in cause the download speed stays zero)
Also, no time out occurs.

I think this locale.h does something with the local settings ?
Mine are set to location Netherlands and the non-unicode settings are set to US.

I use windows xp sp2
Windows firewall is disabled. I only use Norton. When I disable it, no change.

Anybody understands this ?
(I won't ask "why" anymore in this forum... :-) )
Last edited by darwusch on 2004-08-20 02:49, edited 1 time in total.

darwusch
Posts: 23
Joined: 2004-03-19 12:57

Post by darwusch » 2004-08-20 02:12

An important addition is that if I commented the setlocale(LC_ALL, "");
and compile, the public hublist DOES download if I run DC++ through the compiler...
Only when I start it again (not through the compiler) it doesn't.

/edit

I just found out that this behaviour is caused by the delay the firewall gives the first time the program is used.
When I compile it, the firewall pops up and when I allow it, all goes.
But when I start it again directly, no hublist.

Now when I remove DCPlusPlus.exe from the firewall list and start it again, then allow it again when Norton pops up:
All goes...

This means that (assuming there is nothing wrong with Norton firewall, because disabled the problem remains) the delay of the "asking" of the firewall gives enough time for something else to prevent the problem from coming.

Can anybody still follow me ?

darwusch
Posts: 23
Joined: 2004-03-19 12:57

Post by darwusch » 2004-08-20 09:43

After a lot of testing, here is some extra info:

In DCPlusPlus.cpp the following contradiction occurs:

Code: Select all

	if(v <= 0.22) {
		// Disable automatic public hublist opening
		SettingsManager::getInstance()->set(SettingsManager::OPEN_PUBLIC, false);
	}
While v = 0.401, it thinks that this is smaller than 0.22....!!!!!

I tested it by making it:

Code: Select all

if(v >= 0.22)
And then the public hub frame opens at startup !

So it thinks that 0.22 is bigger than 0.401 !!
And all beacuse of
setlocale(LC_ALL, "");


Furthermore, when the public hub frame opens at startup, it doesn't download the hub list (see above posts)
But when I set DC++ to not open the public hub frame at startup, and open it manually, it downloads the hub list fine...

Please help me out here people... I'm too confused about it.

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-08-20 10:09

You followed it all the way to that point, but you didn't come to the same conclusion that I did.

Did you see what the value of v was? I will bet that it's 0. Zero is less than 0.22.

You know why?

Code: Select all

<ConfigVersion type="string">0.4032</ConfigVersion>
Util::toDouble(), or specifically, atof, may not handle , as the decimal separator. Util::initialize(), where the locale is set, is called before the SettingManager is instantiated, so that shouldn't be the problem. A "fix" would be to replace the , in the string in ::toDouble() with ..

darwusch
Posts: 23
Joined: 2004-03-19 12:57

Post by darwusch » 2004-08-20 13:39

Thanks a lot for helping me garg !

What you say makes sense to me.
I will try it also.
At this moment I just commented out both complete

Code: Select all

if(v <= 0.22)
and

Code: Select all

if(v <= 0.251)
checks (including the code below it), since the version is above that anyway and nothing else should happen.

Now the other problem:
The window opened but no hublist was downloaded (eternal "downloading", no actual data traffic or time outs / errors)

I "fixed" this by putting a delay of 1 second in the

Code: Select all

LRESULT PublicHubsFrame::onCreate
just before it wants to download with

Code: Select all

HubManager::getInstance()->addListener(this);
It looks like:

Code: Select all

	u_int32_t now = GET_TICK();
	now = GET_TICK() - now;
	if(now < 1000){
		Sleep(1000 - now);
	}

This is a *very* ugly hack...
Do you have a better idea ?

Thanks !

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-08-24 11:37

darwusch wrote:This is a *very* ugly hack...
Do you have a better idea ?
Well, hmm.

You could always move the window opening down a little further in MainFrame::OnCreate(). Do you have a lot of favorite hubs in HubManager? I'm not sure why loading would take that long...

darwusch
Posts: 23
Joined: 2004-03-19 12:57

Post by darwusch » 2004-08-24 17:22

I tested it with no favorite hubs in the list at all.
It's very strange, but with this delay, at least it works...

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2004-08-25 09:51

Why are you makeing the code for the sleep such complex?
It should be enough with just using Sleep(1000)

darwusch
Posts: 23
Joined: 2004-03-19 12:57

Post by darwusch » 2004-08-25 14:47

Because I'm a terrible programmer... :D

Locked