KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGIT_STATUS_REPORTER Class Reference

One background git transfer owned by the window that started it: the cancellation, whether one is running, and the owner's lifetime. More...

#include <git_transfer.h>

Inheritance diagram for KIGIT_STATUS_REPORTER:
PROGRESS_REPORTER_BASE PROGRESS_REPORTER

Public Member Functions

 KIGIT_STATUS_REPORTER (const std::weak_ptr< bool > &aAlive, std::function< void(const wxString &)> aShow)
 
void SetNumPhases (int aNumPhases) override
 Set the number of phases.
 
void AddPhases (int aNumPhases) override
 
virtual void BeginPhase (int aPhase) override
 Initialize the aPhase virtual zone of the dialog progress bar.
 
virtual void AdvancePhase () override
 Use the next available virtual zone of the dialog progress bar.
 
virtual void AdvancePhase (const wxString &aMessage) override
 Use the next available virtual zone of the dialog progress bar and updates the message.
 
virtual void Report (const wxString &aMessage) override
 Display aMessage in the progress bar dialog.
 
virtual void SetCurrentProgress (double aProgress) override
 Set the progress value to aProgress (0..1).
 
void SetMaxProgress (int aMaxProgress) override
 Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).
 
void AdvanceProgress () override
 Increment the progress bar length (inside the current virtual zone).
 
bool KeepRefreshing (bool aWait=false) override
 Update the UI dialog.
 
void SetTitle (const wxString &aTitle) override
 Change the title displayed on the window caption.
 
bool IsCancelled () const override
 
int CurrentProgress () const
 
virtual void SetIndeterminate (bool aIndeterminate)
 Ask for an indeterminate (pulsing) display, for work whose total is not known yet.
 

Protected Member Functions

bool updateUI () override
 

Protected Attributes

wxString m_rptMessage
 
std::mutex m_mutex
 
std::atomic_int m_phase
 
std::atomic_int m_numPhases
 
std::atomic_int m_progress
 
std::atomic_int m_maxProgress
 
std::atomic_bool m_cancelled
 
std::atomic_bool m_messageChanged
 

Private Attributes

std::weak_ptr< bool > m_alive
 
std::function< void(const wxString &)> m_show
 
wxString m_lastShown
 

Detailed Description

One background git transfer owned by the window that started it: the cancellation, whether one is running, and the owner's lifetime.

Push, pull, fetch and force push each used to keep this in a shape of their own, and the disagreement is how one of them came to read a finished thread as a running one. The transfer itself runs on a thread the orphan registry owns, so closing the window does not wait for the socket, and the completion is delivered only while this object still exists. A progress reporter that writes a line of text instead of opening a dialog over the editor. libgit2's callbacks drive it from a worker, so each line is handed to the UI thread and dropped once the window that started the transfer has gone.

aShow must be safe to copy and destroy on a worker, so it may hold a raw window pointer but never a wxWeakRef. It runs only on the UI thread and only while aAlive holds.

Definition at line 78 of file git_transfer.h.

Constructor & Destructor Documentation

◆ KIGIT_STATUS_REPORTER()

KIGIT_STATUS_REPORTER::KIGIT_STATUS_REPORTER ( const std::weak_ptr< bool > & aAlive,
std::function< void(const wxString &)> aShow )

Member Function Documentation

◆ AddPhases()

void PROGRESS_REPORTER_BASE::AddPhases ( int aNumPhases)
overridevirtualinherited

Implements PROGRESS_REPORTER.

Definition at line 94 of file progress_reporter_base.cpp.

References m_numPhases.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ AdvancePhase() [1/2]

void PROGRESS_REPORTER_BASE::AdvancePhase ( )
overridevirtualinherited

◆ AdvancePhase() [2/2]

void PROGRESS_REPORTER_BASE::AdvancePhase ( const wxString & aMessage)
overridevirtualinherited

Use the next available virtual zone of the dialog progress bar and updates the message.

Implements PROGRESS_REPORTER.

Reimplemented in DIALOG_DRC, DIALOG_DRC_RULE_EDITOR, and DIALOG_ERC.

Definition at line 53 of file progress_reporter_base.cpp.

References AdvancePhase(), and Report().

◆ AdvanceProgress()

void PROGRESS_REPORTER_BASE::AdvanceProgress ( )
overridevirtualinherited

Increment the progress bar length (inside the current virtual zone).

Implements PROGRESS_REPORTER.

Definition at line 82 of file progress_reporter_base.cpp.

References m_progress.

◆ BeginPhase()

void PROGRESS_REPORTER_BASE::BeginPhase ( int aPhase)
overridevirtualinherited

Initialize the aPhase virtual zone of the dialog progress bar.

Implements PROGRESS_REPORTER.

