Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception when trying to bring back QuickAccessItem #135

Closed
KingKnecht opened this issue Jul 9, 2015 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@KingKnecht
Copy link

When hiding a QuickAccessMenuItem like this:
image

and then try to bring it back:
image

I get a "Null pointer exception".

image

Stack-Trace:

   bei System.Windows.Input.InputManager.PushMenuMode(PresentationSource menuSite)
   bei System.Windows.Controls.Primitives.MenuBase.PushMenuMode(Boolean isAcquireFocusMenuMode)
   bei System.Windows.Controls.Primitives.MenuBase.OnPreviewKeyboardInputProviderAcquireFocus(Object sender, KeyboardInputProviderAcquireFocusEventArgs e)
   bei System.Windows.Input.KeyboardInputProviderAcquireFocusEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   bei System.Windows.Input.InputManager.ProcessStagingArea()
   bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   bei System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   bei System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
   bei System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
   bei System.Windows.UIElement.Focus()
   bei System.Windows.Controls.MenuItem.FocusOrSelect()
   bei System.Windows.Controls.MenuItem.OnClickImpl(Boolean userInitiated)
   bei System.Windows.Controls.MenuItem.OnClick()
   bei Fluent.MenuItem.OnClick() in c:\DEV\OSS_Own\FluentRibbon\Fluent.Ribbon\Fluent\Controls\MenuItem.cs:Zeile 625.
   bei System.Windows.Controls.MenuItem.OnClickCore(Boolean userInitiated)
   bei System.Windows.Controls.MenuItem.ClickItem(Boolean userInitiated)
   bei System.Windows.Controls.MenuItem.HandleMouseUp(MouseButtonEventArgs e)
   bei System.Windows.Controls.MenuItem.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   bei Fluent.MenuItem.OnMouseLeftButtonUp(MouseButtonEventArgs e) in c:\DEV\OSS_Own\FluentRibbon\Fluent.Ribbon\Fluent\Controls\MenuItem.cs:Zeile 610.
   bei System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   bei System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   bei System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   bei System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   bei System.Windows.Input.InputManager.ProcessStagingArea()
   bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   bei System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   bei System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   bei System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

It's happening in MenuItem.cs line 625:

image

@batzen
Copy link
Member

batzen commented Jul 10, 2015

Which windows and .NET versions are you using?
Any custom code running in your project that makes use of MenuModes?

@batzen
Copy link
Member

batzen commented Jul 10, 2015

And the code of your QuickAccessMenuItem would be nice.

@KingKnecht
Copy link
Author

<fluent:Ribbon x:Name="Ribbon"
                       AutomaticStateManagement="True">

            <fluent:Ribbon.QuickAccessItems>

                <fluent:QuickAccessMenuItem IsChecked="True"
                                            Target="{Binding ElementName=UndoButton}" />
                <fluent:QuickAccessMenuItem IsChecked="True"
                                            Target="{Binding ElementName=RedoButton}" />

            </fluent:Ribbon.QuickAccessItems>

            <fluent:RibbonTabItem   x:Name="homeTabItem"
                                    Header="Home"
                                    KeyTip="H"
                                    ToolTip="Regular Tool Tip">
                <fluent:RibbonGroupBox Header="Undo/Redo">

                    <StackPanel Orientation="Horizontal">
                        <fluent:SplitButton x:Name="UndoButton"
                                            KeyTip="Ctrl+Z"
                                            Header="Undo"
                                            Icon="{DynamicResource appbar_undo}"
                                            SizeDefinition="Middle,Small"
                                            Command="ApplicationCommands.Undo"
                                            FocusManager.IsFocusScope="True"
                                            CanAddButtonToQuickAccessToolBar="True"
                                            Click="UndoButton_OnClick"
                                            ClosePopupOnMouseDown="True">
                            <fluent:MenuItem Header="Begin"
                                      Click="MenuItem_OnClick" />

                            <fluent:MenuItem Header="Undo something" />
                            <fluent:MenuItem Header="Undo another thing" />
                        </fluent:SplitButton>

                        <fluent:SplitButton x:Name="RedoButton"
                                            KeyTip="Ctrl+Y"
                                            Header="Redo"
                                            Icon="{DynamicResource appbar_redo}"
                                            SizeDefinition="Middle,Small"
                                            Command="ApplicationCommands.Redo"
                                            CanAddButtonToQuickAccessToolBar="True"
                                            FocusManager.IsFocusScope="True">
                        </fluent:SplitButton>
                    </StackPanel>
                </fluent:RibbonGroupBox>
            </fluent:RibbonTabItem>

        </fluent:Ribbon>

