Skip to content

Commit

Permalink
Merged PR 683: V3.2.20 Release 16
Browse files Browse the repository at this point in the history
- BugFix: 'System.NullReferenceException: Object reference not set to an instance of an object' sometimes seen after editing a structure to combine two molecules

Related work items: #1154
  • Loading branch information
MikeWilliams-UK committed Aug 21, 2024
1 parent 34e2632 commit 1ed8dd7
Show file tree
Hide file tree
Showing 36 changed files with 177 additions and 63 deletions.
34 changes: 32 additions & 2 deletions src/Chem4Word.V3/Chem4WordV3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Timers;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Threading;
Expand Down Expand Up @@ -85,6 +86,8 @@ public partial class Chem4WordV3
public LibraryOptions LibraryOptions;
public TelemetryWriter Telemetry;

private System.Timers.Timer _timer;

public List<IChem4WordEditor> Editors = new List<IChem4WordEditor>();
public List<IChem4WordRenderer> Renderers = new List<IChem4WordRenderer>();
public List<IChem4WordSearcher> Searchers = new List<IChem4WordSearcher>();
Expand Down Expand Up @@ -332,6 +335,11 @@ private void PerformStartUpActions()

try
{
_timer = new System.Timers.Timer(1000);
_timer.Elapsed += OnTimerElapsed;
_timer.AutoReset = true;
_timer.Enabled = true;

SetButtonStates(ButtonState.NoDocument);

LoadOptions();
Expand Down Expand Up @@ -421,6 +429,23 @@ private void PerformStartUpActions()
}
}

private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{
if (Telemetry != null
&& Helper != null
&& !string.IsNullOrEmpty(Helper.IpAddress)
&& !Helper.IpAddress.Equals("0.0.0.0")
&& !Helper.IpAddress.Equals("0.0.0.0"))
{
RegistryHelper.SendSetupActions();
RegistryHelper.SendUpdateActions();
RegistryHelper.SendMsiActions();

_timer.Enabled = false;
_timer.Elapsed -= OnTimerElapsed;
}
}

public void LoadNamesFromLibrary()
{
var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod()?.Name}()";
Expand Down Expand Up @@ -931,7 +956,7 @@ public IChem4WordRenderer GetRendererPlugIn(string name)
}
}
}

if (plugin == null)
{
Telemetry.Write(module, "Warning", $"Could not find renderer plug in {name}");
Expand Down Expand Up @@ -1633,6 +1658,8 @@ private void HandleRightClick(Word.Selection selection)
Telemetry.Write(module, "Exception", ex.ToString());
}

ClearChemistryContextMenus();

if (selectedWords.Count > 0)
{
AddChemistryMenuPopup(selectedWords);
Expand Down Expand Up @@ -1711,7 +1738,8 @@ private void ClearChemistryContextMenus()
var popupControl = (CommandBarPopup)contextMenu.FindControl(
MsoControlType.msoControlPopup, Type.Missing,
ContextMenuTag, true, true);
if (popupControl != null)
if (popupControl != null
&& popupControl.Caption.Equals(ContextMenuText))
{
popupControl.Delete(true);
}
Expand Down Expand Up @@ -1853,6 +1881,8 @@ private void OnDocumentChange()
DisableContentControlEvents();
EnableContentControlEvents();

ClearChemistryContextMenus();

SelectChemistry(document.Application.Selection);
EvaluateChemistryAllowed();

Expand Down
8 changes: 2 additions & 6 deletions src/Chem4Word.V3/Data/Chem4Word-Versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
<Version>
<Number>3.2.20 Release 16</Number>
<IsBeta>false</IsBeta>
<Released>31-Aug-2024</Released>
<Released>21-Aug-2024</Released>
<Changes>
<Change>...</Change>
<Change>...</Change>
<Change>BugFix: 'System.NullReferenceException: Object reference not set to an instance of an object' sometimes seen after editing a structure to combine two molecules</Change>
<Change>Please note any previous beta versions V3.2.4 and below will cease to allow insertion or editing of chemistry</Change>
<Change>If you like our product, please consider buying us a coffee at https://www.buymeacoffee.com/chem4word</Change>
<Change>Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating</Change>
Expand All @@ -24,9 +23,6 @@
<Change>UX: Prohibit import of binary files</Change>
<Change>BugFix: User unable to hide Hydrogens in Renderer (seen in Word document)</Change>
<Change>Security: Update NuGet packages (Microsoft Security Advisory CVE-2024-30105)</Change>
<Change>Please note any previous beta versions V3.2.4 and below will cease to allow insertion or editing of chemistry</Change>
<Change>If you like our product, please consider buying us a coffee at https://www.buymeacoffee.com/chem4word</Change>
<Change>Please download Chem4Word-Setup.exe via https://www.chem4word.co.uk/download/ if you encounter any difficulties updating</Change>
</Changes>
</Version>
<Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Chem4Word.V3/Data/This-Version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<Version>
<Number>3.2.20 Release 16</Number>
<IsBeta>false</IsBeta>
<Released>31-Aug-2024</Released>
<Released>21-Aug-2024</Released>
</Version>
13 changes: 12 additions & 1 deletion src/Chem4Word.V3/Helpers/RegistryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ public static void SendUpdateActions()
}
}

