MediaPortal 2 development snapshot (2014-12-19) (1 Viewer)

osre

Retired Team Member
  • Premium Supporter
  • December 14, 2014
    775
    387
    Home Country
    Germany Germany
    It would be very strange if this side effect is caused by the ServerSettings.xml file - maybe if you have done your patch in a way so that all settings files are written to disk (not only ServerSettings.xml) but even in this case, the behavior described would be a bug...
    I made my change at a central point, but I think I did not fully take into account, that there is not a global and a user file for all setting classes.
    My change looks like this:
    \MediaPortal\Source\Core\MediaPortal.Common\Services\Settings\SettingsManager.cs:101
    Code:
        protected object LoadSettingsObject(Type settingsType)
        {
          SettingsFileHandler globalHandler = new SettingsFileHandler(GetGlobalFilePath(settingsType));
          SettingsFileHandler userHandler = new SettingsFileHandler(GetUserFilePath(settingsType));
          try
          {
            globalHandler.Load();
          }
          catch (Exception e)
          {
            ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading global settings file for setting type '{0}'... Will clear this settings file.", e, settingsType.Name);
            globalHandler.Clear();
            RemoveSettingsData(settingsType, false, true);
          }
          try
          {
            userHandler.Load();
          }
          catch (Exception e)
          {
            ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading user settings file for setting type '{0}'... Will clear this settings file.", e, settingsType.Name);
            userHandler.Clear();
            RemoveSettingsData(settingsType, true, false);
          }
          try
          {
            object result = Activator.CreateInstance(settingsType);
            foreach (PropertyInfo property in result.GetType().GetProperties())
            {
              SettingAttribute att = GetSettingAttribute(property);
              if (att == null) continue;
              SettingsFileHandler s = (att.SettingScope == SettingScope.Global ? globalHandler : userHandler);
              try
              {
                object value = s.GetValue(property.Name, property.PropertyType);
                if (value == null)
                  if (att.HasDefault)
                    value = att.DefaultValue;
                  else
                    continue;
                property.SetValue(result, value, null);
              }
              catch (Exception e)
              {
                ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error setting property '{0}' in settings of type '{1}'" +
                    (att.HasDefault ? ", using default value" : string.Empty), e, property.Name, settingsType.Name);
                if (att.HasDefault)
                  property.SetValue(result, att.DefaultValue, null);
              }
            }
            /* my modification, but I guess '||' should be replaced by an '&&'
            if (!File.Exists(globalHandler.FilePath) || !File.Exists(userHandler.FilePath))
            {
              SaveSettingsObject(result);
            }*/
            return result;
          }
          catch (Exception e)
          {
            ServiceRegistration.Get<ILogger>().Error("SettingsManager: Error loading settings of type '{0}'", e, settingsType.Name);
            return null;
          }
        }
    About the no sound issue: may be I hit some keyboard short cut.
     

    Users who are viewing this thread

    Top Bottom