mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed: JBR-1347 Instaneous exit on using Alt-Enter to add an import automatically (MenuData::HandleGetNamedAccessibleAttribute)
add extra npe checks
This commit is contained in:
Binary file not shown.
@@ -101,7 +101,9 @@ static const int g_interItemSpacings = 5;
|
||||
|
||||
@end
|
||||
|
||||
static int _fillCache(NSMutableArray * cache, NSMutableArray * visibleItems, void* items, int byteCount) {
|
||||
static void _fillCache(NSMutableArray * cache, NSMutableArray * visibleItems, void* items, int byteCount) {
|
||||
if (cache == NULL || visibleItems == NULL || items == NULL || byteCount <= 0)
|
||||
return;
|
||||
const int prevCacheSize = cache.count;
|
||||
const int prevVisibleSize = visibleItems.count;
|
||||
const char * p = items;
|
||||
@@ -188,6 +190,9 @@ void appendScrubberItems(id scrubObj, void* packedItems, int byteCount) {
|
||||
|
||||
// NOTE: called from EDT (when update UI)
|
||||
void enableScrubberItems(id scrubObj, void* itemIndices, int count, bool enabled) {
|
||||
if (itemIndices == NULL || count <= 0)
|
||||
return;
|
||||
|
||||
NSScrubberContainer *container = scrubObj;
|
||||
NSScrubber *scrubber = container.view;
|
||||
const int sizeInBytes = sizeof(int)*count;
|
||||
@@ -220,6 +225,9 @@ void enableScrubberItems(id scrubObj, void* itemIndices, int count, bool enabled
|
||||
|
||||
// NOTE: called from EDT (when update UI)
|
||||
void showScrubberItems(id scrubObj, void* itemIndices, int count, bool show) {
|
||||
if (itemIndices == NULL || count <= 0)
|
||||
return;
|
||||
|
||||
NSScrubberContainer * container = scrubObj;
|
||||
NSScrubber *scrubber = container.view;
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ public class NST {
|
||||
|
||||
public static ID createScrubber(String uid, int itemWidth, NSTLibrary.ScrubberDelegate delegate, NSTLibrary.ScrubberCacheUpdater updater, List<TBItemScrubber.ItemData> items, int itemsCount) {
|
||||
final Memory mem = _packItems(items, 0, itemsCount);
|
||||
final ID scrubberNativePeer = ourNSTLibrary.createScrubber(uid, itemWidth, delegate, updater, mem, (int)mem.size()); // called from AppKit, uses per-event autorelease-pool
|
||||
final ID scrubberNativePeer = ourNSTLibrary.createScrubber(uid, itemWidth, delegate, updater, mem, mem == null ? 0 : (int)mem.size()); // called from AppKit, uses per-event autorelease-pool
|
||||
return scrubberNativePeer;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class NST {
|
||||
|
||||
static void appendScrubberItems(ID scrubObj, List<TBItemScrubber.ItemData> items, int fromIndex, int itemsCount) {
|
||||
final Memory mem = _packItems(items, fromIndex, itemsCount);
|
||||
ourNSTLibrary.appendScrubberItems(scrubObj, mem, (int)mem.size()); // called from AppKit, uses per-event autorelease-pool
|
||||
ourNSTLibrary.appendScrubberItems(scrubObj, mem, mem == null ? 0 : (int)mem.size()); // called from AppKit, uses per-event autorelease-pool
|
||||
}
|
||||
public static void enableScrubberItem(ID scrubObj, Collection<Integer> indices, boolean enabled) {
|
||||
if (indices == null || indices.isEmpty())
|
||||
@@ -222,8 +222,16 @@ public class NST {
|
||||
}
|
||||
|
||||
private static @Nullable Memory _packItems(List<TBItemScrubber.ItemData> items, int fromIndex, int itemsCount) {
|
||||
if (items == null)
|
||||
if (items == null || itemsCount <= 0)
|
||||
return null;
|
||||
if (fromIndex < 0) {
|
||||
LOG.error("_packItems: fromIndex < 0 (" + fromIndex + ")");
|
||||
return null;
|
||||
}
|
||||
if (fromIndex + itemsCount > items.size()) {
|
||||
LOG.error("_packItems: fromIndex + itemsCount > items.size() (" + fromIndex + ", " + itemsCount + ", " + items.size() + ")");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1. calculate size
|
||||
int byteCount = 4;
|
||||
|
||||
Reference in New Issue
Block a user