Skip to content

Commit 71dd957

Browse files
committed
Fix #8962 (Destroying browser onClientGUIClick result instant crash)
1 parent 0e2508b commit 71dd957

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Client/mods/deathmatch/logic/CClientWebBrowser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,9 @@ CClientGUIWebBrowser::CClientGUIWebBrowser ( bool isLocal, bool isTransparent, u
335335
: CClientGUIElement ( pManager, pLuaMain, pCGUIElement, ID )
336336
{
337337
m_pManager = pManager;
338-
m_pBrowser = g_pClientGame->GetManager ()->GetRenderElementManager ()->CreateWebBrowser ( width, height, isLocal, isTransparent );
339-
m_pBrowser->SetParent ( this ); // m_pBrowser gets deleted automatically by the element tree logic
338+
m_pBrowser.reset(g_pClientGame->GetManager()->GetRenderElementManager()->CreateWebBrowser(width, height, isLocal, isTransparent));
339+
m_pBrowser->SetParent(this); // Memory management is no longer done via element tree logic, but is kept here for backwards compatibility
340+
m_pBrowser->MakeSystemEntity(); // Mark element as system entity so it isn't destroyed automatically
340341

341342
// Set our owner resource
342343
m_pBrowser->SetResource ( pLuaMain->GetResource () );

Client/mods/deathmatch/logic/CClientWebBrowser.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
* PURPOSE: ClientEntity webbrowser tab class
88
*
99
*****************************************************************************/
10+
#pragma once
1011

11-
#ifndef __CCLIENTWEBBROWSER_H
12-
#define __CCLIENTWEBBROWSER_H
13-
12+
#include <memory>
1413
#include <core/CWebViewInterface.h>
1514
#include <core/CAjaxResourceHandlerInterface.h>
1615
#include <core/CWebBrowserEventsInterface.h>
@@ -96,10 +95,8 @@ class CClientGUIWebBrowser : public CClientGUIElement
9695
public:
9796
CClientGUIWebBrowser ( bool isLocal, bool isTransparent, uint width, uint height, CClientManager* pManager, CLuaMain* pLuaMain, CGUIElement* pCGUIElement, ElementID ID = INVALID_ELEMENT_ID );
9897

99-
inline CClientWebBrowser* GetBrowser () { return m_pBrowser; }
98+
inline CClientWebBrowser* GetBrowser () { return m_pBrowser.get(); }
10099

101100
private:
102-
CClientWebBrowser* m_pBrowser;
101+
std::unique_ptr<CClientWebBrowser> m_pBrowser;
103102
};
104-
105-
#endif

0 commit comments

Comments
 (0)