>> - Greg's tweak to handle file:// prefixes also segfaults.
>
> [..] seems odd is that extra slashes would be any kind of cause
> of a segfault.
I just ran some OSX tests.
Looks like a few things are at issue under OSX:
1) Indeed, looks like the cause is that sometimes dnd_open() is passed
a NULL pointer randomly as the event_text(), and when it is, that causes
the dump. Sometimes the drop works fine, sometimes it's NULL.
I added a check to dnd_open() to check for urls == 0 || length == 0
and updated my comments example in the article.
But there's more..
2) The "random behavior" might be due to the timer that triggers dnd_open().
It seems that Fl::event_text()'s contents doesn't always survive the
length
of time between when FL_PASTE is received, and when the timer fires.
What should probably be done is that when FL_PASTE is received, a local
copy
should be made of the Fl::event_text(), so that dnd_open() can later
reference
that local copy, instead of Fl::event_text() which is apparently volatile
after handle() returns.
3) Also, in one of my tests, it looked like under OSX Fl::event_text()
was NOT null terminated. I did an fprintf() of Fl::event_text() during
FL_PASTE, and it had garbage at the end of the URL. Which means the docs
for Fl::event_length() might be wrong:
---
int event_length();
Returns the length of the text in Fl::event_text(). There will always be a nul
at this position in the text. However there may be a nul before that if the
keystroke translates to a nul character or you paste a nul character.
---
So looks like when we make the copy, we have to memcpy() the
Fl::event_text(),
then stick a null at the end of our copy, to ensure it's null terminated.
Also, looks like when the payload is a multibyte string, the copy should
probably be "double-null terminated", which means the copy should be
Fl::event_length()+2 in size.
Fun.
A lot of this stuff should eventually be added to the docs for
Fl::event_text(),
which is currently empty last I looked:
http://fltk.org/documentation.php/doc-1.1/Fl.html#Fl.event_text
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk