V2 port update - Add COM initialization retries and pointer guards to prevent startup crashes #89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix initialization crash by adding COM retry logic and pointer safety checks
When
VD.ahkis loaded as part of my main AHK script at user logon, initialization occasionally runs before Windows has fully registered the virtual-desktop COM services. This caused early-boot failures and null COM pointers downstream.What was happening
Two issues surfaced during early-boot initialization:
this._initMaxAttemptswas accessed before being defined, causing:Error: This value of type "Class" has no property named "_initMaxAttempts".
Windows had not yet registered several virtual-desktop COM classes, leading to:
Error: (0x80040154) Class not registered
when constructing:
{aa509086-5ca9-4c25-8f95-589d3c07b48a}{c2f03a33-21f5-47fa-b4bb-156362a2f239}As a result,
_init()failed and key COM pointers (e.g.,ptr_GetViewForHwnd) remained unset, causing crashes when callinggetDesktopNumOfWindowvia hotkeys.What this PR changes
_initMaxAttemptsand related internal members are defined before their first use.These changes stabilize initialization on boot and prevent hotkey-triggered crashes when COM services are briefly unavailable.