Skip to content

Commit

Permalink
Remove temporary aliases when calling resetProfile() (Mudlet#3233)
Browse files Browse the repository at this point in the history
* Remove temporary aliases when calling resetProfile()

* Ensure aliases are disabled, cleaned up and then enabled when resetting profile
  • Loading branch information
aaronjoslyn authored and vadi2 committed Nov 17, 2019
1 parent 64ee0ed commit 1e836fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/AliasUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ void AliasUnit::removeAliasRootNode(TAlias* pT)
mAliasRootNodeList.remove(pT);
}

void AliasUnit::removeAllTempAliases()
{
for (auto alias : mAliasRootNodeList) {
if (alias->isTemporary()) {
alias->setIsActive(false);
markCleanup(alias);
}
}
}

TAlias* AliasUnit::getAlias(int id)
{
QMutexLocker locker(&mAliasUnitLock);
Expand Down
1 change: 1 addition & 0 deletions src/AliasUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AliasUnit
bool enableAlias(const QString&);
bool disableAlias(const QString&);
bool killAlias(const QString& name);
void removeAllTempAliases();
bool registerAlias(TAlias* pT);
void unregisterAlias(TAlias* pT);
void uninstall(const QString&);
Expand Down
4 changes: 4 additions & 0 deletions src/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ void Host::reloadModule(const QString& reloadModuleName)

void Host::resetProfile_phase1()
{
mAliasUnit.stopAllTriggers();
mTriggerUnit.stopAllTriggers();
mTimerUnit.stopAllTriggers();
mKeyUnit.stopAllTriggers();
Expand All @@ -399,10 +400,12 @@ void Host::resetProfile_phase1()

void Host::resetProfile_phase2()
{
getAliasUnit()->removeAllTempAliases();
getTimerUnit()->removeAllTempTimers();
getTriggerUnit()->removeAllTempTriggers();
getKeyUnit()->removeAllTempKeys();

mAliasUnit.doCleanup();
mTimerUnit.doCleanup();
mTriggerUnit.doCleanup();
mKeyUnit.doCleanup();
Expand All @@ -421,6 +424,7 @@ void Host::resetProfile_phase2()
// All the Timers are NOT compiled here;
mResetProfile = false;

mAliasUnit.reenableAllTriggers();
mTimerUnit.reenableAllTriggers();
mTriggerUnit.reenableAllTriggers();
mKeyUnit.reenableAllTriggers();
Expand Down

0 comments on commit 1e836fa

Please sign in to comment.