int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
EnableConsole();
// ...
// ...
// Get command line
int argc = 0;
char** argv = CommandLineToArgvA(GetCommandLineA(), &argc);
// If there were no images dropped...
if(argc == 0)
{
// ...
return 0;
}
sf::RenderWindow win; // Thought maybe it was because a window wasn't open (I read somewhere that
win.create(sf::VideoMode(10, 10), "..."); // OpenGL may not init until a window is opened)
// Init images
deque<sf::Texture*> textures;
// Load images
for(int i = 0; i < argc; i++)
{
sf::Texture* img = new sf::Texture();
if(!img->loadFromFile("test/test_1.png")) // RUNTIME ERROR
{
// ...
}
textures.push_back(img);
}
}
In the above code, upon the loadFromFile call (where it is marked), the program crashes and dumps running memory to the console.
Stack trace:
> msvcr110.dll!memcpy(unsigned char * dst=0x00676e70, unsigned char * src=0x00000000, unsigned long count=5044544) Line 367 Unknown
msvcp110.dll!std::basic_streambuf<char,std::char_traits<char> >::sputn(const char * _Ptr=0x004d0ffb, __int64 _Count=6778480) Line 203 C++
sfmlg.dll!std::operator<<<char,std::char_traits<char>,std::allocator<char> >(std::basic_ostream<char,std::char_traits<char> > & _Ostr={...}, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Str={...}) Line 521 C++
sfmlg.dll!sf::priv::ImageLoader::loadImageFromFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename={...}, std::vector<unsigned char,std::allocator<unsigned char> > & pixels={...}, sf::Vector2<unsigned int> & size={...}) Line 126 C++
sfmlg.dll!sf::Texture::loadFromFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & filename={...}, const sf::Rect<int> & area={...}) Line 160 C++
ImageSequencer.exe!WinMain(HINSTANCE__ * hInstance=0x00150000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00542a83, int nShowCmd=1) Line 79 C++
ImageSequencer.exe!__tmainCRTStartup() Line 528 C
ImageSequencer.exe!WinMainCRTStartup() Line 377 C
In the file SFML\Graphics\ImageLoader.cpp, line 126 says:
err() << "Failed to load image \"" << filename << "\". Reason : " << stbi_failure_reason() << std::endl;
At runtime, err() is showing that it has an address of 123 (which is not a valid pointer address at all, unless I'm missing something).