-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leak when converting a bitmap to an icon, crasshes when too many handle created #137
Comments
That error message indicates that is completely unrelated to PDF at all. It is a GDI+ (windows graphic device interface) error, it states that it's an exception with windows. It happens when the program is drawing the activity icon on the taskbar. From a google search here is some context from stack overflow: https://stackoverflow.com/questions/12026664/a-generic-error-occurred-in-gdi-when-calling-bitmap-gethicon It looks like a leak where more than 10 000 handle are created, it errors out. Converting so much files had the activity updates so much. Congratulation🥇 you again managed to find a problem that was left undiscovered for more than a decade by shear numbers. Here is an extension method from this link that should prevent that error if used instead, not that I would be able to test that. public class IconExtensions
{
/// <summary>
/// Create a Icon that calls DestroyIcon() when the Destructor is called.
/// Unfortunatly Icon.FromHandle() initializes with the internal Icon-constructor Icon(handle, false), which sets the internal value "ownHandle" to false
/// This way because of the false, DestroyIcon() is not called as can be seen here:
/// https://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Icon.cs,f2697049dea34e7c,references
/// To get arround this we get the constructor internal Icon(IntPtr handle, bool takeOwnership) from Icon through reflection and initialize that way
/// </summary>
private static Icon BitmapToIcon(Bitmap bitmap)
{
Type[] cargt = new[] { typeof(IntPtr), typeof(bool) };
ConstructorInfo ci = typeof(Icon).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, cargt, null);
object[] cargs = new[] { (object)bitmap.GetHicon(), true };
Icon icon = (Icon)ci.Invoke(cargs);
return icon;
}
} Related links: |
Got another error, probably the same type Crash dump
|
Yes identical, no need to keep posting them. I should have already fixed the problem and will post the update later, when I have more to fix. In the mean time you can prevent this by closing ComicRack if you do a lot of converting/updating. Keep an eye on the handles column in task manager like the stack overflow post describes. |
Thanks! :-) |
Describe the bug
When converting 8000 PDF files to CBZ, CR crashes
Exact Steps to Reproduce
Steps to reproduce the behavior:
Crash dump
Version/Commit (check the about page, next to the version, for the string between brackets):
The text was updated successfully, but these errors were encountered: