sskodje / wpfchrometabs-mvvm

A tab control based on WPF chrome tabs, modified to work with the MVVM pattern
MIT License
256 stars 60 forks source link

ArgumentOutOfRange exception in ChromeTabPanel.ProcessMouseMove(Point p) #16

Closed stebla27 closed 7 years ago

stebla27 commented 7 years ago

Sometime a ArgumentOutOfRange exception in ChromeTabPanel.ProcessMouseMove(Point p) is thrown. Problem is an access to a double array with an invalid index. I suppose this could be the problem: int localSlideIndex = this.slideIndex; if (margin.Left < this.slideIntervals[localSlideIndex - 1]) { SwapSlideInterval(localSlideIndex - 1); localSlideIndex -= 1; changed = 1; } else if (margin.Left > this.slideIntervals[localSlideIndex + 1]) { SwapSlideInterval(localSlideIndex + 1); localSlideIndex += 1; changed = -1; } There is no check if localSlideIndex-1 is >= 0 and if it's < Count. Please check all other source positions too.

Callstack: image

sskodje commented 7 years ago

Hm, that's weird. What basically should happen when you drag a tab is that the "slideIntervals" collection is created when you grab the tab, and is destroyed when you release the tab. Both the "slideIndex" and "slideIntervals" are created together when a tab is grabbed, so the index should always be valid for the tab collection you have at the moment you start dragging it.

Is there any more info you could give about the out of bounds exception? Is the index below zero, or is it higher than the item count? Is it repeatable?

stebla27 commented 7 years ago

Unfortunately I have no additional info. But now the exception occurs again. The control is now in a bad state and it s enough to hover over the tab header. ==> Result: Exception occurs on each mouse move. This behaviour is now 100% reproducible on each tab (I have 3), But don't ask me what I have done to get in this state. I don't know. Sorry!

sskodje commented 7 years ago

Oh, so it crashes even without dragging? That explains how the index goes out of range at least. I'll see if i can figure out what goes wrong.

stebla27 commented 7 years ago

Yes, only mouse hovering throws the exception(s). Thanks for investigating!

sskodje commented 7 years ago

I'm sorry for taking so long. I have been unable to reproduce this on my own projects. Would it be possible for you to isolate the code that reproduces this error in a project and attach it here? I don't like to do changes that can affect other users when i don't know the underlying issue.

stebla27 commented 7 years ago

Difficult! There are too much dependencies. How about just checking the index before accessing the array. OK maybe this is a symptomatical bugfix but it's not wrong checking it before array access and it would solve my problem.

sskodje commented 7 years ago

I have made some changes that will prevent a crash on out of index, but there might be missing animations when it happens. Please let me know if you figure out the underlying cause.