A class object isnt updated

I have a class called "Client", and a class called "Login"

both are friends of each other (haha).

in the class Client, there is an instance of login called "menu".
I have the following code in the class Client :

1
2
3
4
5
6
7
8
9
menu.RegisterLoginClass(hInstance);
	menu.MainHwnd = CreateWindowEx(WS_EX_CLIENTEDGE , "LoginClass", "Login", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,  400, 300, NULL, NULL, hInstance, NULL);
	menu.CreateLoginClass();

	std::thread t1(&Client::CheckAuth, this);
	t1.detach();

	ShowWindow(menu.MainHwnd, nCmdShow);
    UpdateWindow(menu.MainHwnd);


and the thread :

1
2
3
4
5
6
7
void Client::CheckAuth()
{
	if (menu.AuthenticateSuccess == true)
	{
		int x = 3;
	}
}


Now, I have a boolean field in menu, that is called AutheticateSuccess, which is set to true at a certin condition.
I've checked, and it reached the line where it makes it true inside the Login class, yet it remains false outside (by the way, the constructor is making it false at start)...
I've checked using debug points if it reachs the "int x = 3", and if it reaches the "AuthenticateSuccess = true" inside the Login class, and it does not reach the "int x = 3" line, but do reach the "AuthenticateSuccess = true" line.
I have no idea, how come the object menu (which is a Login class), doesnt update itself, saying that "AuthenticateSuccess" is still false, while I've changed it into true.

What is my error?

Thanks!
Check to see that the address of the menu item in the t1 thread is not the same as the address in the main thread.
How is that possible? I didnt completely understand you...
What is menu? A global variable? I think kooth is suggesting your setup may have a separate menu for each thread.
I think he means that you should use your IDE's debugger to check the addresses of the threads.
Menu is a "Login" variable that is inside the "Client" class.
Also Kooth, I've noticed that the adress of the Login object inside the function that makes "AuthenticateSuccess" true, is different from the adress of the Login object that is in the class "Client".. How is it possible ?

I have not created an instance of the Login class, but in the Client class...
Last edited on
Make sure your testcase is self-contained and actually reproduces the problem
A testcase that does not reproduce the problem is useless:
A testcase consisting of randomly copy&paste'd bits of code that you thought were relevant can obviously not reproduce the problem

http://www.eelis.net/iso-c++/testcase.xhtml
Topic archived. No new replies allowed.