Skip to content

Commit 9e865e0

Browse files
committed
1.7.4
[Bug fixes] - Crash after rename profile and select another one #34
1 parent 412b24c commit 9e865e0

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

Source/HDRProfile/AutoHDRDaemon.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -407,20 +407,26 @@ private void MoveAssignmentUp(ApplicationProfileAssignment assignment)
407407

408408
private void AddProfile()
409409
{
410-
int count = 0;
411-
string profileName = string.Empty;
412-
while (string.IsNullOrEmpty(profileName) || Settings.ApplicationProfiles.Any(p => p.Name.ToUpperInvariant().Equals(profileName.ToUpperInvariant())))
410+
lock (_accessLock)
413411
{
414-
count++;
415-
profileName = $"{ProjectResources.Locale_Texts.Profile} {count}";
412+
int count = 0;
413+
string profileName = string.Empty;
414+
while (string.IsNullOrEmpty(profileName) || Settings.ApplicationProfiles.Any(p => p.Name.ToUpperInvariant().Equals(profileName.ToUpperInvariant())))
415+
{
416+
count++;
417+
profileName = $"{ProjectResources.Locale_Texts.Profile} {count}";
418+
}
419+
Settings.ApplicationProfiles.Add(new Profile() { Name = profileName });
416420
}
417-
Settings.ApplicationProfiles.Add(new Profile() { Name = profileName });
418421
}
419422

420423

421424
private void RemoveProfile(Profile profile)
422425
{
423-
Settings.ApplicationProfiles.Remove(profile);
426+
lock (_accessLock)
427+
{
428+
Settings.ApplicationProfiles.Remove(profile);
429+
}
424430
}
425431

426432
#endregion Process handling

