I seem to be unable to access member pointers to structs. Here are the struct declarations in the class:
Your program must be much longer than 4 lines.
Please post the actual code that duplicates the error. Setting a pointer to NULL and comparing it to NULL does not cause errors by itself -- your code is doing much more to cause the problem than what you've shown.
That's what my team and I also thought at first, but this is the isolated portion of the code that causes the error. I'm sorry I wasn't clear, but the two statements in the bottom code section are in separate methods. I took out the first line after I saw that was where the access violation break point was and the second line also caused the same error at the same location.
This probably has nothing to do with the fact that the members you're accessing are pointers. Notice that in both cases, the code dies the first time any member of the Direct2DSoftwareDevice class is touched.
This probably means that you're trying to call these methods on something which isn't a valid Direct2DSoftwareDevice object. Usually this can happen if you're trying to access the object via an invalid Direct2DSoftwareDevice*.
Set a breakpoint at two positions, such that the debugger stops at, say:
Code:
void Direct2DSoftwareDevice::Start()
{
//!!!!!!!!!!
//DIES HERE
//!!!!!!!!!!
first = NULL; //<< so debugger stops here
last = NULL;
}
Then, tell us what the value of "this" is.
Then, look at the call stack and find the code where "Start" is called
..from there, look for the object upon whose instance Start is called,
and look further backwards until you find where that object is created.
Tell us the code you have there.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).
Thank you Lindley! You were spot on. A pointer to an instance of the class wasn't properly initialized. Doh. Thank you JVene for your help as well. I'll try to remember to make the instance before I use its non-static methods next time. =)
Out of curiousity, what is the "next" parameter supposed to denote? Is this a linked list? If so, maybe that should just be a std::list<SpriteStruct*> or something similar to that, and forget about the "next" member variable.
Bookmarks