Commit graph

3302 commits

Author SHA1 Message Date
Marc Durdin
fbcfd62678 fix(windows): refactor controller windows
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.
2021-05-11 14:47:17 +10:00
Marc Durdin
af67d180af
Merge pull request #5031 from keymanapp/fix/developer/kmdecomp-two-issues
fix(developer): two small issues in kmdecomp
2021-05-11 11:55:15 +10:00
Marc Durdin
b3087823a4
Merge pull request #5056 from keymanapp/chore/windows/remove-utilrun
chore(windows): remove unused utilrun unit
2021-05-11 11:54:28 +10:00
Marc Durdin
ed3e9caa4e chore(windows): FixupMissingFile needed current component code
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.
2021-05-11 08:39:33 +10:00
Marc Durdin
cfea41382c chore(windows): remove unused utilrun unit 2021-05-11 08:38:07 +10:00
Marc Durdin
a6a658e8bc
Merge pull request #5002 from keymanapp/fix/windows/4976-redesign-keymanx64-lifecycle
fix(windows): make keymanx64 responsible for its own lifecycle
2021-05-10 19:46:12 +10:00
Marc Durdin
39f8a8ef6f
Merge pull request #5007 from keymanapp/chore/windows/4700-get-detail-on-cefmanager-error
chore(windows): add telemetry to trace crash on exit
2021-05-10 19:35:18 +10:00
Marc Durdin
b06c8edaac
Merge pull request #5000 from keymanapp/fix/windows/4965-alternative-tips-block-activation
fix(windows): avoid disabling Keyman when speech recognition starts
2021-05-10 19:34:59 +10:00
Marc Durdin
23505d8e7b chore: remove extra file 2021-05-07 17:19:43 +10:00
Marc Durdin
a23266a6b9 chore: address review comments 2021-05-07 17:17:48 +10:00
Marc Durdin
492394c4f6 chore: address review comment 2021-05-07 17:08:11 +10:00
Marc Durdin
72b8e42732 fix(developer): two small issues in kmdecomp
1. build paths when loaded as part of solution were incorrect
2. decompiling `if` statements did not work for `!=`
2021-05-05 09:52:06 +10:00
Marc Durdin
0908df873f chore(windows): add telemetry to trace crash on exit
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.
2021-05-02 14:44:55 +10:00
Marc Durdin
ee6f8590a6 fix(windows): make keymanx64 responsible for its own lifecycle
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.
2021-04-30 15:02:18 +10:00
Darcy Wong
18a36c2de3 fix(windows): Fix more whitespace 2021-04-30 09:50:10 +07:00
Marc Durdin
097ce9ac9a fix(windows): avoid disabling Keyman when speech recognition starts
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`.
2021-04-30 09:04:12 +10:00
Darcy Wong
fa72dc5506 chore(common): Update some more strings 2021-04-28 23:15:59 +07:00
Darcy Wong
ab7e7f7ff1 chorre(common): Check in crowdin files for Azerbaijani 2021-04-28 15:17:25 +07:00
Marc Durdin
a1066f13a1
chore(windows): review comments
Co-authored-by: rc-swag <58423624+rc-swag@users.noreply.github.com>
2021-04-28 11:06:22 +10:00
Marc Durdin
94b6e1a00f fix(windows): handle errors starting keymanx64
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.
2021-04-28 10:37:47 +10:00
Marc Durdin
3a59175465 fix(windows): avoid error if keyman32.dll renamed
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.)
2021-04-21 14:21:17 +10:00
Marc Durdin
30c64f34aa
Merge pull request #4934 from keymanapp/fix/developer/4803-chiral-warning-is-disruptive
fix(developer): chiral mismatch warning is disruptive
2021-04-21 11:27:07 +10:00
Marc Durdin
58b1f926fa
Merge pull request #4918 from keymanapp/fix/developer/4917-crash-on-malformed-kpj-user-file
fix(developer): avoid crash if .kpj.user file is malformed
2021-04-21 10:24:44 +10:00
Marc Durdin
a19b7019da
Merge pull request #4922 from keymanapp/fix/windows/4874-help-contents-broken-from-tray-menu
fix(windows): help contents broken from tray menu
2021-04-21 10:22:00 +10:00
Marc Durdin
32524601f9
Merge pull request #4920 from keymanapp/fix/windows/4848-access-violation-closing-text-editor
fix(windows): access violation closing text editor
2021-04-21 10:21:48 +10:00
Marc Durdin
a8ddf018c1
Merge pull request #4899 from keymanapp/chore/windows/4893-disable-profile-repair
chore(windows): disable profile repair
2021-04-21 10:21:34 +10:00
Marc Durdin
19a8ddcc6e
Merge pull request #4890 from keymanapp/fix/windows/4889-crash-when-installing-tip
fix(windows): crash when installing TIP in some rare situations
2021-04-21 10:21:25 +10:00
Marc Durdin
1822590261
Merge pull request #4887 from keymanapp/fix/windows/4886-install-crashes-on-invalid-and-legacy-package-names
fix(windows): handle invalid package names during install
2021-04-21 10:21:09 +10:00
Marc Durdin
355eba3514 fix(developer): chiral mismatch warning is disruptive
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.
2021-04-21 10:07:33 +10:00
Marc Durdin
568e4b2e7e fix(windows): help contents broken from tray menu
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).
2021-04-20 12:54:10 +10:00
Marc Durdin
a1cf52579e fix(windows): access violation closing text editor
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.
2021-04-20 12:42:10 +10:00
Marc Durdin
4fcc23eb40
Update initprog.pas 2021-04-20 12:28:58 +10:00
Marc Durdin
3da6a28d79 fix(developer): avoid crash if .kpj.user file is malformed
Fixes #4917.

This updates `TProjectLoader` to use the same exception handling pattern
for loading the .kpj.user file as we use for the .kpj file.
2021-04-20 10:50:16 +10:00
Darcy Wong
8e8190664d
Merge pull request #4829 from keymanapp/chore/android/crowdin-id
chore(android,windows): Check in crowdin for Indonesian
2021-04-19 15:10:37 +07:00
Marc Durdin
7915429cf6 chore(windows): disable profile repair
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.
2021-04-19 15:52:07 +10:00
Darcy Wong
5e66918f0b chore(common): Update crowdin for French 2021-04-19 10:12:58 +07:00
Marc Durdin
e86704b702 fix(windows): crash when installing TIP in some rare situations
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).
2021-04-19 10:39:49 +10:00
Marc Durdin
35c82ea128 fix(windows): handle invalid package names during install
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.
2021-04-19 08:25:31 +10:00
Darcy Wong
eaabf2bfa8 chore(windows): Check in crowdin for "id" 2021-04-07 08:35:38 +07:00
Darcy Wong
d9e8a72597 fix(developer): Reduce non-canonical BCP 47 tag warning
In PackageInfoRefreshLexicalModels.ps. reduce non-canonical BCP 47 tag warning to "info" so they do not block the build.
2021-04-05 11:06:13 +07:00
Darcy Wong
41745a7b0d chore(common): Check in crowdin for Fulah 2021-04-01 09:12:31 +07:00
Marc Durdin
d1dd8b022e fix(developer): buffer size for range expansions
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.
2021-03-31 19:10:12 +11:00
Marc Durdin
3d943c7f1c
Merge pull request #4814 from keymanapp/fix/developer/4810-requote-font-names
fix(developer): requote font names
2021-03-30 13:30:45 +11:00
Marc Durdin
071bfd9011 fix(developer): requote font names
Fixes #4810.
2021-03-29 20:53:12 +11:00
Marc Durdin
e9e98010af fix(developer): open containing folder was not opening correct folder
Fixes #4773.
2021-03-25 06:44:22 +11:00
Marc Durdin
2563189bfa fix(windows): Change TLangSwitchRefreshWatcher ownership
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.
2021-03-23 08:57:24 +11:00
Marc Durdin
bec6be0329
Merge pull request #4726 from keymanapp/fix/windows/4724-avoid-double-start-during-setup
fix(windows): Avoid double start during setup
2021-03-19 20:57:58 +11:00
Marc Durdin
4e518f660d fix(windows): backup start with windows value during setup
The value is not restored for upgrades unless we back it up, because
Setup does not change these settings if they are not present :)
2021-03-19 14:40:16 +11:00
Marc Durdin
1f3d71611f fix(windows): ensure profiles are reinstalled during setup
Fixes #4725.
2021-03-19 14:26:36 +11:00
Marc Durdin
b97fc4c82c fix(windows): Avoid double start during setup
Fixes #4724.
2021-03-19 14:24:55 +11:00