[PD-dev] libpd: divide by 0 in rtext_senditup()

Dan Wilcox danomatika at gmail.com
Sat Sep 24 19:20:30 CEST 2016


I’m playing with removing the @synchronized locks in the libpd Obj-C layer since the updates to the libpd ringbuffer seem to be working now.

Long story short, I’m only running into one issue: divide by 0s in g_rtext.c rtext_senditup() when opening a file. It seems that the findx & findy computations on line 215 & 216 fails since the previous glist_fontwidth() & glist_fontheight() calls return 0. Could this be an execution order issue where removing the lock is making something happen earlier than it should?

Adding the following before the findx & findy math works as a quick fix to keep the divide by zero error:

if (fontwidth <= 0) fontwidth = 1;
if (fontheight <= 0) fontheight = 1;

I’m wondering if there is a better way to catch this...

--------
Dan Wilcox
@danomatika <https://twitter.com/danomatika>
danomatika.com <http://danomatika.com/>
robotcowboy.com <http://robotcowboy.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20160924/457dcdf4/attachment.html>


More information about the Pd-dev mailing list