By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Access Violation by fox toolkit in FXObject::MetaClass::search(FXSelector key)

P: n/a
Well I've been sat here for hours twiddling with this code and it's
time to scream for help.

Hi there I'm a Student at Sheffield University programming the mapping
section of a control system for a flight simulator.
In order to do the graphical part required for the map we have an fox
declared window with an OpenGL canvas in it (loosely based on the
glviewer example which you get with the Fox toolkit download).
Things have been going hunky-dory so far but now im stuck with this
problem: When I inluded my most recent bit of code which loads Bitmaps
into OpenGL and declares them as textures I've been getting a:
0xC0000005: Access Violation from:

// Find function
const void* FXMetaClass::search(FXSelector key) const {
register const FXObject::FXMapEntry* lst=(const
FXObject::FXMapEntry*)assoc;
register FXuint n=nassocs;
while(n--){
//THE FOLLOWING LINE OF CODE:
if(lst->keylo<=key && key<=lst->keyhi) return lst;
lst=(const FXObject::FXMapEntry*) (((const FXchar*)lst)+assocsz);
}
return NULL;
}

If you already know exactly what the problem is GREAT! I'd really
appreciate if you could get back to me as soon as possible. If however
you need a bit more info then read on as I'v included the bit of code
that defines the textures:

if ((TextureImage[0]=LoadBMP("COMPASS ROSE.bmp")) && //Load those
bitmaps!
(TextureImage[1]=LoadBMP("RUNWAY.bmp")) &&
(TextureImage[2]=LoadBMP("VOR.bmp")) &&
(TextureImage[3]=LoadBMP("ILS and ILS-DME.bmp")) &&
(TextureImage[4]=LoadBMP("NDB.bmp")) &&
(TextureImage[5]=LoadBMP("DME.bmp")) &&
(TextureImage[6]=LoadBMP("TAC.bmp")) &&
(TextureImage[7]=LoadBMP("VOR-DME.bmp")))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(8,
&texture[0]); // Create 8 Textures

for (int loop=0; loop<1; loop++) // Loop Through All 8 Textures
{
glBindTexture(GL_TEXTURE_2D, texture[loop]);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[loop]->sizeX,
TextureImage[loop]->sizeY, GL_RGB, GL_UNSIGNED_BYTE,
TextureImage[loop]->data);
}
}

for (int loop=0; loop<1; loop++) // Loop Through All 8
Textures
{
if (TextureImage[loop]) // If Texture Exists
{
if (TextureImage[loop]->data) // If Texture Image Exists
{
free(TextureImage[loop]->data); // Free The Texture Image
Memory
}
free(TextureImage[loop]); // Free The Image Structure
}
}
Sorry about the length of this enquiry I just wanted to make sure I
included as much info as possible, if I'v missed anything you need to
know please dont hesitate to ask. Thanks a lot

Pete

p.s HEEEEEEEEEELLLLLPPP!!!!!!!!!!!!!!!!!

Apr 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Pete wrote:

0xC0000005: Access Violation from:

// Find function
const void* FXMetaClass::search(FXSelector key) const {
register const FXObject::FXMapEntry* lst=(const
FXObject::FXMapEntry*)assoc;
register FXuint n=nassocs;
while(n--){
//THE FOLLOWING LINE OF CODE:
if(lst->keylo<=key && key<=lst->keyhi) return lst;
lst=(const FXObject::FXMapEntry*) (((const FXchar*)lst)+assocsz);
}
return NULL;


My lst is in invalid pointer. Make sure that lst points to a valid object.

I also suggest you read the FAQ on how to post... you need to post a
minimal complete compilable example that demonstrates the issue.

However, given the error message, I'd check the value of assoc, and
nassoc. I'd also skip the register declaration, the compiler is
probably ignoring it anyways.

Apr 14 '06 #2

P: n/a
Pete wrote:
Well I've been sat here for hours twiddling with this code and it's
time to scream for help.


Please post this to a FOX mailing list. This newsgroup only discusses raw
C++ itself. I would bet that several here have read your code, looking for
some obvious C++ problem, such as a stray pointer.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.