@@ -307,7 +307,7 @@ class CWebDiffWindow : public IWebDiffWindow
307307 }
308308 else if (event == WebDiffEvent::NavigationStarting)
309309 {
310- m_compareState = NOT_COMPARED;
310+ SetCompareState ( NOT_COMPARED) ;
311311 }
312312 else if (event == WebDiffEvent::FrameNavigationStarting)
313313 {
@@ -675,7 +675,6 @@ class CWebDiffWindow : public IWebDiffWindow
675675 void SetDiffOptions (const DiffOptions& diffOptions) override
676676 {
677677 m_diffOptions = diffOptions;
678- Recompare (nullptr );
679678 }
680679
681680 bool GetSyncEvents () const
@@ -716,6 +715,18 @@ class CWebDiffWindow : public IWebDiffWindow
716715 return m_compareState;
717716 }
718717
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+
719730 int GetDiffCount () const override
720731 {
721732 return static_cast <int >(m_diffInfos.size ());
@@ -981,7 +992,7 @@ class CWebDiffWindow : public IWebDiffWindow
981992
982993 HRESULT compare (IWebDiffCallback* callback)
983994 {
984- m_compareState = COMPARING;
995+ SetCompareState ( COMPARING) ;
985996 ComPtr<IWebDiffCallback> callback2 (callback);
986997 std::shared_ptr<std::vector<std::wstring>> jsons (new std::vector<std::wstring>());
987998 HRESULT hr = getDocumentsLoop (jsons,
@@ -1034,27 +1045,27 @@ class CWebDiffWindow : public IWebDiffWindow
10341045 Callback<IWebDiffCallback>([this , callback2](const WebDiffCallbackResult& result) -> HRESULT
10351046 {
10361047 HRESULT hr = result.errorCode ;
1037- m_compareState = FAILED (hr) ? NOT_COMPARED : COMPARED;
1048+ SetCompareState ( FAILED (hr) ? NOT_COMPARED : COMPARED) ;
10381049 if (callback2)
10391050 return callback2->Invoke ({ hr, nullptr });
10401051 return S_OK;
10411052 }).Get ());
10421053 }
10431054 if (FAILED (hr))
1044- m_compareState = NOT_COMPARED;
1055+ SetCompareState ( NOT_COMPARED) ;
10451056 if (FAILED (hr) && callback2)
10461057 return callback2->Invoke ({ hr, nullptr });
10471058 return S_OK;
10481059 }).Get ());
10491060 }
10501061 if (FAILED (hr))
1051- m_compareState = NOT_COMPARED;
1062+ SetCompareState ( NOT_COMPARED) ;
10521063 if (FAILED (hr) && callback2)
10531064 return callback2->Invoke ({ hr, nullptr });
10541065 return S_OK;
10551066 }).Get ());
10561067 if (FAILED (hr))
1057- m_compareState = NOT_COMPARED;
1068+ SetCompareState ( NOT_COMPARED) ;
10581069 return hr;
10591070 }
10601071
0 commit comments