Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

❌ [Error] Can't apply theme #218

Open
MuscularPuky opened this issue Feb 27, 2024 · 19 comments
Open

❌ [Error] Can't apply theme #218

MuscularPuky opened this issue Feb 27, 2024 · 19 comments
Assignees
Labels
enhancement New feature or request issue Issue

Comments

@MuscularPuky
Copy link
Contributor

❌ Error report

Describe the error

  • When I try to apply theme, WinPlaetter crashes

How to reproduce the error

    1. open theme file I saved before update
    1. it prompt 2 JSON errors
    1. try to apply but it crashes

WinPaletter Log

//General information
//...........................................................
   Report.Date = "2024년 2월 27일 화요일 오전 1:52:34";
   OS = "Windows 11, 10.0.26058.1000, 64-bit";
   WinPaletter.Version = "1.0.8.6, 베타, Build: Release";
   WinPaletter.Language = "한국어(대한민국)";
   WinPaletter.Debugging = false;

//Error details
//...........................................................
   Exception.message = "Cannot access a disposed object.
Object name: 'Icon'.";
   Exception.type = "System.ObjectDisposedException";
   Exception.stack.trace =
   {
      at System.Drawing.Icon.get_Handle()
      at System.Windows.Forms.Form.UpdateWindowIcon(Boolean redrawFrame)
      at System.Windows.Forms.Form.set_Icon(Icon value)
      at WinPaletter.Dialogs.ThemeLog.ThemeLog_Load(Object sender, EventArgs e)
      at System.Windows.Forms.Form.OnLoad(EventArgs e)
      at System.Windows.Forms.Form.OnCreateControl()
      at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
      at System.Windows.Forms.Control.CreateControl()
      at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
      at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
      at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
      at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
      at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
      at System.Windows.Forms.Control.Show()
      at WinPaletter.Tabs.TabsContainer.AddFormIntoTab(Form form)
      at WinPaletter.Dialogs.ThemeLog.Apply_Theme(Manager TM, Boolean AdditionalStoreTips, Boolean dontInvoke)
      at WinPaletter.Home.apply_btn_Click(Object sender, EventArgs e)
      at System.Windows.Forms.Control.OnClick(EventArgs e)
      at System.Windows.Forms.Button.OnClick(EventArgs e)
      at WinPaletter.UI.WP.Button.OnClick(EventArgs e)
      at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
      at WinPaletter.UI.WP.Button.OnMouseUp(MouseEventArgs e)
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at System.Windows.Forms.ButtonBase.WndProc(Message& m)
      at System.Windows.Forms.Button.WndProc(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   };
   Exception.target.void_function = "System.Drawing.get_Handle()";
   Exception.assembly = "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
   Exception.assembly.file = "C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Drawing\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Drawing.dll";
   Exception.HRESULT = -2146232798;

Screenshots/Screen records

  • Don't add screenshot to exception error dialog if you already wrote WinPaletter Log.
  • If possible, add screenshots/Screen records of the wrong behaviour to help explain your problem.

Additional context

  • After save the theme on 1.0.8.6, the JSON errors gone. Maybe only theme file saved on ~1.0.8.4 cause this? I don't know

+I'm testing more deflects, like wi-fi connected/disconnected, etc. I'll tell you as enhancement when I'm done :)

@Abdelrhman-AK
Copy link
Owner

Abdelrhman-AK commented Feb 27, 2024

I'll try to reproduce this and fix this. It is mainly not from theme JSON file, it is from adding form into tabs.

it prompt 2 JSON errors

It is a known issue that you can safely ignore. It results from the massively changed Windows Terminal structure in WinPaletter class. I made these changes to make implementing new Windows Terminal features easier, and make this class better in readability for any developer will open this class.

+I'm testing more deflects, like wi-fi connected/disconnected, etc. I'll tell you as enhancement when I'm done :)

I'll be waiting for these new ideas :)
Once their event IDs are known, implementing these new sounds deflections will be easy.

@Abdelrhman-AK
Copy link
Owner

I have just implemented Wi-Fi sounds

Connection: *[System[(EventID = 8000)]]
Disconnection: *[System[(EventID = 8003)]]

Both will be available in the next update

@MuscularPuky
Copy link
Contributor Author

Oh you're quick!
Actually I'm comparing 8000, 8001, 11000, 11001 and found out these IDs are like lifecyle. not only these there is also about 30 events but would be too much.
I summerized events roughly but some events seem to actually not work:
4003 Wi-Fi error and auto recoverin.txt

It would be better 11001 than 8000/8001 I think because virtual adaptor also uses that event

@Abdelrhman-AK
Copy link
Owner

Abdelrhman-AK commented Feb 28, 2024

I have used event viewer to watch the events:

11001: Wireless network association succeeded.

It is triggered correctly when there is a connection.

So, what ID will be used for disconnection instead of 8003 (As you said that 8003 may be used by virtual adaptor)?

There is 11004 triggered too by disconnection, but it is relevant to WLAN security.

11004: Wireless security stopped.

@MuscularPuky
Copy link
Contributor Author

I write some event lifecycle in this roughly: 8000 - 11000 - 11001 - 10010 - 10005 - 8001 - 11004 - 8003

@Abdelrhman-AK
Copy link
Owner

Abdelrhman-AK commented Mar 1, 2024

I have tested these IDs, 11001 plays the sound first then a delay happens before connection is triggered and before taskbar icon change. And this behavior is identical to 8001.

I am going to use 11001 for Wi-Fi connection, 8003 for Wi-Fi disconnection.

Tell me if I should use these IDs and release the new update or not.

@MuscularPuky
Copy link
Contributor Author

👍 How about triggering failed to connect (8002) too?

@Abdelrhman-AK
Copy link
Owner

Abdelrhman-AK commented Mar 1, 2024

Great! I'll add it, and push the new update either today or tomorrow.

@Abdelrhman-AK
Copy link
Owner

And please tell me whether the main issue (exception error) has been resolved in the new update or not. I have been unable to reproduce it myself, despite attempting code fixes based on the provided details.

@Abdelrhman-AK Abdelrhman-AK added enhancement New feature or request issue Issue labels Mar 2, 2024
@Abdelrhman-AK
Copy link
Owner

Tell me if the issue is fixed or not.

@MuscularPuky
Copy link
Contributor Author

Good. it does not crash anymore. but WinPaletter ignores metrics & fonts preference. I had to use "apply metrics" button instead "apply this theme"

@MuscularPuky
Copy link
Contributor Author

MuscularPuky commented Mar 7, 2024

Good. it does not crash anymore. but WinPaletter ignores metrics & fonts preference. I had to use "apply metrics" button instead "apply this theme"

ah it's not ignores. just rollback to default

@Abdelrhman-AK
Copy link
Owner

Can you make verbose levels 'advanced', and include skipped items? (Temporarily for one time).

I want to know what skips Metric and Fonts or what makes the Metrics and Fonts aspect uses default theme.

Export the log after applying the whole theme.

https://github.com/Abdelrhman-AK/WinPaletter/wiki/Theme-log-verbose-level

@Abdelrhman-AK
Copy link
Owner

ah it's not ignores. just rollback to default

This is expected if you are using WinPaletter store, but let me see applying log.

@MuscularPuky
Copy link
Contributor Author

Can you make verbose levels 'advanced', and include skipped items? (Temporarily for one time).

I want to know what skips Metric and Fonts or what makes the Metrics and Fonts aspect uses default theme.

Export the log after applying the whole theme.

https://github.com/Abdelrhman-AK/WinPaletter/wiki/Theme-log-verbose-level

OK I'll try soon

@MuscularPuky
Copy link
Contributor Author

Can you make verbose levels 'advanced', and include skipped items? (Temporarily for one time).
I want to know what skips Metric and Fonts or what makes the Metrics and Fonts aspect uses default theme.
Export the log after applying the whole theme.
https://github.com/Abdelrhman-AK/WinPaletter/wiki/Theme-log-verbose-level

OK I'll try soon

I'm here. it rollbacks classic colors, font & metrics, etc, to default. I forgot to change language to english so translated manually.

[info] Winpaletter appys theme on Windows 11 section
[info] apply started
[apply] saving theme infomatoin to registry
[skip] winpaletter application theme
[skip] wallpaper
[apply] applying Windows 11 scheme
[reg_add] HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent > AccentPalette = 107 107 107 255 89 89 98 255 76 76 255 63 63 63 255 0 0 0 255 0 0 0 255 20 20 20 255 136 23 152 255, RegistryValueKind = Binary
[reg_add] ditto > StartColorMenu = -16777216, RegistryValueKind = DWord
[apply] Windows 11 LogonUI
[apply] classic colors
[dll] calling user32.dll.SystemParameterInfo(SPI_SETFLATMENU, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETGRADIENTCAPTIONS, 0, True, SPIF_UPDATEINIFILE)
[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ActiveBorder = 32 32 32, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ActiveTitle = 32 32 32, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > AppWorkspace = 8 8 8, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonDkShadow = 24 24 24, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonFace = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonHilight = 96 96 96, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonLight = 64 64 64, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonShadow = 40 40 40, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ButtonText = 255 255 255, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > GradientActiveTitle = 32 32 32, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > GradientInactiveTitle = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > GrayText = 128 128 128, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > HotTrackingColor = 255 255 255, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > InactiveBorder = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > InactiveTitle = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > InactiveTitleText = 160 160 160, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > InfoText = 255 255 255, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > InfoWindow = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > Menu = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > MenuBar = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > MenuText = 255 255 255, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > Scrollbar = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > TitleText = 255 255 255, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > Window = 0 0 0, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > WindowFrame = 64 64 64, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > WindowText = 192 192 192, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > Hilight = 128 127 127, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > MenuHilight = 11 11 11, RegistryValueKind = String

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > Desktop = 0 0 0, RegistryValueKind = String
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDROPSHADOW, 0, True, SPIF_UPDATEINIFILE)
[apply] apllying window metrics & fonts
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDROPSHADOW, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETFONTSMOOTHING, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETUIEFFECTS, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_GETICONMETRICS, 108, WinPaletter.NativeMethods.User32+ICONMETRICS, SPIF_NONE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETCLIENTAREAANIMATION, 0, True, SPIF_UPDATEINIFILE)
[skip] window switcher (Alt+Tab)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDRAGFULLWINDOWS, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETMENUANUMATION, 0, True, SPIF_UPDATEINIFILE)
[skip] Skipping WinPaletter Wallpaper Tone as it is disabled
[dll] calling user32.dll.SystemParameterInfo(SPI_SETMENUFADE, 0, True, SPIF_UPDATEINIFILE)
[skip] command prompt
[dll]  calling user32.dll.SystemParameterInfo(SPI_SETMENUSHOWDELAY, 400, True, SPIF_UPDATEINIFILE)
[skip] PowerShell x86
[dll] calling user32.dll.SystemParameterInfo(SPI_SETSELECTIONFADE, 0, True, SPIF_UPDATEINIFILE)
[skip] powershell x64
[dll] calling user32.dll.SystemParameterInfo(SPI_SETCOMBOBOXANIMATION, 0, True, SPIF_UPDATEINIFILE)
[skip] Windows Terminal stable & preview
[dll] calling user32.dll.SystemParameterInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, True, SPIF_UPDATEINIFILE)
[skip] Skipping Screen Saver as its toggle is disabled
[dll] calling user32.dll.SystemParameterInfo(SPI_SETTOOLTIPANIMATION, 0, True, SPIF_UPDATEINIFILE)
[appy] applying sounds
[dll] calling user32.dll.SystemParameterInfo(SPI_SETTOOLTIPFADE, 0, True, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETKEYBOARDCUES, 0, False, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETFOCUSBORDERWIDTH, 0, 1, SPIF_UPDATEINIFILE)
[dkk] calling user32.dll.SystemParameterInfo(SPI_SETFOCUSBORDERHEIGHT, 0, 1, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETCARETWIDTH, 0, 1, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETACTIVEWINDOWTRACKING, 0, False, SPIF_UPDATEINIFILE)
[reg_add] CMD: HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System > DisabledStartupSound = 0, RegistryValueKind = DWord
[dll] calling user32.dll.SystemParameterInfo(SPI_SETACTIVEWNDTRKZORDER, 0, False, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETACTIVEWNDTRKTIMEOUT, 0, 500, SPIF_UPDATEINIFILE)
[dll] calling user32.dll.SystemParameterInfo(SPI_SETSNAPTODEFBUTTON, 0, True, SPIF_UPDATEINIFILE)
[reg_add]	 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MTCUVC > EnableMtcUvc = 1, RegistryValueKind = DWord

