Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/myframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ MyFrame::MyFrame()
m_mgr.SetManagedWindow(this);

m_frameCounter = 0;
m_closed = false;
m_pPrimaryWorkerThread = nullptr;
StartWorkerThread(m_pPrimaryWorkerThread);
m_pSecondaryWorkerThread = nullptr;
Expand Down Expand Up @@ -2154,6 +2155,17 @@ double MyFrame::CurrentGuideErrorSmoothed() const

void MyFrame::OnClose(wxCloseEvent& event)
{
// OnClose can be called more than once. On Windows, wxApp::OnQueryEndSession calls Close() on
// the top window for every WM_QUERYENDSESSION, and Windows sends that message to each of our
// top-level windows, so a logoff or restart arrives here several times. The first call has
// already disconnected the gear and freed the help controller, and Destroy() is pending, so
// let the close go ahead without repeating the shutdown.
if (m_closed)
{
Debug.Write("MyFrame::OnClose already closed\n");
return;
}

if (CaptureActive && event.CanVeto())
{
bool confirmed = ConfirmDialog::Confirm(_("Are you sure you want to exit while capturing is active?"),
Expand All @@ -2167,6 +2179,8 @@ void MyFrame::OnClose(wxCloseEvent& event)

Debug.Write("MyFrame::OnClose proceeding\n");

m_closed = true;

StopCapturing();

bool killed = StopWorkerThread(m_pPrimaryWorkerThread);
Expand All @@ -2188,10 +2202,13 @@ void MyFrame::OnClose(wxCloseEvent& event)
this->GetSize().y, this->GetScreenPosition().x, this->GetScreenPosition().y);
pConfig->Global.SetString("/geometry", geometry);

if (help->GetFrame())
help->GetFrame()->Close();
delete help;
help = 0;
if (help)
{
if (help->GetFrame())
help->GetFrame()->Close();
delete help;
help = nullptr;
}

Destroy();
}
Expand Down
1 change: 1 addition & 0 deletions src/myframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class MyFrame : public wxFrame

bool m_continueCapturing; // should another image be captured?
SingleExposure m_singleExposure;
bool m_closed; // OnClose has already shut down the gear and servers

public:
MyFrame();
Expand Down