@@ -480,6 +480,8 @@ class UpdateDialog : public WinSparkleDialog
480
480
bool m_installAutomatically;
481
481
// whether an error occurred (used to properly call NotifyUpdateCancelled)
482
482
bool m_errorOccurred;
483
+ // whether window closure was updater-initiated (i.e. not caused by user)
484
+ bool m_closeInitiatedByUpdater;
483
485
484
486
static const int RELNOTES_WIDTH = 460 ;
485
487
static const int RELNOTES_HEIGHT = 200 ;
@@ -492,6 +494,7 @@ UpdateDialog::UpdateDialog()
492
494
{
493
495
m_installAutomatically = false ;
494
496
m_errorOccurred = false ;
497
+ m_closeInitiatedByUpdater = false ;
495
498
496
499
m_heading = new wxStaticText (this , wxID_ANY, " " );
497
500
SetHeadingFont (m_heading);
@@ -594,7 +597,7 @@ void UpdateDialog::OnTimer(wxTimerEvent&)
594
597
595
598
void UpdateDialog::OnCloseButton (wxCommandEvent&)
596
599
{
597
- ApplicationController::NotifyUpdateDismissed () ;
600
+ m_closeInitiatedByUpdater = false ;
598
601
Close ();
599
602
}
600
603
@@ -615,18 +618,23 @@ void UpdateDialog::OnClose(wxCloseEvent&)
615
618
// destroy itself in Close().
616
619
Destroy ();
617
620
618
- // If the update was not downloaded and the appcast is empty and we're closing,
619
- // it means that we're about to restart or there was an error, and that the
620
- // window-close event wasn't initiated by the user.
621
- if ( m_appcast.IsValid () && m_updateFile.IsEmpty () && !m_errorOccurred )
622
- ApplicationController::NotifyUpdateCancelled ();
621
+ // Notify about window being dismissed or update cancelled. We must not notify
622
+ // if window closure was initiated by WinSparkle itself e.g. to run the installer.
623
+ if (!m_closeInitiatedByUpdater)
624
+ {
625
+ if (!m_errorOccurred && m_appcast.IsValid ())
626
+ ApplicationController::NotifyUpdateCancelled ();
627
+
628
+ ApplicationController::NotifyUpdateDismissed ();
629
+ }
623
630
}
624
631
625
632
626
633
void UpdateDialog::OnSkipVersion (wxCommandEvent&)
627
634
{
628
635
Settings::WriteConfigValue (" SkipThisVersion" , m_appcast.Version );
629
636
ApplicationController::NotifyUpdateSkipped ();
637
+ m_closeInitiatedByUpdater = false ; // skipping is cancellation
630
638
Close ();
631
639
}
632
640
@@ -636,6 +644,7 @@ void UpdateDialog::OnRemindLater(wxCommandEvent&)
636
644
// Just abort the update. Next time it's scheduled to run,
637
645
// the user will be prompted.
638
646
ApplicationController::NotifyUpdatePostponed ();
647
+ m_closeInitiatedByUpdater = false ; // skipping is cancellation
639
648
Close ();
640
649
}
641
650
@@ -645,6 +654,7 @@ void UpdateDialog::OnInstall(wxCommandEvent&)
645
654
if ( !m_appcast.HasDownload () )
646
655
{
647
656
wxLaunchDefaultBrowser (m_appcast.WebBrowserURL , wxBROWSER_NEW_WINDOW);
657
+ m_closeInitiatedByUpdater = true ;
648
658
Close ();
649
659
}
650
660
else if ( m_downloader == NULL )
@@ -685,6 +695,7 @@ void UpdateDialog::OnRunInstaller(wxCommandEvent&)
685
695
}
686
696
else
687
697
{
698
+ m_closeInitiatedByUpdater = true ;
688
699
Close ();
689
700
ApplicationController::RequestShutdown ();
690
701
}
@@ -757,6 +768,7 @@ void UpdateDialog::StateNoUpdateFound(bool installAutomatically)
757
768
758
769
if ( m_installAutomatically )
759
770
{
771
+ m_closeInitiatedByUpdater = true ;
760
772
Close ();
761
773
return ;
762
774
}
0 commit comments