Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When ProfilesManager::m_currentProfile is changed the special://profi…

…le path must be updated as well.

Added SetCurrentProfileId() function for manipulating m_currentProfile. Replaced all occurances of direct manipulation by using this function. This makes sure that the special://profile path is updated as well when updating the current profile id.
Since SetCurrentProfileId() is called in ProfilesManager::Load(), the special://profile path is now automatically set which made it obsolete in CApplication::Create().
  • Loading branch information...
commit 570362fc977cc2b9f6f92939215d1d6f2b24479b 1 parent 12bdefb
@leechguy leechguy authored
View
1  xbmc/Application.cpp
@@ -648,7 +648,6 @@ bool CApplication::Create()
init_emu_environ();
CProfilesManager::Get().Load();
- CSpecialProtocol::SetProfilePath(CProfilesManager::Get().GetProfileUserDataFolder());
CLog::Log(LOGNOTICE, "-----------------------------------------------------------------------");
#if defined(TARGET_DARWIN_OSX)
View
19 xbmc/profiles/ProfilesManager.cpp
@@ -177,18 +177,18 @@ bool CProfilesManager::Load(const std::string &file)
if (m_lastUsedProfile >= m_profiles.size())
m_lastUsedProfile = 0;
- m_currentProfile = m_lastUsedProfile;
+ SetCurrentProfileId(m_lastUsedProfile);
// check the validity of the auto login profile index
if (m_autoLoginProfile < -1 || m_autoLoginProfile >= (int)m_profiles.size())
m_autoLoginProfile = -1;
else if (m_autoLoginProfile >= 0)
- m_currentProfile = m_autoLoginProfile;
+ SetCurrentProfileId(m_autoLoginProfile);
// the login screen runs as the master profile, so if we're using this, we need to ensure
// we switch to the master profile
if (m_usingLoginScreen)
- m_currentProfile = 0;
+ SetCurrentProfileId(0);
return ret;
}
@@ -226,8 +226,8 @@ void CProfilesManager::Clear()
m_profiles.clear();
m_usingLoginScreen = false;
m_lastUsedProfile = 0;
- m_currentProfile = 0;
m_nextProfileId = 0;
+ SetCurrentProfileId(0);
}
bool CProfilesManager::LoadProfile(size_t index)
@@ -244,9 +244,7 @@ bool CProfilesManager::LoadProfile(size_t index)
// unload any old settings
CSettings::Get().Unload();
- m_currentProfile = index;
- // point special://profile to the correct profile path
- CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
+ SetCurrentProfileId(index);
// load the new settings
if (!CSettings::Get().Load())
@@ -534,3 +532,10 @@ std::string CProfilesManager::GetUserDataItem(const std::string& strFile) const
return path;
}
+
+void CProfilesManager::SetCurrentProfileId(size_t profileId)
+{
+ CSingleLock lock(m_critical);
+ m_currentProfile = profileId;
+ CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
+}
View
7 xbmc/profiles/ProfilesManager.h
@@ -183,11 +183,16 @@ class CProfilesManager : public ISettingsHandler
virtual ~CProfilesManager();
private:
+ /*! \brief Set the current profile id and update the special://profile path
+ \param profileId profile index
+ */
+ void SetCurrentProfileId(size_t profileId);
+
std::vector<CProfile> m_profiles;
bool m_usingLoginScreen;
int m_autoLoginProfile;
uint32_t m_lastUsedProfile;
- uint32_t m_currentProfile;
+ uint32_t m_currentProfile; // do not modify directly, use SetCurrentProfileId() function instead
int m_nextProfileId; // for tracking the next available id to give to a new profile to ensure id's are not re-used
CCriticalSection m_critical;
};
Please sign in to comment.
Something went wrong with that request. Please try again.