Glfw and WIndows 10 problems


#1

I have application, not finished, but is working under Win7 without problem. I use more windows for options and etc… Problem is (under Window10), in second windows is not render GUI. Window is filled with grey color, but gui is there because when I click on area where should be close button, window close. It is glfw problem, or GUI i use, maybe everything?
Another problem is, after close program, exit function is not finished. I think it is maybe my fault, but I am not 100% sure. It looks like loop is not finished, and that it make me wonder why in W7 it is working and under W10 not. Maybe because I simply take project from WIndows7 and add it in to Windows 10 and it maybe need some more set up.
Have someone experience with glfw multiwindowing under Windows 10?

I use
glfw
Noesis GUI
vs 2015 CE
under Windows 7 is everything ok
under Windows 10 are problems described above.


#2

On my Windows 10 machine I have had no problem with multiple windows, and the GLFW multiple windows test windows.c runs fine. Perhaps there is an issue with the NoesisGUI on Windows 10, or perhaps there is a bug which haphazardly is showing up on one system and not the other.

It would be a good idea to debug and check that your OpenGL context is being set correctly for each window render.

For the issue:

I would advice debugging this to find out why - without knowing more about your application it’s difficult to give any help.


#3

Hmm it is looks like Noesis problem. Maybe using GLEW or something like that can resolve problem?

And exit function, I have window, without decoration, it means I use my buttons to close window (not from Windows frame). In my second simple example (glfw with noesis) program with decorated window, after hit close button, glfw close correctly. that means console application write “Press any key to close…” or something like that. This is how it works on Windows 10 for me. Under W7 is everything ok.


#4

Are you saying that on Windows 10 when you close you are left with a console application?

If so are you certain you are running the same .exe on both Win7 and Win10? Because the only way for this to happen is if you built as a console application and not as a Window application.


#5

Yes, but under W7 console write all actions to the end, but under W10 it stops (it write some actions but not to finish, for instance I have under last line code to display something to console, and it is not written in console because it stop), expect my simple glfw app with one window, it finish console app to the end like under W7.

No, I rebuild program under Windows 10 and my second simple program with only one window, is closing correctly under W10, also builded under W10. And all are console applications (W7 and W10).


#6

I am confused as to what you say is happening, the best I can offer is that you should try to put breakpoints into your code at the point it exits and try to figure out what is happening.

If you need further help it may be useful to post screenshots.


#7


I resolve problem and it was maybe not glfw or Noesis problem. On the picture you can see where is white background with black text, this was not displayed in console after close main window. Then console application was not closed properly. This behavior is under Windows 10, but under Windows 7 it is finished.

I have windows class under

std::list<wGWindow *> m_listWindow;
pointer = *listWindowIterator;
m_listWindow.erase(listWindowIterator);
delete pointer;

when I comented delete pointer; my program finished correctly under W10, - selected text under cmd (console text with white background on picutre), was displayed. But I had to undocment it and add it inside if() because, other windows was not closed.

I wonder why it is working in W7 and under W10 i must use this (there is code how I delete window)

for (size_t i = 0; i < MAX; ++i, ++listWindowIterator)
{
	(*listWindowIterator)->m_func_RenderFull(m_bOpenTrue_closeFalse);
	if (m_bOpenTrue_closeFalse == false)	// Zavriet Okno
	{
		if (i == 0)
		{
			MyDelegate::DataManager->m_func_Save();
		}
		if (i != 0)
		{// due w10 i need this code add it under if
			pointer = *listWindowIterator;
			m_listWindow.erase(listWindowIterator);
			delete pointer;
		}
		MAX = m_listWindow.size();
		--mWinwowCount;
		if (i == 0)
		{
			exitTrue_noExitFalse = true;
		}
		break;
	}
}

#8

Erasing a iterator in a list will invalidate that iterator, see the documentation for erase. However the erase function returns the next iterator in the sequence, so you can use this.

Using C++98 style code (you can do this more easily now with C++11 range based for loops), I’ve altered your code to erase and get the next iterator. This means the loop logic must change slightly, as the iterator now points to the next entry in the list. I’ve not tested this, and I don’t know what most of the code is doing so have left it the same as much as possible.

