SFML community forums

Help => General => Topic started by: OutlawLee on May 11, 2012, 07:31:34 pm

Title: My friend is getting errors that i dont get when he closes the program
Post by: OutlawLee on May 11, 2012, 07:31:34 pm
this is what he gets:
Code: [Select]
the instruction at "0x004f53cc" referenced memory at "0x027581c8". The memory could not be "read". Click on OK to terminate the program
But i close it, it closes normally

while (App.isOpen())
        {
                while (App.pollEvent(Event))
                {
                        if (Event.type == sf::Event::Closed)
                                App.close();
                }
                return 0;
         }
 
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: Sonkun on May 11, 2012, 08:40:17 pm
Lol, look at where your return statement is. "While the window is open, close the program".
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: OutlawLee on May 11, 2012, 11:59:18 pm
What ? No i doesnt close since you can write one command after "if" and it will be considered like its in the brackets. Thats not the problem. It runs perfectly on my pc, but on his when he presses exit he gets that error.
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: Rosme on May 12, 2012, 12:12:32 am
He didn't said anything about your event and your if statement, he talked about your return. It is inside your while(App.isOpen()) loop. I suppose it's copy mistake, otherwise it would close as soon as it open.

Now for your problem, give us a minimal code. We can't say anything about this.
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: OutlawLee on May 12, 2012, 11:03:46 am
oh yeh thats copy paste error, i was writing it manually

Code: [Select]

while (App.isOpen())
{
while (App.pollEvent(Event))
{
if (Event.type == sf::Event::Closed)
App.close();
                        if (Event.type == sf::Event::KeyReleased)
{
if(Event.key.code == sf::Keyboard::Return)
{
if(stage == 0)
{
stage = 1;
loaded = 0;
}
else if(stage == 1)
{
if(menu_choice == 0)
{
stage = 2;
loaded = 0;
}
if(menu_choice == 1)
{

}
if(menu_choice == 2) // This is when he presses exit menu/same goes for the X  sign on the windows bar.
{
App.close();
}
}
}
                        }
}
        }

    return EXIT_SUCCESS;
}

thats it

Im using windows 7, VC++ 2010. Hes still on Win XP SP3.

Im gonna try giving him an empty window program, to see if it works with that one.
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: aNewHobby on May 12, 2012, 12:35:32 pm
is this happening when running from inside VS? try building a release build and running from explorer.. you might find it runs fine. I forget where ... but i saw a post that said there was a bug that caused a crash as the program closed when running from the run command in VS...

The fix as I understand it is to use a custom font rather than the default one... anyway that worked for me when i tried to make a corss project in xciode code::blocks(ubuntu) and Vs2010... in vs2010 the exact same code would crash... simply changed it to laod a custom font and it worked...
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: OutlawLee on May 12, 2012, 04:56:52 pm
Im building a debug. Im using custom fonts.
Title: Re: My friend is getting errors that i dont get when he closes the program
Post by: Rosme on May 12, 2012, 06:57:02 pm
Do you use the custom fonts when you build your sf::Text, or you use default constructor for sf::Text? If so, the default fonts load anyway and can cause the problem. Like I said, give us a minimal code. You just gave us the while loop. Not enough. We don't know what's happening before. You should try to create a minimal code that reproduces the error.