I'm facing a strange problem I don't know even how to properly explain, but I hope somebody has faced this pseudo-problem and can tell me more or less why it happens.
I have a complex activity that occassionally spans threads to load resources.
It looks like that, somehow, if I assign a weakreference in the execution context of one thread, later on, on the UI thread, it returns null.
I'm absolutely sure I don't null that reference, as I only assign it on one place, that is like:
function assignReference(FunqSlide slide) {
mWeakEditSlide=new WeakReference<FunqSlide>(newSlide);
if (Conf.LOG_ON) Log.d(TAG, "SetSlide_internal "+index+"="+mWeakEditSlide+"->"+mWeakEditSlide.get());
.
.
}
And this produces the trace with the expected weakreference assigned to a valid object
06-01 17:40:50.030: D/FunqStory[Hiphop en LA](18390): SetSlide_internal 4=java.lang.ref.WeakReference@41625d18->FunqSlide{40f60728}
.
. next is processing
But the program flow continues and, slightly later on, a function accesses the previously created reference, but it is null!!!
06-01 17:40:53.330: D/FunqStory[Hiphop en LA](18390): *** CURRENT EDIT SLIDE ID weakreference is null!!!
06-01 17:40:53.330: E/AndroidRuntime(18390): FATAL EXCEPTION: main
06-01 17:40:53.330: E/AndroidRuntime(18390): java.lang.NullPointerException
06-01 17:40:53.330: E/AndroidRuntime(18390): at com.regaliz.funq.gui.Props_LayerList.loadSlide(Props_LayerList.java:77)
06-01 17:40:53.330: E/AndroidRuntime(18390): at com.regaliz.gui.fragments.FunqHelperSupport$Frag.setup_native_pane(FunqHelperSupport.java:1028)
06-01 17:40:53.330: E/AndroidRuntime(18390): at com.regaliz.libneo.NativeStory$ActionBarHandler.handleItemSelected(NativeStory.java:1612)
And, if had nulled it, there should be a debug trace of the function assignRefennce before the nullpointerexception, but there isn't, what indicates that something outside my code is nulling the reference for me.
Of course I've solved it just doing the stuff in the same thread, but I'd really want to know what's going on!
Any pointers? or WeakReferences? xD
Thanks in advance !