Hello everybody! Yesterday I had posted about a problem I was having creating Gdiplus::Image's. I have a related issue now, where the call to Gdiplus::Image::Image(const WCHAR *filename, BOOL useEmbeddedColorManagement)
crashes the program.
Here is the code that calls this function: m_pImage = new Gdiplus::Image(a_ImagePath);, where m_pImage is a pointer to a Gdiplus::Image and a_ImagePath is a constwchar_t* to a valid path.
When the program is compiled and run, the actual window does not show up, and half of the time I get a popup box saying the program has stopped working, etc. Under more details it points to an XML file which supposedly has more details on the error, which I pasted here: http://pastebin.com/hGXM6g06 .
I have used my IDE's debugger (Code::Blocks), and it segfaults at the constructor call for the Gdiplus::Image constructor. Thank you for your help, let me know if I can provide any more information.
Make sure a_ImagePath is a valid pointer - Windows API Calls many times don't check the validity of the pointers.
If there's a problem, either you're out of ram, you previously did bad allocations with another block of memory, or a_ImagePath is a bad pointer.
I really don't know. Standing to the other topic, m_pImage is in another class, right? Can I see how the class is declared in your code?
Like:
1 2 3 4 5
class Test {};
//...
Test * pT = new Test; // <-- This line
Test t; // <-- or This
Because, if it's not directly like this, it may be crashing because of a bad 'this' pointer.
About this, try putting a message box both before and after m_pImage = new Gdiplus::Image(a_ImagePath);
like:
1 2 3
MessageBoxW(NULL,L"Error is NOT before Constructor",L"Info",0,0);
m_pImage = new Gdiplus::Image(a_ImagePath);
MessageBoxW(NULL,L"Error is AFTER Constructor",L"Info",0,0);
Please try the same code in Visual Studio and see if it works. It could be a problem with libgdiplus.a and MinGW, GDI+ is a C++ API, unlike any other win32 api's, there are different rules.
// In your entrypoint:
Gdiplus::Image * pImage = new Gdiplus::Image(L"imagepath here");
And see if it bugs. If it does, it's a GDI+/Library problem. If it doesn't, you must have got problems with your class's memory allocation, which is really weird as you initialize other variables before the image, and you don't notice any other crash.
Good news! It bugged out with the same problem, therefor it's a GDI+/Library problem! What might I do to solve this? Is there any way to check if the imagepath is valid?