ChrisAnd1998 / TaskbarXI

An application written in C++ to modify the Windows 11 Taskbar.
https://chrisandriessen.nl/
GNU General Public License v3.0
1.52k stars 159 forks source link

fix GDI leaks that case app crashing #127

Closed hussien89aa closed 2 years ago

hussien89aa commented 2 years ago

I work for the Microsoft Graphics team, and I notice that your app is leaking GDI objects. These leaks make your app crash suddenly on the user. Once your all use all quotes for GDI object per process because of the leak the app will crash. Please fix/verify PR as soon as possible. I address leaks as much as I can I am not sure I address all leaks please find other leaks if there are any and fix them, your app is a good and nice App.

Leak issue fixed

When you use CombineRgn to combine three areas CombineRgn(region_Both, region_ShellTrayWnd, region_TrayNotifyWnd, RGN_OR); you need delete the old two (region_ShellTrayWnd, region_TrayNotifyWnd) since nobody can delete them. Even SetWindowRgn going to delete new area region_Both only old you need to delete them Thanks Hussein

hussien89aa commented 2 years ago

Also please be aware of the way you use SetWindowRgn it doesn't delete objects all time For safe delete, you need to use a pattern like this to make sure object is deleted if the window is not set

  HRGN regin1 = CreateRectRgn(0, 0, 10, 10);
    BOOL created = SetWindowRgn(hWnd, regin1, TRUE);
   if (!created)
   {
     DeleteObject(regin1);
   }
hussien89aa commented 2 years ago

Going to send one PR that fixes all leak issues.