Brent Baccala asked: > I need a Tk::Photo object shared between threads. The idea is > to load images in background while the GUI keeps running. > > Can it be done?
If the Tk::Photo module (and hence Tk::Image, and so on) is not thread safe, then you won't be able to share the object between threads. > As soon as I do a &share($fimage), I can no longer do anything > useful with $fimage. I get complaints like: > > Use of uninitialized value in subroutine entry at > /usr/lib/perl5/Tk/Submethods.pm line 37. > image "" doesn't exist at /usr/lib/perl5/Tk/Submethods.pm line 37. Yes. This is a known aspect of threads::shared. See http://annocpan.org/~NWCLARK/perl-5.8.8/ext/threads/shared/shared.pm#note_395 Most likely you'll need to change your application to pass data to the thread (e.g., the image name) so that the thread can do the work using its own (non-shared) objects.
