Skip to content
This repository
Browse code

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 authored May 10, 2013
1  xbmc/Application.cpp
@@ -648,7 +648,6 @@ bool CApplication::Create()
648 648
   init_emu_environ();
649 649
 
650 650
   CProfilesManager::Get().Load();
651  
-  CSpecialProtocol::SetProfilePath(CProfilesManager::Get().GetProfileUserDataFolder());
652 651
 
653 652
   CLog::Log(LOGNOTICE, "-----------------------------------------------------------------------");
654 653
 #if defined(TARGET_DARWIN_OSX)
19  xbmc/profiles/ProfilesManager.cpp
@@ -177,18 +177,18 @@ bool CProfilesManager::Load(const std::string &file)
177 177
   if (m_lastUsedProfile >= m_profiles.size())
178 178
     m_lastUsedProfile = 0;
179 179
 
180  
-  m_currentProfile = m_lastUsedProfile;
  180
+  SetCurrentProfileId(m_lastUsedProfile);
181 181
 
182 182
   // check the validity of the auto login profile index
183 183
   if (m_autoLoginProfile < -1 || m_autoLoginProfile >= (int)m_profiles.size())
184 184
     m_autoLoginProfile = -1;
185 185
   else if (m_autoLoginProfile >= 0)
186  
-    m_currentProfile = m_autoLoginProfile;
  186
+    SetCurrentProfileId(m_autoLoginProfile);
187 187
 
188 188
   // the login screen runs as the master profile, so if we're using this, we need to ensure
189 189
   // we switch to the master profile
190 190
   if (m_usingLoginScreen)
191  
-    m_currentProfile = 0;
  191
+    SetCurrentProfileId(0);
192 192
 
193 193
   return ret;
194 194
 }
@@ -226,8 +226,8 @@ void CProfilesManager::Clear()
226 226
   m_profiles.clear();
227 227
   m_usingLoginScreen = false;
228 228
   m_lastUsedProfile = 0;
229  
-  m_currentProfile = 0;
230 229
   m_nextProfileId = 0;
  230
+  SetCurrentProfileId(0);
231 231
 }
232 232
 
233 233
 bool CProfilesManager::LoadProfile(size_t index)
@@ -244,9 +244,7 @@ bool CProfilesManager::LoadProfile(size_t index)
244 244
   // unload any old settings
245 245
   CSettings::Get().Unload();
246 246
 
247  
-  m_currentProfile = index;
248  
-  // point special://profile to the correct profile path
249  
-  CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
  247
+  SetCurrentProfileId(index);
250 248
 
251 249
   // load the new settings
252 250
   if (!CSettings::Get().Load())
@@ -534,3 +532,10 @@ std::string CProfilesManager::GetUserDataItem(const std::string& strFile) const
534 532
 
535 533
   return path;
536 534
 }
  535
+
  536
+void CProfilesManager::SetCurrentProfileId(size_t profileId)
  537
+{
  538
+  CSingleLock lock(m_critical);
  539
+  m_currentProfile = profileId;
  540
+  CSpecialProtocol::SetProfilePath(GetProfileUserDataFolder());
  541
+}
7  xbmc/profiles/ProfilesManager.h
@@ -183,11 +183,16 @@ class CProfilesManager : public ISettingsHandler
183 183
   virtual ~CProfilesManager();
184 184
 
185 185
 private:
  186
+  /*! \brief Set the current profile id and update the special://profile path
  187
+    \param profileId profile index
  188
+    */
  189
+  void SetCurrentProfileId(size_t profileId);
  190
+
186 191
   std::vector<CProfile> m_profiles;
187 192
   bool m_usingLoginScreen;
188 193
   int m_autoLoginProfile;
189 194
   uint32_t m_lastUsedProfile;
190  
-  uint32_t m_currentProfile;
  195
+  uint32_t m_currentProfile; // do not modify directly, use SetCurrentProfileId() function instead
191 196
   int m_nextProfileId; // for tracking the next available id to give to a new profile to ensure id's are not re-used
192 197
   CCriticalSection m_critical;
193 198
 };

0 notes on commit 570362f

Please sign in to comment.
Something went wrong with that request. Please try again.