Scroll - crash in OnCreate function

edited October 2012 in Help request
I'm not sure how to describe this one, but here goes. I finally got a class to go with my menu objects. However, once the object is created and OnCreate is called, I end up getting a segfault.
Here is the error:
[09:48:34] [ASSERT] [orxStructure.h:orxStructure_TestFlags():427] [ASSERT] : <(_pStructure != orxNULL) && (((((orxSTRUCTURE *)(_pStructure))->u64GUID & orxSTRUCTURE_GUID_MASK_STRUCTURE_ID) >> orxSTRUCTURE_GUID_SHIFT_STRUCTURE_ID) < orxSTRUCTURE_ID_NUMBER)>
Trace/breakpoint trap (core dumped)
Here is my OnCreate function:
void Menu::OnCreate()
{
    orxOBJECT* p_current_object;
    // Populate menu vector
    menu_option_list.push_back(orxObject_GetOwnedChild(GetOrxObject()));
    menu_option_iterator = menu_option_list.begin();

    for(p_current_object = *menu_option_iterator; p_current_object != orxNULL;
        menu_option_iterator++, p_current_object = orxObject_GetOwnedSibling(*menu_option_iterator))
        menu_option_list.push_back(p_current_object);

    // Select the first menu option
    HighlightMenuOption(0);

    return;
}

Here is my menu in INI:
[O-MainMenu]
Position        = (512, 384, 0)
ChildList       = O-StoryMode # O-ArcadeMode # O-ScoreAttack # O-Records # O-Options # O-QuitGame

If you need any other info, let me know. I don't know what could be causing it, and I'll try to look into it later, but I'm stumped after a quick once-over.

I'm trying to store all of the pointers to the menu objects in a vector to make manipulating them in the code easier.

Comments

  • edited October 2012
    Once again, I figured it out myself. The logic in my for function was garish. What was I smoking when I wrote that? o.o
  • edited October 2012
    On the same topic, given that you're using Scroll, you also have the alternative of accessing the collections of ScrollObjects without having to resort to additional containers.

    You can access either the global list of all ScrollObjects, or only the list of ScrollObject of a given type/class.

    The methods for that are
    ScrollObject *GetNextObject(const ScrollObject *_poObject = orxNULL, orxBOOL _bChronological = orxFALSE) const;
    template<class O> O *GetNextObject(const O *_poObject = orxNULL) const;
    ScrollObject *GetPreviousObject(const ScrollObject *_poObject = orxNULL, orxBOOL _bChronological = orxFALSE) const;
    template<class O> O *GetPreviousObject(const O *_poObject = orxNULL) const;
    
  • edited October 2012
    Sweet. I'll have to change my code later.
Sign In or Register to comment.