Fixes#5004.
This cleans up the use of controller windows. A single window is now
given the responsibility of being the master controller, which receives
messages from Keyman32 and other components around UI activation, active
keyboard, etc.
The master controller is keyman.exe's `TApplication` window, which does
not get destroyed and recreated, unlike the main form window.
Any thread which has responsibility for Keyman UI (keyman.exe main
thread, keymanx64.exe main thread) is also registered as a controller
thread. A controller thread has special handling for interactions with
keyman32 around focus tracking.
Caveats:
* While keymanx64 does not have a visible window and thus probably does
not need to be registered as a controller thread, it doesn't really
hurt.
* Note that keymanx64 registers the 32-bit controller thread as well,
which again is probably unnecessary as the 64-bit process cannot
interact with the 32-bit thread.
* Keyman's main form still handles wm_keyman_control messages, as there
are a number of other components which post to that window (e.g. text
editor, com library visual keyboard interactions). Unlike the original
problem trigger, the reference handle is not stored long-term and so
there is unlikely to be a problem with main form window re-creation
causing an issue in these contexts.
There are several TODO items in this which I will address in follow-ups,
to reduce the scope of these changes.
I hope to cherry-pick this to stable-14.0, but will run for a while in
15.0 before doing so.
UFixupMissingFile referred to an old MSI component code, which meant
that it would never actually fix the installation. This now refers to a
current component code.
I may backport this to stable-14.0 but would like to assess its
stability over time first.
Relates to #4700.
This simply adds some debug logging so that when the current crash
occurs, we can discover which windows have failed to automatically
close, which should give us enough detail to be able to reproduce the
problem, hopefully, and fix it.
Fixes#4976.
Fixes KEYMAN-WINDOWS-2K.
Fixes KEYMAN-WINDOWS-3F.
Fixes KEYMAN-WINDOWS-5A.
Fixes KEYMAN-WINDOWS-3E.
This fix reworks keymanx64's lifecycle, moving responsibility for
process shutdown from keyman.exe to keymanx64.exe.
This eliminates the need for interprocess communication, and simplifies
the startup and shutdown of keymanx64.exe. Removing this means that we
can more safely handle situations where two instances of keymanx64 may
be started, as one of them will rapidly terminate when it discovers that
its parent process has disappeared.
Fixes#4965.
When speech recognition is enabled, it sometimes activates after a
Keyman keyboard is selected. This would cause Keyman to think it is
being deactivated. We needed to check in
`CKMTipTextService::OnActivated` that it was a keyboard-type TIP that
was being activated, and only deactivate the Keyman hooks in that
situation.
This commit also adds a little logging helper function, and removes an
unused variable `guidActiveProfile`.
Fixes#4988.
Fixes KEYMAN-WINDOWS-3F.
This relates to #4976 and is a stop-gap until we implement that. It will
reduce the number of reported errors (both to us and the end user) but
does not address the core issue, which requires a more significant
refactor.
Fixes#4939.
Fixes KEYMAN-WINDOWS-70.
Fixes KEYMAN-WINDOWS-71.
Fixes KEYMAN-WINDOWS-BR.
Fixes KEYMAN-WINDOWS-6J.
I am speculating a little here, because the root cause is not visible in
the crash report, but it appears that if keyman32.dll is renamed, that
the UnregisterControllerWindows function attempts to reload keyman32.dll
which means that (a) it no longer has a list of registered controllers,
and (b) it may fail to reload.
Instead of throwing an exception, we now only log this error in
development mode. The error is not likely to cause significant trouble
for end users as they are shutting down Keyman anyway at this point.
The resolution if there is any uncertainty during an upgrade is to
restart Windows. This is less than ideal but avoids file locks and
problems with in-memory DLLs. (Future versions of Keyman will schedule
upgrades to happen automatically after a restart before Keyman has been
started, in an effort to avoid this kind of trauma.)
Fixes#4803.
This fixes part of #4803 - namely the obtrusive warning flagging that
there are mismatched modifier types in the keyboard. Instead of making
the change during tab switching, it simply shows a warning message in
the design view of the keyboard, which the developer can choose to
ignore.
This does not address the removal of comments or the switch of character
formats which is part of that conversion routine. That is a more complex
change to the parser.
Fixes#4874.
Opening product help from the tray menu would end up at a broken page.
Given the title of the link is "Help Contents", I have opted to open at
the help contents... (rather than the alternative of context/tray-menu).
Fixes#4848.
This error arose because the form was destroyed after kmshell.dpr
completes, which meant that sentry had already been destroyed. The
sentry call was simply to record a breadcrumb of the form being closed.
The fix is to move the lifecycle of the form into the `OpenTextEditor`
function. `OpenTextEditor` is used only by `initprog.RunKMCOM` and so it
is safe to remove the ApplicationRunning path of the code, which
simplifies the lifecycle of the form.
Fixes#4893.
Fixes KEYMAN-WINDOWS-50.
Fixes KEYMAN-WINDOWS-4Z.
Profile repair was using legacy code for re-establishing Keyman TIP
profiles after they had been modified by a third party app or Windows.
However, with Keyman 14's new profile registration pattern, this is both
less likely to occur and also easier to resolve (just disabling and
re-enabling the keyboard should do it).
Thus, I have opted to disable the profile repair code as, with the way
it stands at present, it may well make things worse, even aside from the
crash, because of disparities between user and admin TSF settings.
May fix#4889.
In some situations, Keyman is unable to precisely match the user's
default language with its own keyboard settings. In this situation,
Keyman may crash when attempting to install the TIP, or may give a
spurious error such as "Too many transient languages" or similar.
I have been unable to reproduce the crash described in #4889 on my
machines so this is an attempted fix.
This does fix a bug with default languages in any case so is a good fix
to include: if the user's default language is not found in Keyman's LCID
table, then Keyman would fail to install the TIP when the keyboard is
installed and would return an error message (but not crash).
Fixes#4886.
This patch includes 5 separate fixes for the various scenarios we
encountered during package installation.
1. RunTools.pas: don't attempt to install TIPs if package is not also
being installed.
2. Keyman.Setup.System.OnlineResourceCheck.pas, OnlineUpdateCheck.pas:
handle online update check for packages with spaces or periods in the
id (legacy packages only).
3. Keyman.Setup.System.InstallInfo.pas: Handle browsers renaming
downloaded files with `(n)` and `[n]` patterns as well as the current
` (n)` pattern.
4. Keyman.Setup.System.InstallInfo.pas: Handle browsers renaming
downloaded files with `_n` pattern. See code comments for details.
5. Keyman.Configuration.System.TIPMaintenance.pas: Avoid crashing if
`kmshell -install-tips-for-packages` is passed an invalid package
name.
The crash is actually fixed in point 5 above, but the root causes are
addressed in the other points.
Fixes#4830.
There remain some additional buffer size checks we should be doing in
`GetXString` but this will address the current issue by using the
standard maximum buffer size.
Fixes#4751.
Fixes KEYMAN-WINDOWS-76.
Fixes KEYMAN-WINDOWS-79.
Fixes KEYMAN-WINDOWS-7B.
Fixes KEYMAN-WINDOWS-7E.
Fixes KEYMAN-WINDOWS-7F.
Fixes KEYMAN-WINDOWS-7K.
Fixes KEYMAN-WINDOWS-7N.
Fixes KEYMAN-WINDOWS-80.
This resolves an issue where the TLangSwitchRefreshWatcher thread would
terminate early on Win7 (as it had no work to do), and free itself, but
then the main form would reference it post-free. Responsibility for free
has been moved to the main form.
This would result in various exceptions as state is corrupted at this
point.