From 84b900ca909d342ac193f2b6b4c058b1b432b5f9 Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Thu, 15 Aug 2019 16:56:44 -0400 Subject: [PATCH] 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. --- oscar/SleepLib/profiles.cpp | 8 ++++---- oscar/SleepLib/profiles.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/oscar/SleepLib/profiles.cpp b/oscar/SleepLib/profiles.cpp index 7e16a07a..8ae04efa 100644 --- a/oscar/SleepLib/profiles.cpp +++ b/oscar/SleepLib/profiles.cpp @@ -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; } diff --git a/oscar/SleepLib/profiles.h b/oscar/SleepLib/profiles.h index 0a3d892d..706dd766 100644 --- a/oscar/SleepLib/profiles.h +++ b/oscar/SleepLib/profiles.h @@ -237,7 +237,6 @@ class Profile : public Preferences QDate m_last; bool m_opened; - bool m_machopened; QHash > MachineList;