size_t i = 0;
while( listWindowIterator != m_listWindow.end() )
{
	(*listWindowIterator)->m_func_RenderFull(m_bOpenTrue_closeFalse);
	if (m_bOpenTrue_closeFalse == false)	// Zavriet Okno
	{
		if (i == 0)
		{
			MyDelegate::DataManager->m_func_Save();
		}
		pointer = *listWindowIterator;
		listWindowIterator = m_listWindow.erase(listWindowIterator);
		delete pointer;

		MAX = m_listWindow.size();
		--mWinwowCount;
		if (i == 0)
		{
			exitTrue_noExitFalse = true;
		}
		break;
	}
	else
	{
		++listWindowIterator;
	}
        ++i;
}


#9

Thanks, but same problem as under my code. I still have to add delete pointer under if() for main window.


#10

This then points to the destructor for the object pointed to possibly being the problem - you need to look at what the destructor is doing and figure out why deleting the first one is an issue.


#11

When I have opened some other windows and close main window while other are opened, then program is closed correctly (with your or my unmodified code). Maybe it is true that deleting first object from list cause this problem, because other window are shared from main window. Then I don’t understand why it is not working under Win10 and under Win7 yes.


#12

It’s impossible to help further without seeing more of the code (the destructor etc.).


#13
void wGWindow::m_func_WindowDestroy()
{
	m_NSframeworkElementView.Reset();
	m_NSxmlView.Reset();
	
	glfwDestroyWindow(m_Window);
	std::cout << "window was destroyed\n";
}

wGWindowSystem::~wGWindowSystem()
{
	m_listWindow.clear();
	delete MyDelegate::m_LangModel;
	m_NsRenderDevice.Reset();
	m_NsVGContext.Reset();
	Noesis::GUI::Shutdown();
	glfwTerminate();
}

#14

I presume m_func_WindowDestroy is called by the wGWindow destructor?

glfwDestroyWindow() should be safe so long as it is not called from another glfw callback, and is called from the main thread. Once this is done no other callbacks for that window will ocurr, so if you rely on these your program may not function correctly.

The Noesis GUI code I don’t know about.

Do you know where the code hangs or crashes when you debug with Visual Studio?


#15

Yes, I forgot mention it.

glfwDestroyWindow() should be safe so long as it is not called from another glfw callback, and is called from the main thread. Once this is done no other callbacks for that window will ocurr, so if you rely on these your program may not function correctly.

glfwDestroyWindow() is called once only in this function.

Do you know where the code hangs or crashes when you debug with Visual Studio?

I can say, it only stops when main window is deleted (after delete pointer), it write (windows was destroyed ) it in to console and thats all. Window is closed but rogram is stoped, not finished. I did debug with breakpoints and all values was correct. Btw program never crashed, in this case.


#16

I presume that to exit the program you check the value of exitTrue_noExitFalse, because at no point do I see a call to delete the wGWindowSystem nor how you exit the running of the program.

Then what you need to check is if this value gets correctly set, and then the logic of how you exit.


#17

under debug I check exitTrue_noExitFalse, and this is ok. Behavior of my code is, when user click on close main window, bool is set to true. And then deletion is made. I see problem, when main window is deleted, then program stop for no reason. Strange is, under Win7 it is running without problem.

here is my loop

bool exitTrue = false;
	while (!exitTrue)
	{
		windowSystem->m_func_RenderWindows(exitTrue);
		MyDelegate::DataManager->m_func_UpdateContainerDatas();
		MyDelegate::dataModel->m_func_UpdateProgressBar();
	}
	delete MyDelegate::DataManager;
	delete windowSystem;

#18

Unfortunately the small snippets of code you are showing aren’t enough to understand the problem.

If exitTrue is the same as exitTrue_noExitFalse in your window close test loop then when you close the first window it gets set to true as you have:

if (i == 0)
{
	exitTrue_noExitFalse = true;
}

so your program exits.

Could you explain what " program stop for no reason" means? If I understand correctly your program should exit when the main window is closed.


#19

It is described in post where I have picture, window is closed, but application not finish to exit, console not write exit code. It is stopped on the deletion main window. It shouldn’t stop it.

If I understand correctly your program should exit when the main window is closed.

Yes, it should, but for unknown reason it didn’t happen.


#20

Yes, I understand that this is when “program stop for no reason”. However I do not know exactly what you mean by “stop”. If you debug the program, what occurs? Does the program exit due to an error (crash) or does it continuously loop in some piece of code (hang)?