[reg_add]	 CMD: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation > DisableStartupSound = 0, RegistryValueKind = DWord

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Desktop > PaintDesktopVersion = 0, RegistryValueKind = DWord

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Desktop > CaretWidth = 1, RegistryValueKind = DWord

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Desktop > MenuShowDelay = 400, RegistryValueKind = DWord

[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Mouse > SnapToDefaultButton = 1, RegistryValueKind = DWord

[reg_add]	 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\BootControl > BootProgressAnimation = 1, RegistryValueKind = DWord

[reg_delete] deleting HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}
[reg_delete] deleting HKCU\Software\Classes\CLSID\{1eeb5b5a-06fb-4732-96b3-975c0194eb39}
[reg_delete] deleting HKCU\Software\Classes\CLSID\{056440FD-8568-48e7-A632-72157243B55B}
[task_remove] deleting WinPaletter\Shutdown task from Task Scheduler
[task_remove] deleting WinPaletter\Logoff task from Task Scheduler
[task_remove] deleting WinPaletter\Logon task from Task Scheduler
[task_remove] deleting WinPaletter\Unlock task from Task Scheduler
[task_remove] deleting WinPaletter\ChargerConnected task from Task Scheduler
[info] saving Windows cursor colors to registry
[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Desktop > UserPreferencesMask = 158 126 6 128 146 0 0 0, RegistryValueKind = Binary
complete

@MuscularPuky
Copy link
Contributor Author

weirdly eventhough I apply aspects manually, when I restart explorer, the changes rollback.

@Abdelrhman-AK
Copy link
Owner

Abdelrhman-AK commented Mar 12, 2024

[dll] calling user32.dll.SystemParameterInfo(SPI_SETGRADIENTCAPTIONS, 0, True, SPIF_UPDATEINIFILE)
[reg_add]	 HKEY_USERS\.DEFAULT\Control Panel\Colors > ActiveBorder = 32 32 32, RegistryValueKind = String
  • That is extremely weird as there is nothing in code skips items between these two steps.
  • Did you include skipped items in themes log settings? If not, this will explain this behavior.
  • I want to see skipped registry values. There must be entries of values shown between these two lines.

[apply] apllying window metrics & fonts
[dll] calling user32.dll.SystemParameterInfo(SPI_SETDROPSHADOW, 0, True, SPIF_UPDATEINIFILE)
  • The second line here is not relevant to metrics and fonts, it is relevant Windows Effects.
  • It is logical as I made applying metrics and fonts is in a separate thread, not synchronized with main thread.
  • I made this to prevent crashing issues when Windows tries to update all open applications interfaces when metrics and fonts change.

weirdly eventhough I apply aspects manually, when I restart explorer, the changes rollback.

I faced the same issue twice last year:

  1. In some aspects elements (not all aspects) (especially in Metrics and Fonts); when I used SystemParameterInfo in shell32.dll with parameter SPIF_SENDCHANGE, then I used instead SPIF_SENDWININICHANGE and SPIF_UPDATEINIFILE | SPIF_SENDCHANGE and both fixed the issue.
  2. In multiple users; lets assume that you have two users: x and y. You can use another user differs than the user that has logged in, but there is an issue that is similar to yours. If you are in x and selected user y, both users x: partially and y will be themed. When you logoff and logon, user x will revert the preferences. The best practice it when you open WinPaletter in user x, select user x, and if you're in y select user y.

You can these steps so that I can track this bug:

  • Give me a copy of your *.wpth theme file. I'll try applying it as there is a part in code that skips registry value editing if there is value equality.
  • Delete registry key of aspect having problem with you in HKEY_CURRENT_USER\Software\WinPaletter and HKEY_CURRENT_USER\Software\WinPaletter\WindowsColorsThemes
  • Rollback WinPaletter version till you reach the version that works correctly, and tell me the version to see what has been changed in codes.
  • Use WinPaletter_DEBUG.exe with WinPaletter.pdb to see if there is an exception error occurs and see its details.

@MuscularPuky
Copy link
Contributor Author

I applyed theme in SYSTEM account then non-SYSTEM accounts automatically applied new theme and problem solved. perhaps recent Windows build changeds theme mechanism. as I know this problem happned since WinPaletter UI update. I'll test old WinPaletter versoins.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request issue Issue
Projects
None yet
Development

No branches or pull requests

2 participants