diff options
author | jenkins4kodi <jenkins4kodi@users.noreply.github.com> | 2018-12-21 18:10:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-21 18:10:19 +0100 |
commit | 35ae3cb81b9479878abe660b9ee2c8abd58862b3 (patch) | |
tree | 98512285b037b5fcb701c4561cd3127c30bb19ec | |
parent | f5df89eef0139fd7030d9b99dc9699d255cc19cd (diff) | |
parent | b3cd094fc4cf5386d76541ba159bbac438a3c715 (diff) |
Merge pull request #15104 from xbmc/fix-glibcxx-assertions
-rw-r--r-- | xbmc/guilib/GUIFontTTF.cpp | 5 | ||||
-rw-r--r-- | xbmc/guilib/GUIFontTTFGL.cpp | 7 | ||||
-rw-r--r-- | xbmc/windowing/wayland/WindowDecorator.cpp | 15 |
3 files changed, 24 insertions, 3 deletions
diff --git a/xbmc/guilib/GUIFontTTF.cpp b/xbmc/guilib/GUIFontTTF.cpp index acad2fcb76..906db44dad 100644 --- a/xbmc/guilib/GUIFontTTF.cpp +++ b/xbmc/guilib/GUIFontTTF.cpp @@ -352,6 +352,11 @@ void CGUIFontTTFBase::End() void CGUIFontTTFBase::DrawTextInternal(float x, float y, const std::vector<UTILS::Color> &colors, const vecText &text, uint32_t alignment, float maxPixelWidth, bool scrolling) { + if (text.empty()) + { + return; + } + Begin(); uint32_t rawAlignment = alignment; diff --git a/xbmc/guilib/GUIFontTTFGL.cpp b/xbmc/guilib/GUIFontTTFGL.cpp index db51eb4bdd..f87afae0af 100644 --- a/xbmc/guilib/GUIFontTTFGL.cpp +++ b/xbmc/guilib/GUIFontTTFGL.cpp @@ -23,6 +23,8 @@ #endif #include "rendering/MatrixGL.h" +#include <cassert> + // stuff for freetype #include <ft2build.h> #include FT_FREETYPE_H @@ -280,6 +282,9 @@ void CGUIFontTTFGL::LastEnd() CVertexBuffer CGUIFontTTFGL::CreateVertexBuffer(const std::vector<SVertex> &vertices) const { + assert(!vertices.empty()); + assert(vertices.size() % 4 == 0); + // Generate a unique buffer object name and put it in bufferHandle GLuint bufferHandle; glGenBuffers(1, &bufferHandle); @@ -288,7 +293,7 @@ CVertexBuffer CGUIFontTTFGL::CreateVertexBuffer(const std::vector<SVertex> &vert // Create a data store for the buffer object bound to the GL_ARRAY_BUFFER // binding point (i.e. our buffer object) and initialise it from the // specified client-side pointer - glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof (SVertex), &vertices[0], GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof (SVertex), vertices.data(), GL_STATIC_DRAW); // Unbind GL_ARRAY_BUFFER glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/xbmc/windowing/wayland/WindowDecorator.cpp b/xbmc/windowing/wayland/WindowDecorator.cpp index 874aaff13b..a44c6357b7 100644 --- a/xbmc/windowing/wayland/WindowDecorator.cpp +++ b/xbmc/windowing/wayland/WindowDecorator.cpp @@ -967,10 +967,21 @@ void CWindowDecorator::CommitAllBuffers() if (emplaceResult.second) { // Buffer was not pending already - auto iter = emplaceResult.first; - wlBuffer.on_release() = [this, iter]() + auto wlBufferC = reinterpret_cast<wl_buffer*> (wlBuffer.c_ptr()); + // We can refer to the buffer neither by iterator (might be invalidated) nor by + // capturing the C++ instance in the lambda (would create a reference loop and + // never allow the object to be freed), so use the raw pointer for now + wlBuffer.on_release() = [this, wlBufferC]() { CSingleLock lock(m_pendingBuffersMutex); + // Construct a dummy object for searching the set + wayland::buffer_t findDummy(wlBufferC, wayland::proxy_t::wrapper_type::foreign); + auto iter = m_pendingBuffers.find(findDummy); + if (iter == m_pendingBuffers.end()) + { + throw std::logic_error("Cannot release buffer that is not pending"); + } + // Do not erase again until buffer is reattached (should not happen anyway, just to be safe) // const_cast is OK since changing the function pointer does not affect // the key in the set |