CA-376480: Prevent two instances from starting after running installer

When an instance of XenCenter is already running, the installer shows the `MsiRMFilesInUse` fragment. Pressing OK within that fragment with the `WixUIRMOption` property set to `UseRM` means that the `RMShutdownAndRestart` event kicks in at the end of the installation.

This happens at the same time as the existing "Launch XenCenter" event (if the matching checkbox is checked), causing in the executable being started twice at about the same time. My guess is that the pipe system is not initialised at that point, and that's how we get two applications.

To avoid this, this commit adds a new custom property: `XS_WixUIRMPressedOk`. This is set to `1` when the user clicks OK on the `WixUIRMOption`. It allows us to know whether or not that dialog was shown at all, as checking `WixUIRMOption` is not possible (it's already set to `UseRM` by default). By checking the value of this property we prevent the "Launch XenCenter" option to be shown if `MsiRMFilesInUse` was shown to the user (and they clicked OK). This applies both in case of a repair and an upgrade from a previous version.

Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
Danilo Del Busso 2023-04-21 11:43:18 +01:00
parent 93d538c831
commit 15fcc02124
No known key found for this signature in database
2 changed files with 20 additions and 3 deletions

View File

@ -238,7 +238,7 @@
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 AND NOT (WixUI_InstallMode="Remove")
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 AND NOT (WixUI_InstallMode="Remove") AND XS_WixUIRMPressedOk="0"
</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="!(loc.XenCenter_Launch) $(var.BrandConsole)" />

View File

@ -1005,12 +1005,29 @@ diff -ru wixlib/ExitDialog.wxl wixlib/ExitDialog.wxl
- <Control Id="OptionalText" Type="Text" X="135" Y="110" Width="220" Height="80" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="[WIXUI_EXITDIALOGOPTIONALTEXT]">
- <Condition Action="show">WIXUI_EXITDIALOGOPTIONALTEXT AND NOT Installed</Condition>
+ <Control Id="OptionalText" Type="Text" X="135" Y="110" Width="220" Height="80" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="[WIXUI_EXITDIALOGOPTIONALTEXT]">
+ <Condition Action="show">WIXUI_EXITDIALOGOPTIONALTEXT AND NOT (WixUI_InstallMode="Remove")</Condition>
+ <Condition Action="show">WIXUI_EXITDIALOGOPTIONALTEXT AND NOT (WixUI_InstallMode="Remove") AND XS_WixUIRMPressedOk="0"</Condition>
</Control>
- <Control Id="OptionalCheckBox" Type="CheckBox" X="135" Y="190" Width="220" Height="40" Hidden="yes" Property="WIXUI_EXITDIALOGOPTIONALCHECKBOX" CheckBoxValue="1" Text="[WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT]">
- <Condition Action="show">WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT Installed</Condition>
+ <Control Id="OptionalCheckBox" Type="CheckBox" X="135" Y="190" Width="220" Height="40" Hidden="yes" Property="WIXUI_EXITDIALOGOPTIONALCHECKBOX" CheckBoxValue="1" Text="[WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT]">
+ <Condition Action="show">WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT (WixUI_InstallMode="Remove")</Condition>
+ <Condition Action="show">WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT AND NOT (WixUI_InstallMode="Remove") AND XS_WixUIRMPressedOk="0"</Condition>
</Control>
</Dialog>
diff --git wixlib/MsiRMFilesInUse.wxs wixlib/MsiRMFilesInUse.wxs
--- wixlib/MsiRMFilesInUse.wxs
+++ wixlib/MsiRMFilesInUse.wxs
@@ -6,10 +6,13 @@
<Fragment>
<UI>
<Property Id="WixUIRMOption" Value="UseRM" />
+ <!-- XS_WixUIRMPressedOk is a custom property. This can be checked to ensure that users did not proceed after using this dialog.-->
+ <Property Id="XS_WixUIRMPressedOk" Value="0" />
<Dialog Id="MsiRMFilesInUse" Width="370" Height="270" Title="!(loc.MsiRMFilesInUse_Title)" KeepModeless="yes">
<Control Id="OK" Type="PushButton" X="240" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUIOK)">
<Publish Event="EndDialog" Value="Return">1</Publish>
<Publish Event="RMShutdownAndRestart" Value="0">WixUIRMOption~="UseRM"</Publish>
+ <Publish Property="XS_WixUIRMPressedOk" Value="1">1</Publish>
</Control>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="EndDialog" Value="Exit">1</Publish>