Re: Array of Object Pointers
No one knows what the values of those variables you're using are. We don't know when, where, and how those functions are called, or what context they're called in, etc..
Runtime errors involving memory handling requires us to have the code, compile it ourselves, and run it with the data that you're using. Otherwise, the only thing that anyone can tell you is to check your indices and memory overwrites.
Regards,
Paul McKenzie
Re: Array of Object Pointers
To compile and run this would take more time than I would expect anyone to spend on it.
But maybe I can narrow it down. When I do not pass the pointer to the createLocalQueue method, I am able to use it without the Access Violation.
This is successful:
localAppQueues[localQueueCount] = new qc::LocalQueue;
createLocalQueue(localAppQueues[localQueueCount], queueName);
//qc::SubscriptionManager subs(session);
//subs.subscribe(*localAppQueues[localQueueCount], queueName);
qc::Message m = localAppQueues[localQueueCount]->get();
And this has the runtime memory error:
localAppQueues[localQueueCount] = new qc::LocalQueue;
//createLocalQueue(localAppQueues[localQueueCount], queueName);
qc::SubscriptionManager subs(session);
subs.subscribe(*localAppQueues[localQueueCount], queueName);
qc::Message m = localAppQueues[localQueueCount]->get();
Is it possible that I am changing the pointer by passing it into the createLocalQueue method? It appears to me that moving the method's inline does not change anything.
Re: Array of Object Pointers
My apologies, in the previous post I had reversed the code segments. The first throws an error and the second (without the method call) is successful.
Re: Array of Object Pointers
Quote:
Originally Posted by
khayman218
To compile and run this would take more time than I would expect anyone to spend on it.
The point is that runtime errors cannot be debugged by individuals looking at two or three lines of code from a much larger program. Add to that, no knowledge of the values of those variables or in what state your program is in by the time it reaches the crash point. We also don't know what those functions you're calling are doing internally.
Quote:
But maybe I can narrow it down. When I do not pass the pointer to the createLocalQueue method, I am able to use it without the Access Violation
Your errors could have occurred much sooner than the code you're looking at. That code is where the application finally breaks down, but it doesn't guarantee that is the origin of the error.
Quote:
Is it possible that I am changing the pointer by passing it into the createLocalQueue method? It appears to me that moving the method's inline does not change anything.
You cannot "change the pointer" unless you pass a pointer to the pointer you're changing. You are not doing that.
Secondly, trying random things here and there is not how you solve these issues. You have to know why something doesn't work, and then fix it. Otherwise, what you'll end up doing is changing the code around so much that the error is moved to another part of the code, maybe a part of the code that isn't executed, giving a false sense that the problem is fixed.
Regards,
Paul McKenzie
Re: Array of Object Pointers
Quote:
Originally Posted by
khayman218
My apologies, in the previous post I had reversed the code segments. The first throws an error and the second (without the method call) is successful.
First of all, please use code tags when posting code.
The difference between the two pieces of code you posted seems to be the scope of the 'subs' variable. In the former, it is destroyed when exiting the function createLocalQueue, whereas in the latter it is destroyed later. That could give you a hint at where to look... or it could be incidental.
As Paul explained, with the information you have provided it's more of a guessing game than anything else.