Uncaught TypeError: Cannot read property 'without' of null in CPView.j

63 views
Skip to first unread message

Richard van Zon

unread,
Aug 24, 2015, 7:21:22 AM8/24/15
to Cappuccino & Objective-J
Hi,

I recently updated Cappuccino and now one of my projects shows the error:

Uncaught TypeError: Cannot read property 'without' of null$CPView__unsetThemeState_ @ CPView.j:1953

It seems that it has to do something with the new CPThemeState:

,["BOOL","ThemeState"]), new objj_method(sel_getUid("unsetThemeState:"), function $CPView__unsetThemeState_(self, _cmd, aState)
{
   
if (aState && aState.isa && (aState == null ? null : aState.isa.objj_msgSend1(aState, "isKindOfClass:", CPArray)))
        aState
= CPThemeState.apply(null, aState);
   
var oldThemeState = self._themeState;
    self._themeState = self._themeState.without(aState);
    if (oldThemeState === self._themeState)
       
return NO;
   
self.isa.objj_msgSend0(self, "setNeedsLayout");
   
self.isa.objj_msgSend1(self, "setNeedsDisplay:", YES);
   
return YES;

Any ideas how to fix this?

Thanks in advance!

Dogild

unread,
Aug 24, 2015, 2:07:15 PM8/24/15
to Cappuccino & Objective-J
Hi Richard,

How do you create your view ? It looks like that _themeState was not initialize yet. 

Thanks, 
Alex

Richard van Zon

unread,
Aug 24, 2015, 4:24:26 PM8/24/15
to Dogild, objec...@googlegroups.com
It’s a pretty big project with about 40 xibs and 100+ source files. It’s hard for me to determine where the problem is...
Also, I never had the problem before.

The stack trace doesn’t give me enough information. Could it be a cache-problem?


--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at http://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

Richard van Zon

unread,
Aug 24, 2015, 5:15:49 PM8/24/15
to Cappuccino & Objective-J
I did some more research. Adding:

    if (!_themeState) {
        console
.log('no _themeState', self);
        _themeState
= CPThemeState(_themeState, aState);
   
}

to View.j (3141) fixes the problem (of course), and shows a list of classes without theme states.

Before I just returned YES when _themeState is not set:

    if (!_themeState) {
     
return YES;
   
}


The app works, but all textfields located in View Based TableViews, don't have text and images are not set. The same classes in the log with the first 'fix'.

Could it be that theming goes wrong with View Bases TableViews?

Dogild

unread,
Aug 24, 2015, 8:42:57 PM8/24/15
to Cappuccino & Objective-J
Not sure if this is the best fixe, we should know why _themeState is null.

Doe it work with this commit : 340d827377e383e2a0dcebc9e62b6e87ceb83887 ?

Richard van Zon

unread,
Aug 25, 2015, 3:20:42 AM8/25/15
to Dogild, objec...@googlegroups.com
Well, it wasn’t meant as a real fix. Just to show that the cause is really and only this part.

Are you sure you mean this commit:


This is an xCodeCapp commit.

Dogild

unread,
Aug 25, 2015, 12:53:13 PM8/25/15
to Cappuccino & Objective-J, alexandre...@gmail.com
Yes I'm sure about this commit, do a git checkout 340d827377e383e2a0dcebc9e62b6e87ceb83887

It's just to know if the issue appears when we have added the appearance feature

Alexandre Wilhelm

unread,
Aug 25, 2015, 1:16:19 PM8/25/15
to Cappuccino & Objective-J
The good news is we can reproduce this issue with manual test TableTests/ViewBasedCib.

I’m taking a look

-- 
Alexandre Wilhelm

Richard van Zon

unread,
Aug 25, 2015, 1:19:19 PM8/25/15
to Alexandre Wilhelm, objec...@googlegroups.com
Ah great! 

I just wanted to write that I have the same issue with 340d827377e383e2a0dcebc9e62b6e87ceb83887. 

My guess is that views in ViewBased Tableviews are not initialised the same way as ’normal’ classes, and so initWithFrame isn’t called. But don’t know exactly.

Dogild

unread,
Aug 25, 2015, 7:52:53 PM8/25/15
to Cappuccino & Objective-J, alexandre...@gmail.com
I just proposed a PR for this one : https://github.com/cappuccino/cappuccino/pull/2375

It's way more complicated as expected....

Richard van Zon

unread,
Aug 26, 2015, 3:18:27 AM8/26/15
to Dogild, objec...@googlegroups.com
I see it’s more complicated, yes. But isn’t it better to setAppearance at first usage instead of initialisation?

I tested your commit and it functions :)

Thanks for your work!

Dogild

unread,
Sep 23, 2015, 6:55:26 PM9/23/15
to Cappuccino & Objective-J, alexandre...@gmail.com
This issue has been fixed in the master !
Reply all
Reply to author
Forward
0 new messages