@@ -307,7 +307,7 @@ class CWebDiffWindow : public IWebDiffWindow
307
307
}
308
308
else if (event == WebDiffEvent::NavigationStarting)
309
309
{
310
- m_compareState = NOT_COMPARED;
310
+ SetCompareState ( NOT_COMPARED) ;
311
311
}
312
312
else if (event == WebDiffEvent::FrameNavigationStarting)
313
313
{
@@ -675,7 +675,6 @@ class CWebDiffWindow : public IWebDiffWindow
675
675
void SetDiffOptions (const DiffOptions& diffOptions) override
676
676
{
677
677
m_diffOptions = diffOptions;
678
- Recompare (nullptr );
679
678
}
680
679
681
680
bool GetSyncEvents () const
@@ -716,6 +715,18 @@ class CWebDiffWindow : public IWebDiffWindow
716
715
return m_compareState;
717
716
}
718
717
718
+ void SetCompareState (CompareState compareState)
719
+ {
720
+ CompareState oldCompareState = m_compareState;
721
+ m_compareState = compareState;
722
+ if (m_compareState != oldCompareState)
723
+ {
724
+ WebDiffEvent ev{ WebDiffEvent::CompareStateChanged, -1 };
725
+ for (const auto & listener : m_listeners)
726
+ listener->Invoke (ev);
727
+ }
728
+ }
729
+
719
730
int GetDiffCount () const override
720
731
{
721
732
return static_cast <int >(m_diffInfos.size ());
@@ -981,7 +992,7 @@ class CWebDiffWindow : public IWebDiffWindow
981
992
982
993
HRESULT compare (IWebDiffCallback* callback)
983
994
{
984
- m_compareState = COMPARING;
995
+ SetCompareState ( COMPARING) ;
985
996
ComPtr<IWebDiffCallback> callback2 (callback);
986
997
std::shared_ptr<std::vector<std::wstring>> jsons (new std::vector<std::wstring>());
987
998
HRESULT hr = getDocumentsLoop (jsons,
@@ -1034,27 +1045,27 @@ class CWebDiffWindow : public IWebDiffWindow
1034
1045
Callback<IWebDiffCallback>([this , callback2](const WebDiffCallbackResult& result) -> HRESULT
1035
1046
{
1036
1047
HRESULT hr = result.errorCode ;
1037
- m_compareState = FAILED (hr) ? NOT_COMPARED : COMPARED;
1048
+ SetCompareState ( FAILED (hr) ? NOT_COMPARED : COMPARED) ;
1038
1049
if (callback2)
1039
1050
return callback2->Invoke ({ hr, nullptr });
1040
1051
return S_OK;
1041
1052
}).Get ());
1042
1053
}
1043
1054
if (FAILED (hr))
1044
- m_compareState = NOT_COMPARED;
1055
+ SetCompareState ( NOT_COMPARED) ;
1045
1056
if (FAILED (hr) && callback2)
1046
1057
return callback2->Invoke ({ hr, nullptr });
1047
1058
return S_OK;
1048
1059
}).Get ());
1049
1060
}
1050
1061
if (FAILED (hr))
1051
- m_compareState = NOT_COMPARED;
1062
+ SetCompareState ( NOT_COMPARED) ;
1052
1063
if (FAILED (hr) && callback2)
1053
1064
return callback2->Invoke ({ hr, nullptr });
1054
1065
return S_OK;
1055
1066
}).Get ());
1056
1067
if (FAILED (hr))
1057
- m_compareState = NOT_COMPARED;
1068
+ SetCompareState ( NOT_COMPARED) ;
1058
1069
return hr;
1059
1070
}
1060
1071
0 commit comments