[osg-users] Segfault occuring in -- void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplier) const -- after updating from osg 3.3.1 to the current trunk

Curtis Rubel crubel at compro.net
Fri May 1 12:49:27 PDT 2015


Hi Robert,

After getting the small example to fail today, I was looking some more and came up with a few changes here that allows me to run.

I am relatively sure that this will not be the final fix, but I am hoping that it will at least get you closer to what is causing the problem.  Here is an svn diff listing from my modified Text.cpp


Code:

Index: src/osgText/Text.cpp
===================================================================
--- src/osgText/Text.cpp        (revision 14858)
+++ src/osgText/Text.cpp        (working copy)
@@ -726,6 +726,12 @@
         GlyphQuads::Coords2& coords2 = glyphquad._coords;
         GlyphQuads::Coords3& transformedCoords = glyphquad._transformedCoords[contextID];
 
+        if(transformedCoords == NULL)
+        {
+           glyphquad._transformedCoords[contextID] = new osg::Vec3Array;                                                                                                                    
+           transformedCoords = glyphquad._transformedCoords[contextID];                                                                                                                     
+        }                                                                                                                                                                                   
+                                                                                                                                                                                            
         unsigned int numCoords = coords2->size();                                                                                                                                           
         if (numCoords != transformedCoords->size())                                                                                                                                         
         {                                                                                                                                                                                   
@@ -804,6 +810,12 @@                                                                                                                                                                         
         for( ; backdrop_index < max_backdrop_index; backdrop_index++)                                                                                                                       
         {                                                                                                                                                                                   
             GlyphQuads::Coords3& transformedCoords = glyphquad._transformedBackdropCoords[backdrop_index][contextID];                                                                       
+            if(transformedCoords == NULL)                                                                                                                                                   
+            {                                                                                                                                                                               
+               glyphquad._transformedCoords[contextID] = new osg::Vec3Array;                                                                                                                
+               transformedCoords = glyphquad._transformedCoords[contextID];                                                                                                                 
+            }                                                                                                                                                                               
+                                                                                                                                                                                            
             unsigned int numCoords = coords2->size();
             if (numCoords!=transformedCoords->size())
             {
@@ -1288,7 +1300,7 @@
     if ( !_textureGlyphQuadMap.empty() )
     {
         const GlyphQuads& glyphquad = (_textureGlyphQuadMap.begin())->second;
-        if ( :q)
+        if ( glyphquad._transformedCoords[contextID] == NULL )
         {
             computePositions(contextID);
         }





The diff at line 1303 in my source file:
-        if ( glyphquad._transformedCoords[contextID]->empty() )
+        if ( glyphquad._transformedCoords[contextID] == NULL )

The glyphquad._transformedCoords[contextID] call creates an
empty buffered object entry since the contextID coming in is not present, yet and the buffered_object API automatically resizes the array if it does not contain the value in the [] operator.  So now I check for NULL instead of empty() and thereby now calling computePositions(contextID).

The change in the computePositions function down around line 727
checks to see if the GlyphQuads::Coords3& transformedCoords is NULL,
if it is we add a new osg::Vec3Array in there  that then gets filled with
what I hope is the correct data...

Anyhow a brief explanation of what I did here to try and get some sort of workaround as I was curious as to what was going on and had some spare time this afternoon to look at it...

Since you are already in the osgText code working maybe with this it will allow you to get an idea of this issue and possibly incorporate both fixes at the same time...well at least I hope so as by no means do I claim to know much about this...hopefully me just trying to help did not confuse you more instead.

I am also attaching the patched version of the file to this post for you as well..


... 

Thank you!

Cheers,
Curtis

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63602#63602



-------------- next part --------------
A non-text attachment was scrubbed...
Name: Text.cpp
Type: text/x-c++src
Size: 73192 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150501/f21beeff/attachment-0003.cpp>


More information about the osg-users mailing list