]> git.vomp.tv Git - vompclient.git/commitdiff
Bug fix: SurfaceVector/OsdVector: reference counts for style VectorHandles
authorChris Tallon <chris@vomp.tv>
Mon, 11 May 2020 22:54:57 +0000 (23:54 +0100)
committerChris Tallon <chris@vomp.tv>
Mon, 11 May 2020 22:54:57 +0000 (23:54 +0100)
SurfaceVector::drawText() would only call getStyleRef(DrawStyle)
once per string drawn. This resulted in a ref count of 1 regardless
of how many chars were drawn. Each time Boxx:draw() was called,
surface->fillblt would call removeCommands which dereferenced 1 for
each character. This eventually results in ref counts of zero or
negative. The GC deletes the DrawStyle/VectorHandle mapping if the
ref count is exactly zero, meaning just sometimes a style is deleted
when it is to be used. When this happens text on screen disappears.

This *might* also be the fix for a Windows client crashing bug.

surfacevector.cc

index 397273af4ae776a55ca01eace0b39e6de90beb2c..8f5216fddc974b5d8f96ab2cec725a26cc50f54b 100644 (file)
@@ -70,7 +70,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra
 
   command_mutex.lock();
 
-  VectorHandle ref = osd->getStyleRef(c);
+  VectorHandle ref;
   float* charwidtharray = osd->getCharWidthArray();
   int commands_size = commands.size();
   int chars = 0;
@@ -84,6 +84,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra
 
   while (num_bytes != ((size_t) -1) && num_bytes != ((size_t) -2) && length > 0)
   {
+    ref = osd->getStyleRef(c); // Need to call this each time to have OSD get the ref count right. Maybe expose incRefCount sometime
     SVGCommand::PaintGlyph(commands[commands_size + chars], x + shift, y, tempo, ref);
     chars++;
 
@@ -111,6 +112,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra
 
   for (int i = 0; i < real_length; i++)
   {
+    ref = osd->getStyleRef(c); // Need to call this each time to have OSD get the ref count right. Maybe expose incRefCount sometime
     SVGCommand::PaintGlyph(commands[commands_size + chars], x + shift, y, temptext[i], ref);
     chars++;