This is a migrated thread and some comments may be shown as answers.

Bug: StackOverflowException

1 Answer 194 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Andrew Anderson
Top achievements
Rank 1
Andrew Anderson asked on 15 Mar 2010, 04:09 PM
I ran into a bug with the RadSlider that tripped me up for a few hours.  There's an easy workaround, but I figured that this is the sort of thing that you'd want to know about so you could fix it.

Synopsis:
When a RadSlider is databound to an object, if the value that is bound to the Minimum property is set prior to setting the object that is bound to the Maximum value then your application will terminate with a StackOverflowException.

What ends up happening, (as far as I can tell), is that internally the API sees that Minimum has been set to X and so reacts by setting SelectionStart = Minimum.  The API then notices that SelectionStart > SelectionEnd and so sets SelectionStart to 0.  This cycle repeats until the stack is blown:  Selection start goes back to X, then 0, then X, then 0, then.....

Reproduction case:
I created a simple little WPF app to reproduce this problem.

XAML:
<Window x:Class="TelerikStackoverflowRepro.MainWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" Title="MainWindow" Height="350" Width="525"
    <Grid> 
        <telerik:RadSlider Name="NumericSlider" Minimum="{Binding Minimum}" Maximum="{Binding Maximum}"                           
                           SelectionEnd="{Binding SelectionEnd, Mode=TwoWay}" SelectionStart="{Binding SelectionStart, Mode=TwoWay}" IsSelectionRangeEnabled="True"/> 
    </Grid> 
</Window> 
 


C#:
using System; 
using System.Windows; 
 
namespace TelerikStackoverflowRepro 
    public partial class MainWindow : Window 
    { 
        public MainWindow() 
        { 
            InitializeComponent(); 
 
            var data = new SelectionData(); 
            data.Initialize(); 
 
            this.DataContext = data; 
 
        } 
    } 
 
    public class SelectionData 
    { 
        private int min; 
        private int max; 
        private int selectionStart; 
        private int selectionEnd; 
         
        public int Minimum 
        { 
            get 
            { 
                return min; 
            } 
            set 
            { 
                min = value; 
                Console.WriteLine("Minimum set to " + min); 
            } 
        } 
 
        public int Maximum 
        { 
            get 
            { 
                return max; 
            } 
            set 
            { 
                max = value; 
                Console.WriteLine("Maximum set to " + max); 
            } 
        } 
 
        public int SelectionStart 
        { 
            get 
            { 
                return selectionStart; 
            } 
            set 
            { 
                selectionStart = value; 
                Console.WriteLine("SelectionStart set to " + selectionStart); 
            } 
        } 
 
        public int SelectionEnd 
        { 
            get 
            { 
                return selectionEnd; 
            } 
            set 
            { 
                selectionEnd = value; 
                Console.WriteLine("SelectionEnd set to " + selectionEnd); 
            } 
        } 
 
        public void Initialize() 
        { 
            Minimum = 6; 
            Maximum = 12; 
        } 
 
    } 
 

You can look at your console output to see the problem as it happens.

Workaround:
Setting Maximum prior to Minimum completely avoids this glitch, which is fine for now.  Hopefully you folks can patch this up so that others don't need to spend the time scratching their heads and trying to figure out what went horribly wrong with their code. =)

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 17 Mar 2010, 02:10 PM
Hi Andrew,

Thank you for your feedback. We will investigate the issue and determine what is causing it. I've also added 1000 Telerik points to your account. Let us know if you have additional questions or comments.

Kind regards,
Kiril Stanoev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Slider
Asked by
Andrew Anderson
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or