Skip to content

Commit aaea40e

Browse files
committed
Defer Comparer command-line open until startup settles
1 parent 71f3251 commit aaea40e

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

.github/workflows/store-validation-trial.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ jobs:
149149
}
150150
[Q1WindowTools]::ShowWindowAsync($process.MainWindowHandle, 3) | Out-Null
151151
Start-Sleep -Seconds 3
152+
$process.Refresh()
153+
if ($process.HasExited) {
154+
throw "$exeName exited after opening its command-line source input."
155+
}
152156
153157
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
154158
"$exeName primary screen: $($bounds.Width)x$($bounds.Height)" |

Comparer/MainFrm.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
5151
ON_WM_TIMER()
5252
ON_WM_DESTROY()
5353
ON_WM_CREATE()
54+
ON_MESSAGE(WM_OPEN_PENDING_FILE, &CMainFrame::OnOpenPendingFile)
5455
END_MESSAGE_MAP()
5556

5657
CMainFrame::CMainFrame()
@@ -646,8 +647,21 @@ void CMainFrame::ActivateFrame(int nCmdShow)
646647
CFrameWnd::ActivateFrame(nCmdShow);
647648

648649
CComparerDoc *pDoc = static_cast<CComparerDoc *>(GetActiveDocument());
649-
if (pDoc->mPendingFile != "") {
650-
pDoc->OnOpenDocument(pDoc->mPendingFile);
651-
pDoc->mPendingFile = "";
652-
}
650+
if (pDoc != NULL && !pDoc->mPendingFile.IsEmpty())
651+
PostMessage(WM_OPEN_PENDING_FILE);
652+
}
653+
654+
LRESULT CMainFrame::OnOpenPendingFile(WPARAM, LPARAM)
655+
{
656+
CComparerDoc *pDoc = static_cast<CComparerDoc *>(GetActiveDocument());
657+
if (pDoc == NULL || pDoc->mPendingFile.IsEmpty())
658+
return 0;
659+
660+
// Wait until startup activation and layout messages have completed before a
661+
// multi-source open starts metric calculation and the scan worker.
662+
CString pendingFile = pDoc->mPendingFile;
663+
pDoc->mPendingFile.Empty();
664+
pDoc->OnOpenDocument(pendingFile);
665+
666+
return 0;
653667
}

Comparer/MainFrm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#define FRAMES_INFO_H 84
1414
#define POS_INFO_W 76
1515

16+
#define WM_OPEN_PENDING_FILE (WM_APP + 1)
17+
1618
#define COMPARER_DEF_W (CANVAS_DEF_W + /* left */ \
1719
(CANVAS_DEF_W + QSPLITTER_W) + /* right */ \
1820
(POS_INFO_W + QSPLITTER_W)) /* position */
@@ -98,6 +100,7 @@ class CMainFrame : public CFrameWnd
98100
afx_msg void OnFpsChange(UINT nID);
99101
afx_msg void OnViewsChange(UINT nID);
100102
afx_msg void OnOptionsChange(UINT nID);
103+
afx_msg LRESULT OnOpenPendingFile(WPARAM wParam, LPARAM lParam);
101104
virtual void ActivateFrame(int nCmdShow = -1);
102105
};
103106

0 commit comments

Comments
 (0)