What could be special is "Icon="{DynamicResource appbar_undo}"
which is a XAML Icon:

<Canvas x:Key="appbar_undo"
            Width="76"
            Height="76"
            Background="Transparent"
            Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
        <Path Width="38.3892"
              Height="39.458"
              Canvas.Left="19"
              Canvas.Top="21.474"
              Stretch="Fill"
              Fill="{DynamicResource BlackBrush}"
              Data="F1 M 52.7514,25.076C 53.4111,25.7534 54.0258,26.4933 54.5953,27.296C 55.1649,28.0987 55.6564,28.9607 56.0698,29.8821C 56.4832,30.8035 56.8065,31.7766 57.0396,32.8014C 57.2727,33.8262 57.3892,34.8883 57.3892,35.9878C 57.3892,37.0566 57.276,38.1517 57.0495,39.2733C 56.823,40.3948 56.4491,41.5394 55.928,42.7071C 55.4068,43.8748 54.713,45.07 53.8465,46.2927C 52.9801,47.5154 51.9069,48.7601 50.6271,50.0267C 50.2137,50.4358 49.7431,50.902 49.2153,51.4253C 48.6875,51.9487 48.1278,52.5029 47.5363,53.0878C 46.9447,53.6728 46.34,54.2742 45.722,54.8922C 45.1041,55.5101 44.4983,56.1072 43.9045,56.6833C 42.5323,58.0424 41.1029,59.4586 39.6163,60.9319L 35.3545,56.6239C 36.8235,55.1638 38.2441,53.7542 39.6163,52.3951C 40.1969,51.819 40.7994,51.2252 41.424,50.6139C 42.0485,50.0025 42.6565,49.4011 43.2481,48.8095C 43.8396,48.218 44.3993,47.6605 44.9271,47.1371C 45.4549,46.6138 45.9255,46.1476 46.3389,45.7385C 48.0146,44.0584 49.2758,42.3904 50.1224,40.7345C 50.969,39.0786 51.3924,37.4678 51.3924,35.9021C 51.3924,34.719 51.1516,33.5777 50.67,32.4781C 50.1884,31.3786 49.4528,30.3406 48.4632,29.3642C 48.2169,29.1179 47.9112,28.8848 47.5462,28.6649C 47.1811,28.445 46.7688,28.2526 46.3092,28.0877C 45.8496,27.9227 45.3482,27.7886 44.805,27.6852C 44.2619,27.5819 43.6868,27.5302 43.0799,27.5302C 42.4641,27.5302 41.8198,27.5929 41.1469,27.7182C 40.474,27.8436 39.7933,28.0503 39.105,28.3384C 38.4167,28.6264 37.7218,29.0036 37.0203,29.4698C 36.3188,29.936 35.6316,30.5056 34.9587,31.1785L 30.466,35.6976L 37.4986,42.75L 19,42.75L 19,24.5417L 25.9931,31.4094L 30.5056,26.8705C 31.5083,25.7446 32.5463,24.8275 33.6194,24.1194C 34.6926,23.4113 35.7646,22.8616 36.8356,22.4701C 37.9065,22.0787 38.972,21.8148 40.0319,21.6785C 41.0919,21.5421 42.1079,21.474 43.0799,21.474C 44.087,21.474 45.0579,21.563 45.9925,21.7411C 46.9271,21.9193 47.8068,22.17 48.6314,22.4932C 49.4561,22.8165 50.2148,23.198 50.9075,23.6378C 51.6002,24.0777 52.2148,24.5571 52.7514,25.076 Z " />
    </Canvas>

I'm not exactly sure what you mean with "MenuModes"?

I'm using .Net 4.5 and following theme:

<!-- Fluent theme-->
                <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Office2013/Generic.xaml" />

I will build a plain FluentRibbon App and do further checks.

@batzen
Copy link
Member

batzen commented Jul 10, 2015

You are right, it's the icon which causes this issue. Will investigate.

@batzen batzen self-assigned this Jul 10, 2015
@batzen batzen modified the milestones: Next, 3.4.2 Jul 10, 2015
@batzen batzen closed this as completed in a456a08 Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants