Skip to content
Snippets Groups Projects
Commit 12946a72 authored by Alexandre Lision's avatar Alexandre Lision Committed by Guillaume Roguez
Browse files

context menu: fix out of bound exception

index path was not calculated properly by the RingOutlineView

Change-Id: Idea0e90095a91b7737030cb201573d38024d5a0b
Tuleap: #447
parent 4baba4ca
Branches
Tags
No related merge requests found
......@@ -216,10 +216,14 @@ NSInteger const PHOTO_TAG = 400;
#pragma mark - ContextMenuDelegate
- (NSMenu*) contextualMenuForIndex:(NSIndexPath*) path
- (NSMenu*) contextualMenuForIndex:(NSTreeNode*) item
{
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
QModelIndex qIdx = [treeController toQIdx:item];
if (!qIdx.isValid()) {
return nil;
}
const auto& var = qIdx.data(static_cast<int>(Call::Role::Object));
if (qIdx.parent().isValid() && var.isValid()) {
if (auto call = var.value<Call *>()) {
......@@ -235,7 +239,6 @@ NSInteger const PHOTO_TAG = 400;
}
}
}
}
return nil;
}
......
......@@ -397,9 +397,14 @@ NSInteger const TXT_BUTTON_TAG = 500;
#pragma mark - ContextMenuDelegate
- (NSMenu*) contextualMenuForIndex:(NSIndexPath*) path
- (NSMenu*) contextualMenuForIndex:(NSTreeNode*) item
{
auto qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
auto qIdx = [treeController toQIdx:item];
if (!qIdx.isValid()) {
return nil;
}
auto originIdx = RecentModel::instance().peopleProxy()->mapToSource(qIdx);
auto contactmethods = RecentModel::instance().getContactMethods(originIdx);
if (contactmethods.isEmpty())
......
......@@ -24,7 +24,7 @@
@required
- (NSMenu*) contextualMenuForIndex:(NSIndexPath*) path;
- (NSMenu*) contextualMenuForIndex:(NSTreeNode*) path;
@end
......
......@@ -27,11 +27,8 @@
{
NSPoint pt = [self convertPoint:[evt locationInWindow] fromView:nil];
int rowIdx = [self rowAtPoint:pt];
int colIdx = [self columnAtPoint:pt];
if (self.contextMenuDelegate && rowIdx >= 0 && colIdx >= 0) {
NSUInteger indexes[2] = {static_cast<NSUInteger>(rowIdx), static_cast<NSUInteger>(colIdx)};
NSIndexPath* path = [NSIndexPath indexPathWithIndexes:indexes length:2];
return [self.contextMenuDelegate contextualMenuForIndex:path];
if (self.contextMenuDelegate && rowIdx >= 0) {
return [self.contextMenuDelegate contextualMenuForIndex:[self itemAtRow:rowIdx]];
}
return nil;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment