Console Error with CCParallaxNode and crash - console

I'm getting an error in the console that reads
Assertion failure in -[CCParallaxNode addChild:z:tag:]
This is for the code
CGSize winSize = [[CCDirector sharedDirector] winSize];
node = info;
voidNode = [CCParallaxNode node];
[voidNode addChild:node z:2 parallaxRatio:ccp(0.0f, 1.0f) positionOffset:ccp(info.contentSize.width/2, info.contentSize.height/2 - winSize.height)];
[self addChild:voidNode z:2 tag:kTagNode];
Not very familiar with debugging with the console

Why don't you simply put there a breakpoint and see what is happening ? Every time i had such error the problem was trying to add a nil child to the parent (there is an assertation of it in a addChild method

Related

PeopleCode error while trying to call function on Page PeopleCode event

I am trying to add the below function (populate_details) to a Page PeopleCode Activate event. The top section of code already exists, I am trying to add the section starting at 6/24/20 comments and getting the error "Syntax error: expecting statement. (2,42) ^ HCSC" If I remove the top section of the code then the error does not display and it saves properly, so I must have some sort of syntax error. Thanks for the help!
import HR_DIRECT_REPORTS:EmployeeSelection;
Component HR_DIRECT_REPORTS:EmployeeSelection &MyUI;
&MyUI.PageActivate();
/*GHS KLG - link to Footprints on termination screen*/
If DERIVED_HR_DR.HR_DR_PAGE_TITLE.Value = "Terminate Employee" Then
GHS_MSS_WRK.HTMLAREA.Value = MsgGetExplainText(31000, 27, "Message not found.");
GHS_MSS_WRK.HTMLAREA.Visible = True;
Else
GHS_MSS_WRK.HTMLAREA.Visible = False;
End-If;
/*GHS end*/
/* GHS KDR 6/24/20 BEGIN */
Declare Function populate_details PeopleCode GH_PERS_INF_WRK.FUNCLIB FieldFormula;
GH_PERS_INF_WRK.EFFDT = %Date;
populate_details(%Date, PERSON_NPC_VW.EMPLID.Value, GH_PERS_SRCH_CW.EMPL_RCD.Value);
/* GHS KDR 6/24/20 END */
You must declare your populate_details function at the top of the Page PeopleCode Activate event. Immediately after this line should work:
Component HR_DIRECT_REPORTS:EmployeeSelection &MyUI;
Then you can call your function as you did, the rest of the code looks fine.

box2d CreateFixture with b2FixtureDef gives pure virtual function call

i have this code that gives me run time error in the line :
body->CreateFixture(&boxDef)
im using cocos2d-x 2.1.5 with box2d 2.2.1 in windows
CCSprite *sprite = CCSprite::create(imageName.c_str());
this->addChild(sprite,1);
b2BodyDef bodyDef;
bodyDef.type = isStatic?b2_staticBody:b2_dynamicBody;
bodyDef.position.Set((position.x+sprite->getContentSize().width/2.0f)/PTM_RATIO,
(position.y+sprite->getContentSize().height/2.0f)/PTM_RATIO);
bodyDef.angle = CC_DEGREES_TO_RADIANS(rotation);
bodyDef.userData = sprite;
b2Body *body = world->CreateBody(&bodyDef);
b2FixtureDef boxDef;
if (isCircle)
{
b2CircleShape circle;
circle.m_radius = sprite->getContentSize().width/2.0f/PTM_RATIO;
boxDef.shape = &circle;
}
else
{
b2PolygonShape box;
box.SetAsBox(sprite->getContentSize().width/2.0f/PTM_RATIO, sprite->getContentSize().height/2.0f/PTM_RATIO);
boxDef.shape = &box;
}
if (isEnemy)
{
boxDef.userData = (void*)1;
enemies->insert(body);
}
boxDef.density = 0.5f;
body->CreateFixture(&boxDef) //<-- HERE IS THE RUN TIME ERROR
;
when i debug the box2d code im getting to b2Fixture.cpp
in the method :
void b2Fixture::Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def)
in the line :
m_shape = def->shape->Clone(allocator);
getting the runtime error :
R6025 pure virtual function call
Tricky one. I ran into this myself a couple times. It has to do with variable scope.
The boxDef.shape is the problem. You create the shapes as local variables in the if/else blocks and then assign them to boxDef. As soon as execution leaves the if/else block scope those local variables will be garbage. The boxDef.shape now points to freed memory.
The solution is to keep the shape variables in scope by moving the circle and box shape declarations before the if/else block.

Firebase FQuery how do you detect when at the end of a list of nodes

How do I detect when I have finished processing all found nodes when doing a query? In the following example, I do some processing on each encountered node. When I reach the "end" of the list I would like to be able to detect this so I know it's finished.
FQuery* messageListQuery = [m_firebaseRef queryLimitedToNumberOfChildren:100];
[messageListQuery observeEventType:FEventTypeChildAdded andPreviousSiblingNameWithBlock:^(FDataSnapshot *snapshot, NSString *prevNodeName) {
// 1. Do interesting stuff with the snapshot data
// 2. I want to detect when I'm at the end of the list so I know when I'm done processing the list.
}];
Here is the example use case. I would like to load the latest 100 messages in the background. Once the messages have been loaded, I would like to update the UI. However, I'm not sure how I know all the messages have been loaded given there might be less then 100 messages in the list.
I figured out how to read all the messages up front by using the observeSingleEventOfType and then iterating over the children.
[m_firebaseRef observeSingleEventOfType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
NSLog( #"Name %# with %d children.", snapshot.name, snapshot.childrenCount );
for( FDataSnapshot *child in snapshot.children )
{
NSDictionary *msgData = child.value;
NSString *message = msgData[kFirebaseLiveChatFieldMessage];
NSString *gamerTag = msgData[kFirebaseLiveChatFieldGamerTag];
NSString *gameCenterId = msgData[kFirebaseLiveChatFieldGameCenterId];
NSLog( #"Preload = %# (%#): %#", gamerTag, gameCenterId, message );
}
}];

Redraw NSTableView with new data from file when NSViewController re-loaded?

I have a Mac OS X Document based app that has multiple NSViewControllers that I switch between and each view displays data from plist files in NSTableViews based on the user selections in the previous NSViewController's NSTableView. The problem I have is that I can't figure out what function can be called, every time a NSViewController gets loaded, to read the correct data from a file to display in the NSTableView. For UIViewControllers I used the function family of viewDidLoad, viewWillAppear, but I haven't been able to find the corresponding functions for NSViewController.
Currently I am using awakeFromNib, which works fine, but only the first time the NSViewController gets loaded. I've tried loadView, but that collapses the NSView. I assume that I need to do more setup to use loadView.
I'm using the View Swapping code from Hillegass's book Cocoa Programming for MAC OS X which switches ViewControllers with the following code:
- (void)displayViewController:(ManagingViewController *)vc
curBox: (NSBox *)windowBox
{
// End editing
NSWindow *w = [windowBox window];
BOOL ended = [w makeFirstResponder:w];
if (!ended) {
NSBeep();
return;
}
NSView *v = [vc view];
NSSize currentSize = [[windowBox contentView] frame].size;
NSSize newSize = [v frame].size;
float deltaWidth = newSize.width - currentSize.width;
float deltaHeight = newSize.height - currentSize.height;
NSRect windowFrame = [w frame];
windowFrame.size.height += deltaHeight;
windowFrame.origin.y -= deltaHeight;
windowFrame.size.width += deltaWidth;
[windowBox setContentView:nil];
[w setFrame:windowFrame
display:YES
animate:YES];
[windowBox setContentView:v];
// Put the view controller in the responder chain
[v setNextResponder:vc];
[vc setNextResponder:windowBox];
}
and puts the NSView Controller in the responder chain.
Is there some function I can call to setup the view every time I swap NSViewControllers? Can I check that a NSViewController has become the firstResponder?
This post provided the answer.
I added the following code:
- (void)viewWillLoad {
}
- (void)viewDidLoad {
}
- (void)loadView {
[self viewWillLoad];
[super loadView];
[self viewDidLoad];
}
and at the beginning of displayViewController I added
[vc loadView]

Actionscript Compiler Problem: Error #1068: Array and * cannot be reconciled

I'm getting a very bizarre callstack in my Flex project (AS3).
Main Thread (Suspended:
VerifyError: Error #1068: Array and * cannot be reconciled.)
I was able to reproduce it using this block of code. If you debug, you'll never get inside "failure" function.
private var testArray:Array = [{},{},{}]
private function run():void {
this.failure({});
}
private function failure(o:Object):void {
for each(var el:Object in testArray) {
o.ids = (o.ids||[]).concat(getArray());
}
}
private function getArray():Array { return [Math.random()]; }
When I run the program, this callstack is one line, but this conole shows a big mess as if it were a segmentation fault:
> verify monkeyTest/failure()
> stack:
> scope: [global Object$ flash.events::EventDispatcher$
> flash.display::DisplayObject$
> flash.display::InteractiveObject$
> flash.display::DisplayObjectContainer$
> flash.display::Sprite$
> mx.core::FlexSprite$
> mx.core::UIComponent$
> mx.core::Container$
> mx.core::LayoutContainer$
> mx.core::Application$ monkeyTest$]
> locals: monkeyTest Object? * * *
Any suggestions? Cheers.
EDIT:
This code does not produce the error:
private function failure(o:Object):void {
for each(var el:Object in testArray) {
o.ids = o.ids || [];
o.ids = o.ids.concat(getArray());
}
}
The problem is here:
o.ids = (o.ids||[]).concat(getArray());
o.ids is type * while [] is Array, so they can't be compared
Change it to:
o.ids = ((o.ids as Array)||[]).concat(getArray());
This error indicates that the ActionScript in the SWF is invalid. If you believe that the file has not been corrupted, please report the problem to Adobe. (see the note at the bottom of that page).
Most verify errors are compiler errors that the compiler failed to capture. Reporting will help to fix them in the next version.
EDIT: Corrected the link, thanks Glenn
I've received this error when creating local variables named "arguments" within a function as well. The compiler doesn't give any warnings, and I've sometimes gotten away with it -- only to have the error pop back up after adding a couple lines. The console gives the crazy error stack, and doesn't let you use the FB debugger in any useful fashion when the error occurs. This happens due to a conflict with the standard "arguments" object available from within any function:
http://as3.miguelmoraleda.com/2009/03/28/actionscript-3-arguments-atributo-arguments-dentro-de-cualquier-funcion-functio/

Resources