Skip to content

Commit

Permalink
Protect against trying to deactivate busy spinner when not busy (fix …
Browse files Browse the repository at this point in the history
…asserts in macOS non-GL)
  • Loading branch information
nohal committed Jun 4, 2024
1 parent 13ac1bc commit 0f81b3d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
18 changes: 2 additions & 16 deletions gui/src/OCPNPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1681,25 +1681,11 @@ bool OCPNPlatform::hasInternalGPS(wxString profile) {
//--------------------------------------------------------------------------

void OCPNPlatform::ShowBusySpinner(void) {
#ifdef __ANDROID__
androidShowBusyIcon();
#else
#if wxCHECK_VERSION(2, 9, 0)
// if( !::wxIsBusy() )
{ ::wxBeginBusyCursor(); }
#endif
#endif
AbstractPlatform::ShowBusySpinner();
}

void OCPNPlatform::HideBusySpinner(void) {
#ifdef __ANDROID__
androidHideBusyIcon();
#else
#if wxCHECK_VERSION(2, 9, 0)
// if( ::wxIsBusy() )
{ ::wxEndBusyCursor(); }
#endif
#endif
AbstractPlatform::ShowBusySpinner();
}

double OCPNPlatform::GetDisplayDensityFactor() {
Expand Down
1 change: 1 addition & 0 deletions model/include/model/base_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class AbstractPlatform {
#endif
int m_monitorWidth, m_monitorHeight;
bool m_bdisableWindowsDisplayEnum;
static bool m_isBusy;
};

class BasePlatform : public AbstractPlatform {
Expand Down
31 changes: 26 additions & 5 deletions model/src/base_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ static const char PATH_SEP = ';';
static const char PATH_SEP = ':';
#endif

bool AbstractPlatform::m_isBusy = false;

static const char* const DEFAULT_XDG_DATA_DIRS =
"~/.local/share:/usr/local/share:/usr/share";

Expand Down Expand Up @@ -744,17 +746,36 @@ wxString AbstractPlatform::GetPluginDataPath() {
return m_pluginDataPath;
}


#ifdef __ANDROID__
void AbstractPlatform::ShowBusySpinner() { androidShowBusyIcon(); }
void AbstractPlatform::ShowBusySpinner() {
if (!m_isBusy) {
androidShowBusyIcon();
m_isBusy = true;
}
}
#else
void AbstractPlatform::ShowBusySpinner() { ::wxBeginBusyCursor(); }
void AbstractPlatform::ShowBusySpinner() {
if (!m_isBusy) {
::wxBeginBusyCursor();
m_isBusy = true;
}
}
#endif

#ifdef __ANDROID__
void AbstractPlatform::HideBusySpinner() { androidHideBusyIcon(); }
void AbstractPlatform::HideBusySpinner() {
if (m_isBusy) {
androidHideBusyIcon();
m_isBusy = false;
}
}
#else
void AbstractPlatform::HideBusySpinner() { ::wxEndBusyCursor(); }
void AbstractPlatform::HideBusySpinner() {
if (m_isBusy) {
::wxEndBusyCursor();
m_isBusy = false;
}
}
#endif

// getDisplaySize
Expand Down

0 comments on commit 0f81b3d

Please sign in to comment.