set object before using it (#6497)

This commit is contained in:
Alekhya
2020-09-10 09:44:10 -07:00
committed by GitHub
parent f589103f5d
commit efd5c33a92

View File

@@ -22,14 +22,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public PowerLauncherViewModel(Func<string, int> ipcMSGCallBackFunc, int defaultKeyCode) public PowerLauncherViewModel(Func<string, int> ipcMSGCallBackFunc, int defaultKeyCode)
{ {
try // set the callback functions value to hangle outgoing IPC message.
{ SendConfigMSG = ipcMSGCallBackFunc;
callback = (PowerLauncherSettings settings) => callback = (PowerLauncherSettings settings) =>
{ {
// Propagate changes to Power Launcher through IPC // Propagate changes to Power Launcher through IPC
SendConfigMSG( SendConfigMSG(
string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings))); string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings)));
}; };
if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName)) if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName))
{ {
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName); settings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
@@ -51,13 +53,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
generalSettings = new GeneralSettings(); generalSettings = new GeneralSettings();
} }
// set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
}
catch
{
}
} }
public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback) public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback)