dalerank / nanogui-sdl

Minimalistic port of NanoGUI claim works with SDL API w/o external dependencies.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Correct way to dispose a window entirely?

tongtunggiang opened this issue · comments

I am using Window::dispose to destroy a window and its child widgets. However, VS complains about can't destroy Theme objects while their mutexes are locked (a.k.a. mutex destroyed while busy); and also there are some cases where Button::AsyncTexture::load causes reading access violation (due to the main Button object is already deleted).

So is it safe to call Window::dispose from the main thread?

@tongtunggiang why did you close this issue? Do you found an answer to your initial question? Is it safe?

@tongtunggiang why did you close this issue? Do you found an answer to your initial question? Is it safe?

It is, though there are a couple of issues with dangling pointers and locked mutex in AsyncTexture::load. I've added some checking with std::future and use ref instead of raw pointers, then it worked fine.