mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 17:05:06 +00:00
LibGUI: Fix crash during HackStudio application teardown
We can't rely on a plain global WeakPtr during application teardown since destruction order is not defined. Instead, use a NeverDestroyed to hold the GUI::Application weak pointer. This way it will always be reliable. Fixes #3251.
This commit is contained in:
parent
0359a5ce27
commit
683ae4f7ad
1 changed files with 5 additions and 4 deletions
|
@ -24,6 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <AK/NeverDestroyed.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -39,17 +40,17 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
static WeakPtr<Application> s_the;
|
static NeverDestroyed<WeakPtr<Application>> s_the;
|
||||||
|
|
||||||
Application* Application::the()
|
Application* Application::the()
|
||||||
{
|
{
|
||||||
return s_the;
|
return *s_the;
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::Application(int argc, char** argv)
|
Application::Application(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ASSERT(!s_the);
|
ASSERT(!*s_the);
|
||||||
s_the = make_weak_ptr();
|
*s_the = make_weak_ptr();
|
||||||
m_event_loop = make<Core::EventLoop>();
|
m_event_loop = make<Core::EventLoop>();
|
||||||
WindowServerConnection::the();
|
WindowServerConnection::the();
|
||||||
Clipboard::initialize({});
|
Clipboard::initialize({});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue