Pārlūkot izejas kodu

UI: Fix crash on macOS when closing OAUTH browser panel

Deleting the cefWidget in the panel's destructor can result in a crash
on macOS because the underlying NSView might have been destroyed in
memory between Qt closing the QDialog and the destructor call.

Moving the browser destruction into the accept and reject calls ensures
that CEF can clean up its state _before_ Qt tears down the view
hierarchy.
PatTheMav 2 gadi atpakaļ
vecāks
revīzija
efbae916fb
2 mainītis faili ar 19 papildinājumiem un 6 dzēšanām
  1. 17 6
      UI/auth-oauth.cpp
  2. 2 0
      UI/auth-oauth.hpp

+ 17 - 6
UI/auth-oauth.cpp

@@ -71,12 +71,7 @@ OAuthLogin::OAuthLogin(QWidget *parent, const std::string &url, bool token)
 #endif
 #endif
 }
 }
 
 
-OAuthLogin::~OAuthLogin()
-{
-#ifdef BROWSER_AVAILABLE
-	delete cefWidget;
-#endif
-}
+OAuthLogin::~OAuthLogin() {}
 
 
 int OAuthLogin::exec()
 int OAuthLogin::exec()
 {
 {
@@ -88,6 +83,22 @@ int OAuthLogin::exec()
 	return QDialog::Rejected;
 	return QDialog::Rejected;
 }
 }
 
 
+void OAuthLogin::reject()
+{
+#ifdef BROWSER_AVAILABLE
+	delete cefWidget;
+#endif
+	QDialog::reject();
+}
+
+void OAuthLogin::accept()
+{
+#ifdef BROWSER_AVAILABLE
+	delete cefWidget;
+#endif
+	QDialog::accept();
+}
+
 void OAuthLogin::urlChanged(const QString &url)
 void OAuthLogin::urlChanged(const QString &url)
 {
 {
 	std::string uri = get_token ? "access_token=" : "code=";
 	std::string uri = get_token ? "access_token=" : "code=";

+ 2 - 0
UI/auth-oauth.hpp

@@ -24,6 +24,8 @@ public:
 	inline bool LoadFail() const { return fail; }
 	inline bool LoadFail() const { return fail; }
 
 
 	virtual int exec() override;
 	virtual int exec() override;
+	virtual void reject() override;
+	virtual void accept() override;
 
 
 public slots:
 public slots:
 	void urlChanged(const QString &url);
 	void urlChanged(const QString &url);