-
March 17th, 2009, 02:43 PM
#16
Re: Vector, class, and iterator issues
Originally Posted by Plasmator
Aye.
Yes, this was evident from your first post.
Oh Yeah.....
So how do I set it up?
Last edited by Escapetomsfate; March 17th, 2009 at 02:58 PM.
-
March 17th, 2009, 08:34 PM
#17
Re: Vector, class, and iterator issues
Originally Posted by Escapetomsfate
Oh Yeah.....
So how do I set it up?
Below are links to a short movie (recorded on a test VM; quality should be acceptable) that illustrates one of the methods that I was talking about.
You may also need VMware's Movie Decoder if you don't have one of their products installed.
Hopefully you'll be able to do this on your own from now on...
Debugger.7z (~700 kB)
http://plasmator.t35.com/DebuggerSFX.zip (Can't link this one, retarded host) [7-zip Self-Extracting Archive] (~800 kB)
-
March 18th, 2009, 12:06 PM
#18
Re: Vector, class, and iterator issues
Originally Posted by Plasmator
Below are links to a short movie (recorded on a test VM; quality should be acceptable) that illustrates one of the methods that I was talking about.
You may also need VMware's Movie Decoder if you don't have one of their products installed.
Hopefully you'll be able to do this on your own from now on...
Debugger.7z (~700 kB)
http://plasmator.t35.com/DebuggerSFX.zip (Can't link this one, retarded host) [7-zip Self-Extracting Archive] (~800 kB)
Thanks plasmator, really helpful
I really don't know which window shows what the problem is. This is the registers window;
Code:
EAX = 00079D40 EBX = 00079B30 ECX = 00079D18 EDX = 00000000 ESI = 0178743C EDI = 0007A7BB EIP = 00000000
ESP = 00A9FE40 EBP = 00000000 EFL = 00200202
and this is from output:
Code:
First-chance exception at 0x00000000 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000000.
Does anyone know wha that could mean, in relation to the code at the start?
-
March 18th, 2009, 12:59 PM
#19
Re: Vector, class, and iterator issues
Originally Posted by Escapetomsfate
Code:
First-chance exception at 0x00000000 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00000000 in orbiter.exe: 0xC0000005: Access violation reading location 0x00000000.
Does anyone know wha that could mean, in relation to the code at the start?
You are accessing an address via pointer for reading, and that address you're attempting to access is NULL (0x00000000).
Set a breakpoint on the very first line of your application, and keep your eye on the Output Window. If that message hasn't appeared when the first line is about to execute, single step through the program until that message appears. When that message appears, then that area of code is where it's triggering that message.
Usually reading from a NULL address isn't fatal, but irritating seeing that message. The fatal one is when you attempt to write to a NULL address.
If that message appears before the first line in your main() program, then either you have global classes, objects, that were instantiated, and that is the cause of the problem, or if you're using other DLL's that get loaded at app startup, then they could be the ones causing the problem. You need to just debug slowly to pinpoint where that message is being generated from.
BTW, since you are using Visual C++, you should have posted this in either the Visual C++ forum (if using MFC) or the Windows API forum (if you're using straight Windows API calls).
Regards,
Paul McKenzie
-
March 18th, 2009, 01:17 PM
#20
Re: Vector, class, and iterator issues
Originally Posted by Paul McKenzie
You are accessing an address via pointer for reading, and that address you're attempting to access is NULL (0x00000000).
Set a breakpoint on the very first line of your application, and keep your eye on the Output Window. If that message hasn't appeared when the first line is about to execute, single step through the program until that message appears. When that message appears, then that area of code is where it's triggering that message.
Usually reading from a NULL address isn't fatal, but irritating seeing that message. The fatal one is when you attempt to write to a NULL address.
If that message appears before the first line in your main() program, then either you have global classes, objects, that were instantiated, and that is the cause of the problem, or if you're using other DLL's that get loaded at app startup, then they could be the ones causing the problem. You need to just debug slowly to pinpoint where that message is being generated from.
BTW, since you are using Visual C++, you should have posted this in either the Visual C++ forum (if using MFC) or the Windows API forum (if you're using straight Windows API calls).
Regards,
Paul McKenzie
Thanks for the help. I already know that this is the code causing the CTD:
Code:
DLLCLBK void opcPreStep(double simt, double simdt, double mjd)
{
//loop through all weapons, and destroy them.
for (vector<Weapon>::iterator it = WeaponList.begin(); it != WeaponList.end();++it)
{
it->explode();
}
}
So, I suppose I have to assign it to something. Any suggestions?
EDIT: Could this be it? it is in the Weapon class constructor.
Code:
//add self to WeaponList vector.
WeaponList.push_back(*this);
Last edited by Escapetomsfate; March 18th, 2009 at 01:24 PM.
-
March 18th, 2009, 01:30 PM
#21
Re: Vector, class, and iterator issues
Originally Posted by Escapetomsfate
Thanks for the help. I already know that this is the code causing the CTD:
There are several lines posted there. Which one is it that is causing the problem?
As others pointed out, we need to see the full context of when, where, and how that code is called, we do not know what the values of any of those variables are when that code is called, etc.
Since this is a runtime issue, we can't do static analysis of source code to show you what you're doing wrong. All we can say is that the loop syntactically is correct. If WeaponList is valid, and if explode() has no issues, then that code is correct (Note the if -- only you know whether any of those things are valid or not).
Regards,
Paul McKenzie
-
March 18th, 2009, 01:33 PM
#22
Re: Vector, class, and iterator issues
I only get an error when I use a function of the iterator (it, using Weapon class functions).
How do I make a class push back itself on construction? I'm sure that's the problem.
-
March 18th, 2009, 01:38 PM
#23
Re: Vector, class, and iterator issues
Originally Posted by Escapetomsfate
EDIT: Could this be it? it is in the Weapon class constructor.
Code:
//add self to WeaponList vector.
WeaponList.push_back(*this);
You're adding a copy of a not yet constructed object to a vector. Could very well be a problem especially since you seem to have no copy constructor defined for the Weapon class that has some pointer members.
Kurt
-
March 18th, 2009, 01:41 PM
#24
Re: Vector, class, and iterator issues
Originally Posted by Escapetomsfate
I only get an error when I use a function of the iterator (it, using Weapon class functions).
Then that loop would never execute if the WeaponList is empty. Look at the for loop constraints. Second, if that loop did execute, that means that the WeaponList is not empty, and one of the item's in that list has an explode() function that is buggy, or the item itself is buggy.
How do I make a class push back itself on construction?
I don't understand your question. How would that fix the issue I stated above?
I'm sure that's the problem.
Hopefully you are not guessing at what the problem is. You never should guess, you have to actually debug, find the cause of the problem, and then offer a diagnosis to fix the problem.
Regards,
Paul McKenzie
-
March 18th, 2009, 01:48 PM
#25
Re: Vector, class, and iterator issues
Originally Posted by ZuK
You're adding a copy of a not yet constructed object to a vector. Could very well be a problem especially since you seem to have no copy constructor defined for the Weapon class that has some pointer members.
Kurt
Of course! duh! Thanks a lot.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|