Infinite loop when notifying model delegates of load start when the model is outdated

11 views
Skip to first unread message

CVertex

unread,
Jul 27, 2009, 5:18:59 AM7/27/09
to Three20
Howdy,

My models derive from TTModel with alot of the automatic stuff it
offers.

I notify my model listeners that loading has started like so

- (void)load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more {
[_delegates perform:@selector(modelDidStartLoad:) withObject:self];

// start http request for stuff

}

Since TTModel uses the cache for it's stuff, the cache key eventually
becomes outdated and model.IsOutdated returns false. This actually
happens inside the TTModelViewController listener of
modelDidStartLoad:. So, when modelDidStartLoad is called from load:,
TTModelViewController does some stuff to update it's state, then
called reloadIfNeeded and calls load again, resulting in an infinite
loop.

I removed the delegate notification from load:cachePolicy:more:, but
then there's no obvious hook to tell the controller the model is
loading.

Does anyone know how to get around this issue?
Or during the update to TTModel, was something changed that I didn't
change appropriately in my code.

Any help is greatly appreciated,

-CV

CVertex

unread,
Jul 27, 2009, 5:37:53 AM7/27/09
to Three20
Just looking through the latest and it appears to be fixed.. should i
upgrade to the latest master three20? or is there a simple patch I can
apply to fix this issue for the time being?

garybu

unread,
Aug 1, 2009, 8:41:38 PM8/1/09
to Three20
I see the same same problem. Should TTModelViewController
shouldReload include a check for model.isLoading?

- (BOOL)shouldReload {
return !_modelError && self.model.isOutdated && !
self.model.isLoading;

klazuka

unread,
Aug 2, 2009, 5:52:14 AM8/2/09
to Three20
Seems right to me, but TTModelViewController is such a monstrous state
machine that it is difficult to reason about.

I think I was bitten by this same bug on Friday... thanks for bringing
this up.

-keith

Adam Jack

unread,
Aug 3, 2009, 11:09:14 AM8/3/09
to thr...@googlegroups.com
Thanks, that seems to have helped me w/ the infinite loop I was experiencing.

regards,

Adam
--
Share Wildlife: http://wildobs.com
iPhone Application: http://wildobs.com/about/iphone



klazuka

unread,
Aug 3, 2009, 4:13:34 PM8/3/09
to Three20
Thanks Gary, that fixed my problem! If there isn't already a ticket
for this on GitHub, I'll go ahead and post it.

-keith

Joe Hewitt

unread,
Aug 4, 2009, 4:29:28 PM8/4/09
to Three20
Got it. Thanks for the fix, Gary.
Reply all
Reply to author
Forward
0 new messages