Definition at line 39 of file progress_reporter_base.cpp.

References m_phase, and m_progress.

◆ CurrentProgress()

int PROGRESS_REPORTER_BASE::CurrentProgress ( ) const
inherited

◆ IsCancelled()

bool PROGRESS_REPORTER_BASE::IsCancelled ( ) const
inlineoverridevirtualinherited

Implements PROGRESS_REPORTER.

Definition at line 104 of file progress_reporter_base.h.

References m_cancelled.

◆ KeepRefreshing()

bool PROGRESS_REPORTER_BASE::KeepRefreshing ( bool aWait = false)
overridevirtualinherited

Update the UI dialog.

Warning
This should only be called from the main thread.
Returns
false if the user clicked Cancel.

Implements PROGRESS_REPORTER.

Definition at line 109 of file progress_reporter_base.cpp.

References m_cancelled, m_maxProgress, m_progress, and updateUI().

Referenced by SCH_EDIT_FRAME::importFile(), PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ Report()

void PROGRESS_REPORTER_BASE::Report ( const wxString & aMessage)
overridevirtualinherited

Display aMessage in the progress bar dialog.

Implements PROGRESS_REPORTER.

Reimplemented in BACKGROUND_JOB_REPORTER, DIALOG_ERC, and JOBS_PROGRESS_REPORTER.

Definition at line 60 of file progress_reporter_base.cpp.

References m_messageChanged, m_mutex, and m_rptMessage.

Referenced by AdvancePhase(), SCH_EDIT_FRAME::importFile(), and SCH_EDIT_FRAME::OpenProjectFiles().

◆ SetCurrentProgress()

void PROGRESS_REPORTER_BASE::SetCurrentProgress ( double aProgress)
overridevirtualinherited

◆ SetIndeterminate()

virtual void PROGRESS_REPORTER::SetIndeterminate ( bool aIndeterminate)
inlinevirtualinherited

Ask for an indeterminate (pulsing) display, for work whose total is not known yet.

Safe to call from a worker thread. Implementations record the request and apply it on the next UI refresh.

Reimplemented in WX_PROGRESS_REPORTER.

Definition at line 79 of file progress_reporter.h.

◆ SetMaxProgress()

void PROGRESS_REPORTER_BASE::SetMaxProgress ( int aMaxProgress)
overridevirtualinherited

Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).

Implements PROGRESS_REPORTER.

Definition at line 69 of file progress_reporter_base.cpp.

References m_maxProgress.

◆ SetNumPhases()

void PROGRESS_REPORTER_BASE::SetNumPhases ( int aNumPhases)
overridevirtualinherited

Set the number of phases.

Implements PROGRESS_REPORTER.

Definition at line 88 of file progress_reporter_base.cpp.

References m_numPhases.

Referenced by DIALOG_PCM_PROGRESS::OnCancelClicked(), and BACKGROUND_JOB_REPORTER::SetNumPhases().

◆ SetTitle()

void PROGRESS_REPORTER_BASE::SetTitle ( const wxString & aTitle)
inlineoverridevirtualinherited

Change the title displayed on the window caption.

Has meaning only for some reporters. Does nothing for others.

Warning
This should only be called from the main thread.

Implements PROGRESS_REPORTER.

Reimplemented in WX_PROGRESS_REPORTER.

Definition at line 102 of file progress_reporter_base.h.

◆ updateUI()

bool KIGIT_STATUS_REPORTER::updateUI ( )
overrideprotectedvirtual

Member Data Documentation

◆ m_alive

std::weak_ptr<bool> KIGIT_STATUS_REPORTER::m_alive
private

Definition at line 87 of file git_transfer.h.

Referenced by KIGIT_STATUS_REPORTER(), and updateUI().

◆ m_cancelled

◆ m_lastShown

wxString KIGIT_STATUS_REPORTER::m_lastShown
private

Definition at line 89 of file git_transfer.h.

Referenced by updateUI().

◆ m_maxProgress

◆ m_messageChanged

std::atomic_bool PROGRESS_REPORTER_BASE::m_messageChanged
protectedinherited

◆ m_mutex

std::mutex PROGRESS_REPORTER_BASE::m_mutex
mutableprotectedinherited

◆ m_numPhases

std::atomic_int PROGRESS_REPORTER_BASE::m_numPhases
protectedinherited

◆ m_phase

◆ m_progress

◆ m_rptMessage

wxString PROGRESS_REPORTER_BASE::m_rptMessage
protectedinherited

◆ m_show

std::function<void( const wxString& )> KIGIT_STATUS_REPORTER::m_show
private

Definition at line 88 of file git_transfer.h.

Referenced by KIGIT_STATUS_REPORTER(), and updateUI().


The documentation for this class was generated from the following files: