Skip to content

Commit 691e280

Browse files
committed
Compare again if all panes reload as a result of clicking the link
1 parent 4ef5283 commit 691e280

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/WinWebDiffLib/WebDiffWindow.hpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,13 @@ class CWebDiffWindow : public IWebDiffWindow
7979
if (m_hWnd)
8080
{
8181
Close();
82-
std::shared_ptr<int> counter(new int{ nPanes });
8382
for (int i = 0; i < nPanes; ++i)
8483
{
8584
std::wstring userDataFolder = GetUserDataFolderPath(i);
8685
ComPtr<IWebDiffCallback> callback2(callback);
8786
hr = m_webWindow[i].Create(m_hInstance, m_hWnd, urls[i], userDataFolder.c_str(),
8887
m_size, m_fitToWindow, m_zoom, m_userAgent, nullptr,
89-
[this, i, counter, callback2](WebDiffEvent::EVENT_TYPE event, IUnknown* sender, IUnknown* args)
88+
[this, i, callback2](WebDiffEvent::EVENT_TYPE event, IUnknown* sender, IUnknown* args)
9089
{
9190
WebDiffEvent ev{};
9291
ev.type = event;
@@ -122,6 +121,8 @@ class CWebDiffWindow : public IWebDiffWindow
122121
}
123122
else if (event == WebDiffEvent::NavigationStarting)
124123
{
124+
m_documentLoaded[ev.pane] = false;
125+
m_urlChanged[ev.pane] = true;
125126
SetCompareState(NOT_COMPARED);
126127
}
127128
else if (event == WebDiffEvent::FrameNavigationStarting)
@@ -130,9 +131,13 @@ class CWebDiffWindow : public IWebDiffWindow
130131
else if (event == WebDiffEvent::NavigationCompleted)
131132
{
132133
addEventListener(sender, ev.pane, nullptr);
133-
*counter = *counter - 1;
134-
if (*counter == 0)
134+
m_documentLoaded[ev.pane] = true;
135+
if ((std::count(m_documentLoaded, m_documentLoaded + m_nPanes, true) == m_nPanes) &&
136+
(std::count(m_urlChanged, m_urlChanged + m_nPanes, true) == m_nPanes))
137+
{
138+
std::fill_n(m_urlChanged, m_nPanes, false);
135139
Recompare(callback2.Get());
140+
}
136141
}
137142
else if (event == WebDiffEvent::FrameNavigationCompleted)
138143
{
@@ -1477,6 +1482,8 @@ class CWebDiffWindow : public IWebDiffWindow
14771482
bool m_bShowDifferences = true;
14781483
bool m_bShowWordDifferences = true;
14791484
bool m_bSynchronizeEvents = true;
1485+
bool m_documentLoaded[3] = { false, false, false };
1486+
bool m_urlChanged[3] = { false, false, false };
14801487
unsigned m_eventSyncFlags = EVENT_SCROLL | EVENT_CLICK | EVENT_INPUT | EVENT_GOBACKFORWARD;
14811488
CompareState m_compareState = NOT_COMPARED;
14821489
IWebDiffWindow::ColorSettings m_colorSettings = {

0 commit comments

Comments
 (0)