diff options
author | Kirill Burtsev <kirill.burtsev@qt.io> | 2018-10-02 16:17:46 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2018-10-08 06:40:43 +0000 |
commit | 17c061d9068de2ff06ec26ed55a693915142032e (patch) | |
tree | 29f2a3072bc4f9d9ee270664cf05c8c190df3fce /src/core | |
parent | 514633108e88da241b6bbcbc108e1fcecdadf366 (diff) |
Fix leak which arises on querying GLOzone instance in SurfaceFactoryQt
Ownership of GLOzone instance assumed to be hold by factory, no new
instance should be created on each GetGLOzone call.
Task-number: QTBUG-69088
Change-Id: I7eb8575f1f35bd30292a8b4fc5ab1334ccb8e2bb
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 25 | ||||
-rw-r--r-- | src/core/ozone/surface_factory_qt.h | 3 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 1 | ||||
-rw-r--r-- | src/core/web_engine_context.h | 1 |
4 files changed, 12 insertions, 18 deletions
diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index d2b2aab8a..03013de4d 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -58,31 +58,26 @@ namespace QtWebEngineCore { SurfaceFactoryQt::SurfaceFactoryQt() { // Fixme: make better platform switch handling - QString platform = qApp->platformName(); - if (platform == QLatin1String("xcb")) { - m_impls.push_back(gl::kGLImplementationDesktopGL); + Q_ASSERT(qApp); + if (qApp->platformName() == QLatin1String("xcb")) { + m_impl = gl::kGLImplementationDesktopGL; +#if QT_CONFIG(webengine_system_x11) + m_ozone.reset(new ui::GLOzoneGLXQt()); +#endif } else { - m_impls.push_back(gl::kGLImplementationEGLGLES2); + m_impl = gl::kGLImplementationEGLGLES2; + m_ozone.reset(new ui::GLOzoneEGLQt()); } } std::vector<gl::GLImplementation> SurfaceFactoryQt::GetAllowedGLImplementations() { - return m_impls; + return { m_impl }; } ui::GLOzone* SurfaceFactoryQt::GetGLOzone(gl::GLImplementation implementation) { - - QString platform = qApp->platformName(); - if (platform == QLatin1String("xcb")) { -#if QT_CONFIG(webengine_system_x11) - return new ui::GLOzoneGLXQt(); -#endif - return nullptr; - } else { - return new ui::GLOzoneEGLQt(); - } + return m_ozone.get(); } } // namespace QtWebEngineCore diff --git a/src/core/ozone/surface_factory_qt.h b/src/core/ozone/surface_factory_qt.h index 0ac2eca68..dee41d948 100644 --- a/src/core/ozone/surface_factory_qt.h +++ b/src/core/ozone/surface_factory_qt.h @@ -53,7 +53,8 @@ public: std::vector<gl::GLImplementation> GetAllowedGLImplementations() override; ui::GLOzone* GetGLOzone(gl::GLImplementation implementation) override; private: - std::vector<gl::GLImplementation> m_impls; + gl::GLImplementation m_impl; + std::unique_ptr<ui::GLOzone> m_ozone; }; } // namespace QtWebEngineCore diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 7010359e2..6fbdbec61 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -96,7 +96,6 @@ #include "net/webui_controller_factory_qt.h" #include "type_conversion.h" #include "ozone/gl_context_qt.h" -#include "ozone/surface_factory_qt.h" #include "web_engine_library_info.h" #include <QFileInfo> diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h index e9e7c44a7..ce71984d4 100644 --- a/src/core/web_engine_context.h +++ b/src/core/web_engine_context.h @@ -67,7 +67,6 @@ namespace QtWebEngineCore { class ProfileAdapter; class ContentMainDelegateQt; class DevToolsServerQt; -class SurfaceFactoryQt; bool usingSoftwareDynamicGL(); |