This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Adding/Removing Ribbon tabs can cause NullReferenceException #185
Comments
Hi @jpatte Thank you for the message, this is the correct repository to pull requests to fix any issues that you find, as this is used for every other published version. |
Hi @jpatte Is this what you mean? public ViewDrawRibbonGroup ViewGroupFromPoint(Point pt)
{
// There can only be groups showing for the currently selected tab
if (Ribbon.SelectedTab != null && _tabToView != null)
{
// Get the scroll port for this tab
ViewLayoutRibbonScrollPort viewScrollPort = _tabToView[Ribbon.SelectedTab];
// The first child of the scroll port is always the view control
ViewLayoutControl viewControl = viewScrollPort[0] as ViewLayoutControl;
// The first child of the view control is always the ribbon groups
ViewLayoutRibbonGroups viewGroups = viewControl.ChildView as ViewLayoutRibbonGroups;
// Ask the view groups to find a matching group
return viewGroups.ViewGroupFromPoint(pt);
}
return null;
} |
Hi, actually what I mean is: public ViewDrawRibbonGroup ViewGroupFromPoint(Point pt)
{
// There can only be groups showing for the currently selected tab
if((Ribbon.SelectedTab != null) &&
(_tabToView.ContainsKey(Ribbon.SelectedTab)))
{
// Get the scroll port for this tab
ViewLayoutRibbonScrollPort viewScrollPort = _tabToView[Ribbon.SelectedTab];
// The first child of the scroll port is always the view control
ViewLayoutControl viewControl = viewScrollPort[0] as ViewLayoutControl;
// The first child of the view control is always the ribbon groups
ViewLayoutRibbonGroups viewGroups = viewControl.ChildView as ViewLayoutRibbonGroups;
// Ask the view groups to find a matching group
return viewGroups.ViewGroupFromPoint(pt);
}
return null;
} We need to check if Thanks for letting me know about the repo, I'll submit pull requests if I stumble upon any other issue. |
Just added the fix, it'll be included in the next update. |
Great, thanks! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
We have an app that dynamically adds and removes ribbon tabs depending on the context. We have observed that a NullReferenceException in
ViewDrawRibbonGroupsBorderSynch
may cause the app to crash occasionally.The problem is in ComponentFactory.Krypton.Ribbon\View Draw\ViewDrawRibbonGroupsBorderSynch.cs, line 72: the code checks if
Ribbon.SelectedTab
isn'tnull
but, unlike all the other methods in the same source file, it omits to check if_tabToView
has an entry for this tab. Simply adding this check fixes the issue.I would gladly submit a pull request to fix this but I'm not sure which repository is used to maintain the source code.
Could you make this change?
Thanks!
Julien
The text was updated successfully, but these errors were encountered: