directentry bug

i set up a directentry:

entry = DirectEntry()

i press arrow-right or arrow-left after filling the whole entrybox (typing as many characters as possible), i get this error:

AssertionError: !pos.is_nan() at line 373 of c:\temp\mkpr\panda\src\pgraph\transformState.cxx

do you get the same error? whats happening?

greets

well this is the code:

from direct.showbase.DirectObject import DirectObject
from direct.gui.DirectEntry import DirectEntry
import direct.directbase.DirectStart

class main(DirectObject):
    def __init__(self):
        self.posXEntry = DirectEntry(scale = .1)
   
main = main()
run()

please type in letters until you reach the end of the entry, then type some more letters (even if its not possible to write more), then press left or right arrow key.

no crash?

Nope, not crashing for me.

the crash only occurs if you are using a panda3D build with assertions.
however in a panda build witout assertions the cursor just dissapears.

i analysed the problem in detail and found out that the problem is caused by an unititialized TextAssembler::TextRow class. The fix is simple just add the initialization of the _xpos and _ypos members to the constructor

in panda/src/text/textAssembler.I line 404

INLINE TextAssembler::TextRow::
TextRow(int row_start) :
_row_start(row_start),
_got_soft_hyphens(false)
{
_xpos = 0.0f; //[PECI]
_ypos = 0.0f;
}

Arrgh. Forgetting to initialize member variables in the constructor is one of my biggest weaknesses.

Thanks for tracking that down! I’ll apply the fix immediately.

David