Remove the m_machopened flag from Profile, which caused newly created profiles

to act differently from profiles after a subsequent application launch.

It was only getting set at the end of Profile::OpenMachines, which was only
called by the Profile constructor, and which wouldn't succeed on a newly created
profile, having no files to open. Therefore, the only way for the flag to be set
was to quit and re-launch the application after creating the profile.

The flag's only remaining use was to make sure that OpenMachines() wasn't
getting called twice and trampling an existing list of machines, so the check
there was changed from looking at a brittle flag to looking at the actual list
of machines.

A critical warning was also added to the check, since OpenMachines() is
only getting called from the Profile constructor and therefore can't
be invoked twice unless a new bug has been introduced.
This commit is contained in:
sawinglogz 2019-08-15 16:56:44 -04:00
parent e3e67438ea
commit 84b900ca90
2 changed files with 4 additions and 5 deletions

View File

@ -37,8 +37,7 @@ Profile *p_profile;
Profile::Profile(QString path)
: is_first_day(true),
m_opened(false),
m_machopened(false)
m_opened(false)
{
p_name = STR_GEN_Profile;
@ -146,8 +145,10 @@ void Profile::addLock()
bool Profile::OpenMachines()
{
if (m_machopened)
if (m_machlist.size() > 0) {
qCritical() << "Skipping redundant call to Profile::OpenMachines";
return true;
}
QString filename = p_path+"machines.xml";
QFile file(filename);
@ -239,7 +240,6 @@ bool Profile::OpenMachines()
elem = elem.nextSiblingElement();
}
m_machopened = true;
return true;
}

View File

@ -237,7 +237,6 @@ class Profile : public Preferences
QDate m_last;
bool m_opened;
bool m_machopened;
QHash<QString, QHash<QString, Machine *> > MachineList;