Source/HDRProfile/Profiles/Profile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void RemoveProfileAction(ProfileActionListType listType, ProfileActionBas
178178

179179
public override string ToString()
180180
{
181-
return Name;
181+
return $"{Name} {GetHashCode()}";
182182
}
183183

184184
public override bool Equals(object obj)
@@ -189,7 +189,7 @@ public override bool Equals(object obj)
189189
public bool Equals(Profile other)
190190
{
191191
return other != null &&
192-
Name == other.Name &&
192+
GUID == other._guid &&
193193
EqualityComparer<ListOfProfileActions>.Default.Equals(ApplicationStarted, other.ApplicationStarted) &&
194194
EqualityComparer<ListOfProfileActions>.Default.Equals(ApplicationClosed, other.ApplicationClosed) &&
195195
EqualityComparer<ListOfProfileActions>.Default.Equals(ApplicationGotFocus, other.ApplicationGotFocus) &&
@@ -199,7 +199,7 @@ public bool Equals(Profile other)
199199
public override int GetHashCode()
200200
{
201201
int hashCode = 210938521;
202-
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
202+
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(GUID.ToString());
203203
hashCode = hashCode * -1521134295 + EqualityComparer<ListOfProfileActions>.Default.GetHashCode(ApplicationStarted);
204204
hashCode = hashCode * -1521134295 + EqualityComparer<ListOfProfileActions>.Default.GetHashCode(ApplicationClosed);
205205
hashCode = hashCode * -1521134295 + EqualityComparer<ListOfProfileActions>.Default.GetHashCode(ApplicationGotFocus);

Source/HDRProfile/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
5353
// indem Sie "*" wie unten gezeigt eingeben:
5454
// [assembly: AssemblyVersion("1.0.*")]
55-
[assembly: AssemblyVersion("1.7.3.0")]
56-
[assembly: AssemblyFileVersion("1.7.3.0")]
55+
[assembly: AssemblyVersion("1.7.4.0")]
56+
[assembly: AssemblyFileVersion("1.7.4.0")]

Source/HDRProfile/Views/ProfileManagerView.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<Border Style="{StaticResource RoundedBorder}" BorderBrush="{DynamicResource AccentBrush}" BorderThickness="1" Margin="10,10,10,10" Grid.Row="0">
2626
<Grid>
27-
<TextBlock Text="{Binding Name}" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" FontWeight="DemiBold"/>
27+
<TextBlock Text="{Binding Name, Mode=OneWay}" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" FontWeight="DemiBold"/>
2828
</Grid>
2929
</Border>
3030
</DataTemplate>
@@ -74,12 +74,12 @@
7474
<TextBlock Grid.Column="0" Grid.Row="0" Text="{x:Static pres:Locale_Texts.Profiles}" Margin="10,10,10,10" FontWeight="Bold" FontSize="18"></TextBlock>
7575
<TextBlock Grid.Column="1" Grid.Row="0" Text="{x:Static pres:Locale_Texts.CurrentProfile}" Margin="10,10,10,10" FontWeight="Bold" FontSize="18"></TextBlock>
7676
<Border Grid.Column="0" Grid.Row="1" Style="{StaticResource RoundedBorder}" BorderBrush="{DynamicResource AccentBrush}" BorderThickness="1" Margin="10,10,10,10">
77-
<ListBox x:Name="ProfileList" HorizontalContentAlignment="Stretch" ItemTemplate="{StaticResource ProfileItemTemplate}" ItemsSource="{Binding Settings.ApplicationProfiles}" ScrollViewer.VerticalScrollBarVisibility="Auto" Background="{x:Null}" BorderThickness="0"/>
77+
<ListBox x:Name="ProfileList" HorizontalContentAlignment="Stretch" ItemTemplate="{StaticResource ProfileItemTemplate}" ItemsSource="{Binding Settings.ApplicationProfiles}" ScrollViewer.VerticalScrollBarVisibility="Auto" Background="{x:Null}" BorderThickness="0" SelectionMode="Single"/>
7878
</Border>
7979
<Border Grid.Column="1" Grid.Row="1" Style="{StaticResource RoundedBorder}" BorderBrush="{DynamicResource AccentBrush}" BorderThickness="1" Margin="10,10,10,10">
8080
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
8181
<!--<Grid Margin="5" DataContext="{Binding ElementName=ProfileList, Path=SelectedItem}">-->
82-
<Grid Margin="5" DataContext="{Binding ElementName=ProfileList, Path=SelectedItem}" Visibility="{Binding ElementName=ProfileList, Path=SelectedItem, Converter={StaticResource NotNullVisibilityConverter}}" >
82+
<Grid Margin="5" DataContext="{Binding ElementName=ProfileList, Path=SelectedItem, Mode=OneWay}" Visibility="{Binding ElementName=ProfileList, Path=SelectedItem,Mode=OneWay, Converter={StaticResource NotNullVisibilityConverter}}" >
8383

8484
<Grid.ColumnDefinitions>
8585
<ColumnDefinition Width="Auto"/>
@@ -104,7 +104,7 @@
104104
<TextBlock Grid.Column="0" Grid.Row="4" Text="{x:Static pres:Locale_Texts.AppClosedActions}" FontWeight="DemiBold" FontSize="15" Margin="5"></TextBlock>
105105
<TextBlock Grid.Column="0" Grid.Row="5" Text="{x:Static pres:Locale_Texts.AppFocusedActions}" FontWeight="DemiBold" FontSize="15" Margin="5"></TextBlock>
106106
<TextBlock Grid.Column="0" Grid.Row="6" Text="{x:Static pres:Locale_Texts.AppLostFocusActions}" FontWeight="DemiBold" FontSize="15" Margin="5"></TextBlock>
107-
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Name, Mode=TwoWay}" Margin="10,5" FontSize="15" FontWeight="DemiBold" ></TextBox>
107+
<TextBox x:Name="NameTextBox" Grid.Column="1" Grid.Row="0" Text="{Binding Name, Mode=TwoWay}" Margin="10,5" FontSize="15" FontWeight="DemiBold"></TextBox>
108108
<CheckBox Grid.Column="1" Grid.Row="1" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" IsChecked="{Binding RestartApplication, Mode=TwoWay}" VerticalAlignment="Center" Margin="10,0,0,0" HorizontalAlignment="Left" />
109109

110110
<Border Grid.Column="1" Grid.Row="3" Style="{StaticResource RoundedBorder}" BorderBrush="{DynamicResource AccentBrush}" BorderThickness="1" Margin="10,10,10,10">

Source/HDRProfile/Views/ProfileManagerView.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ public ProfileManagerView()
1212
{
1313
InitializeComponent();
1414
}
15-
1615
}
1716
}

0 commit comments

Comments
 (0)