Skip to content

Commit 845ea2a

Browse files
committed
Added a delay before switching skin/theme after user profile change. This was done to avoid skin switching during profile change which caused exceptions and crashes
1 parent cfe7d6d commit 845ea2a

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

MediaPortal/Source/UI/SkinEngine/SkinEnginePlugin.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
2323
#endregion
2424

2525
using System;
26+
using System.Threading;
2627
using MediaPortal.UI.Control.InputManager;
2728
using MediaPortal.Common;
2829
using MediaPortal.Common.Logging;
@@ -214,6 +215,8 @@ private void UserChanged(object sender, EventArgs e)
214215
var skinSettings = ServiceRegistration.Get<ISettingsManager>().Load<SkinSettings>();
215216
if (screenManager.SkinName != skinSettings.Skin || screenManager.ThemeName != skinSettings.Theme)
216217
{
218+
// Wait a while to allow all other parts to react on user context changes
219+
Thread.Sleep(500);
217220
IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
218221
// Exclusively lock WF manager while changing skin, otherwise it will fail when models try to get lock.
219222
if (!workflowManager.Lock.TryEnterWriteLock(2000))

MediaPortal/Source/UI/SkinEngine/SkinManagement/SkinResources.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
2323
#endregion
2424

2525
using System;
26+
using System.Collections.Concurrent;
2627
using System.Collections.Generic;
2728
using System.Linq;
2829
using System.Text.RegularExpressions;
@@ -162,7 +163,7 @@ public object GetOrLoadModel(Guid modelId)
162163
/// <summary>
163164
/// Models currently loaded for the style.
164165
/// </summary>
165-
protected IDictionary<Guid, object> _styleGUIModels = new Dictionary<Guid, object>();
166+
protected IDictionary<Guid, object> _styleGUIModels = new ConcurrentDictionary<Guid, object>();
166167

167168
#endregion
168169

0 commit comments

Comments
 (0)