Calling ReleaseRef() is illegal and will assert/crash if the object is not being currently held in a SharedPtr. I assume that your messageBox_ member variable is a raw pointer? In that case, changing it to a SharedPtr should fix the issue.
I agree with Lasse that the MessageBox class is a little unusual. It was created for showing modal dialog box in the Editor via AngelScript API binding. As it is now, it would be a little clumsy to use in C++ language directly. Try not to use SharedPtr instance variable. Just declare the SharedPtr as local variable to your Quit() method and call AddRef() before the local variable goes out of scope. As already pointed out, the class will destroy itself later on when it has been acknowledged by calling ReleaseRef().
Congratulations! You triggered WinAPI mine and died.
Good way: Ensure that no Windows.h bullshit is exposed into your source code. Probably impossible.
Bad way: “Escape” your code like this (Urho3D::MessageBox)
Oh the ugly WinAPI… if it’s not enough to fiddle with gibberish C spagetti, they had to use lowercase macros.Seriously… Who the hell would use lowercase macros ? And if that’s not enough already, they had to use the most generic keywords like MessageBox , min , max. I really want to speak with the idiot who greenlit these dumb ideas… How dumb one can be defining a macro NOMINMAX to actually NOT HAVE min and max defined ? That’s like asking someone “Hey , you don’t want a beer ?” and expecting a yes or no as answer…
I suspect (given that the error is about some MessageBoxW) that you’re including the WinAPI files that have the define, then including the Urho MessageBox include, then you have your #undef. If that’s the case, move the undef before the Urho includes and see if that works.
doesn’t always work for me too, this issue keeps appearing from time to time with my projects. I would like to suggest changing MessageBox object to something else like PopupMessage or NonWinApiMessageBox.