public static void SendMsiActions()
{
var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";

var registryKey = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordMsiActionsRegistryKey, true);
if (registryKey != null)
{
SendValues(module, "Setup", registryKey);
}
}

public static void SendMessages()
{
var module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()";
Expand All @@ -103,7 +114,7 @@ public static void SendExceptions()
var registryKey = Registry.CurrentUser.OpenSubKey(Constants.Chem4WordExceptionsRegistryKey, true);
if (registryKey != null)
{
SendValues(module, "Exceptions", registryKey);
SendValues(module, "Exception", registryKey);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Chem4Word.V3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
1 change: 1 addition & 0 deletions src/Chem4Word.V3/Ribbon/Chem4WordRibbon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ private void AfterButtonChecks(RibbonButton button)
{
RegistryHelper.SendSetupActions();
RegistryHelper.SendUpdateActions();
RegistryHelper.SendMsiActions();
RegistryHelper.SendMessages();
RegistryHelper.SendExceptions();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Chemistry/Chem4Word.ACME/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
4 changes: 2 additions & 2 deletions src/Chemistry/Chem4Word.Libraries/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
4 changes: 2 additions & 2 deletions src/Chemistry/Chem4Word.Model2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
2 changes: 2 additions & 0 deletions src/Common/Chem4Word.Core/Helpers/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ public static class Constants
public const string RegistryValueNameAvailableVersion = "Available Version";
public const string RegistryValueNameAvailableIsBeta = "Available Is Beta";
public const string RegistryValueNameEndOfLife = "End of Life";

public const string Chem4WordSetupRegistryKey = @"SOFTWARE\Chem4Word V3\Setup";
public const string Chem4WordUpdateRegistryKey = @"SOFTWARE\Chem4Word V3\Update";
public const string Chem4WordMsiActionsRegistryKey = @"SOFTWARE\Chem4Word V3\MsiActions";
public const string Chem4WordMessagesRegistryKey = @"SOFTWARE\Chem4Word V3\Messages";
public const string Chem4WordExceptionsRegistryKey = @"SOFTWARE\Chem4Word V3\Exceptions";
public const string Chem4WordAzureSettingsRegistryKey = @"SOFTWARE\Chem4Word V3\AzureSettings";
Expand Down
4 changes: 2 additions & 2 deletions src/Common/Chem4Word.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
4 changes: 2 additions & 2 deletions src/Common/Chem4Word.Telemetry/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
4 changes: 2 additions & 2 deletions src/Installer/Chem4WordSetup/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
4 changes: 2 additions & 2 deletions src/Installer/Chem4WordUpdater/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
44 changes: 42 additions & 2 deletions src/Installer/WiX.CustomAction/CustomAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// Copyright (c) 2024, The .NET Foundation.
// This software is released under the Apache License, Version 2.0.
// The license and further copyright text can be found in the file LICENSE.md
Expand All @@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
Expand Down Expand Up @@ -88,6 +89,45 @@ public static ActionResult SetupChem4Word(Session session)
return ActionResult.Success;
}

[CustomAction]
public static ActionResult SetupChem4WordUser(Session session)
{
session.Log($"Begin {nameof(SetupChem4Word)}()");

session.Log($" Running as {Environment.UserName}");

try
{
const string baseKey = @"SOFTWARE\Chem4Word V3";

var key = Registry.CurrentUser.OpenSubKey(baseKey, true);
if (key == null)
{
key = Registry.CurrentUser.CreateSubKey(baseKey);
}

string actionsKey = $@"{baseKey}\MsiActions";
key = Registry.CurrentUser.OpenSubKey(actionsKey, true);
if (key == null)
{
key = key = Registry.CurrentUser.CreateSubKey(actionsKey);
}

var versionNumber = "3.2.20.8999";

string timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture);
key.SetValue(timestamp, $"[-] V{versionNumber} - Installed");
}
catch (Exception ex)
{
session.Log($"** Exception: {ex.Message} **");
}

session.Log($"End {nameof(SetupChem4Word)}()");

return ActionResult.Success;
}

private static void ModifyFolderPermissions(Session session)
{
session.Log($" Fixing SpecialFolder.CommonApplicationData {ProgramDataFolder}");
Expand Down Expand Up @@ -474,4 +514,4 @@ private static void RegisterChem4WordAddIn(Session session, RegistryKey rk, stri
session.Log($" End {nameof(RegisterChem4WordAddIn)}()");
}
}
}
}
4 changes: 2 additions & 2 deletions src/Installer/WiX.CustomAction/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
4 changes: 3 additions & 1 deletion src/Installer/WiXInstaller/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- For automatic upgrade to work only first three parts of version number are used -->
<Product Id="*" Name="Chemistry Add-In for Microsoft Word 2022 Release 16" Manufacturer="Chem4Word" Version="3.2.20.9009" UpgradeCode="865226e7-d29d-49aa-a390-dda49979b102" Language="1033">
<Product Id="*" Name="Chemistry Add-In for Microsoft Word 2022 Release 16" Manufacturer="Chem4Word" Version="3.2.20.8999" UpgradeCode="865226e7-d29d-49aa-a390-dda49979b102" Language="1033">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of Chem4Word is already installed." />
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" CompressionLevel="high" />
Expand Down Expand Up @@ -52,6 +52,7 @@
<CustomAction Id="CleanUserRegistry" BinaryKey="WiX.CustomAction.dll" DllEntry="CleanUserRegistry" Return="check" Execute="deferred" Impersonate="yes" />
<CustomAction Id="CleanSystemRegistry" BinaryKey="WiX.CustomAction.dll" DllEntry="CleanSystemRegistry" Return="check" Execute="deferred" Impersonate="no" />
<CustomAction Id="SetupChem4Word" BinaryKey="WiX.CustomAction.dll" DllEntry="SetupChem4Word" Return="check" Execute="deferred" Impersonate="no" />
<CustomAction Id="SetupChem4WordUser" BinaryKey="WiX.CustomAction.dll" DllEntry="SetupChem4WordUser" Return="check" Execute="deferred" Impersonate="yes" />
<CustomAction Id="RemoveChem4Word" BinaryKey="WiX.CustomAction.dll" DllEntry="RemoveChem4Word" Return="check" Execute="deferred" Impersonate="no" />
<InstallUISequence>
<Custom Action="WordProcessCount" Before="LaunchConditions" />
Expand All @@ -60,6 +61,7 @@
<Custom Action="CleanUserRegistry" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="CleanSystemRegistry" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="SetupChem4Word" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="SetupChem4WordUser" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="RemoveChem4Word" Before="InstallFinalize">Installed</Custom>
</InstallExecuteSequence>
<Property Id="VSTODESIGNTIME">
Expand Down
10 changes: 6 additions & 4 deletions src/Installer/WiXInstaller/Test.cmd
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
dir bin\Setup\
rem pause

set release=Chem4Word-Setup.3.2.20.Release.16.msi

del setup.log
del remove.log

msiexec /i bin\Setup\Chem4Word-Setup.3.1.16.Release.6.msi /l*v setup.log
msiexec /i bin\Setup\%release% /l*v setup.log

rem pause
pause

msiexec /uninstall bin\Setup\Chem4Word-Setup.3.1.16.Release.6.msi /l*v remove.log
msiexec /uninstall bin\Setup\%release% /l*v remove.log

rem pause
pause

rem find "Property(" setup.log > properties.log
rem search logs for "Calling custom action WiX.CustomAction"
Binary file not shown.
4 changes: 4 additions & 0 deletions src/Installer/WiXInstaller/WiX-Installer.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<Content Include="Chem4Word.ico" />
<Content Include="EULA.rtf" />
<Content Include="Test.cmd" />
<Content Include="Testing\Insert Test Messages.reg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Chem4Word.V3\Chem4Word.V3.csproj">
Expand All @@ -69,6 +70,9 @@
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Testing" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion src/Notes/Releases.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set Build Numbers

.\Set-Assembly-Version.ps1 -version 3.2.20 -name "Release 16" -released "31-Aug-2024" -path ..
.\Set-Assembly-Version.ps1 -version 3.2.20 -name "Release 16" -released "21-Aug-2024" -path ..

.\Set-Assembly-Version.ps1 -version 3.2.19 -name "Release 15" -released "07-Aug-2024" -path ..
.\Set-Assembly-Version.ps1 -version 3.2.18 -name "Release 14" -released "28-Mar-2024" -path ..
Expand Down
4 changes: 2 additions & 2 deletions src/PlugIns/Contracts/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.2.20.9009")]
[assembly: AssemblyFileVersion("3.2.20.9009")]
[assembly: AssemblyVersion("3.2.20.8999")]
[assembly: AssemblyFileVersion("3.2.20.8999")]
Loading

0 comments on commit 1ed8dd7

Please sign in to comment.