Skip to content

Commit

Permalink
Fix: crash when a profile with errors is set to autostart (Mudlet#7369)
Browse files Browse the repository at this point in the history
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Fix crash when a profile with errors is set to autostart
#### Motivation for adding to Mudlet
Bugfix
#### Other info (issues closed, discussion etc)
The error announcer was falsely reporting errors to the accessibility
framework at launch (it's too early to be reporting the errors), and the
Mudlet singleton wasn't ready yet which was causing the crash.

Originally reported in
https://discord.com/channels/283581582550237184/283582068334526464/1267086280932593704
  • Loading branch information
vadi2 authored Aug 8, 2024
1 parent 72f5191 commit 10fedaf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
11 changes: 0 additions & 11 deletions src/TAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,6 @@ void TAction::expandToolbar(TToolBar* pT)
// This applies the CSS for THIS TAction to a CHILD's representation on the Toolbar
button->setStyleSheet(css);

/*
* CHECK: The other expandToolbar(...) has the following in this position:
* //FIXME: Heiko April 2012: only run checkbox button scripts, but run them even if unchecked
* if( action->mIsPushDownButton && mpHost->mIsProfileLoadingSequence )
* {
* qDebug()<<"expandToolBar() name="<<action->mName<<" executing script";
* action->execute();
* }
* Why does it have this and we do not? - Slysven
*/

if (action->isFolder()) {
auto newMenu = new QMenu(pT);
// This applies the CSS for THIS TAction to a CHILD's own menu - is this right
Expand Down
12 changes: 9 additions & 3 deletions src/dlgTriggerEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7910,7 +7910,9 @@ void dlgTriggerEditor::showError(const QString& error)
mpSystemMessageArea->notificationAreaIconLabelWarning->hide();
mpSystemMessageArea->notificationAreaMessageBox->setText(error);
mpSystemMessageArea->show();
mudlet::self()->announce(error);
if (!mpHost->mIsProfileLoadingSequence) {
mudlet::self()->announce(error);
}
}

void dlgTriggerEditor::showInfo(const QString& error)
Expand All @@ -7920,7 +7922,9 @@ void dlgTriggerEditor::showInfo(const QString& error)
mpSystemMessageArea->notificationAreaIconLabelInformation->show();
mpSystemMessageArea->notificationAreaMessageBox->setText(error);
mpSystemMessageArea->show();
mudlet::self()->announce(error);
if (!mpHost->mIsProfileLoadingSequence) {
mudlet::self()->announce(error);
}
}

void dlgTriggerEditor::showWarning(const QString& error)
Expand All @@ -7930,7 +7934,9 @@ void dlgTriggerEditor::showWarning(const QString& error)
mpSystemMessageArea->notificationAreaIconLabelWarning->show();
mpSystemMessageArea->notificationAreaMessageBox->setText(error);
mpSystemMessageArea->show();
mudlet::self()->announce(error);
if (!mpHost->mIsProfileLoadingSequence) {
mudlet::self()->announce(error);
}
}

void dlgTriggerEditor::slot_showActions()
Expand Down
5 changes: 4 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ int main(int argc, char* argv[])
}
mudlet::self()->show();

mudlet::self()->startAutoLogin(cliProfiles);
QTimer::singleShot(0, qApp, [cliProfiles]() {
// ensure Mudlet singleton is initialised before calling profile loading
mudlet::self()->startAutoLogin(cliProfiles);
});

#if defined(INCLUDE_UPDATER)
mudlet::self()->checkUpdatesOnStart();
Expand Down
1 change: 0 additions & 1 deletion src/mudlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,6 @@ void mudlet::deleteProfileData(const QString& profile, const QString& item)
}
}

// this slot is called via a timer in the constructor of mudlet::mudlet()
void mudlet::startAutoLogin(const QStringList& cliProfiles)
{
QStringList hostList = QDir(getMudletPath(profilesPath)).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
Expand Down

0 comments on commit 10fedaf

Please sign in to comment.