Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/generate-quality-report.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,8 @@ def main() -> None:
if spotbugs:
forbidden_rules = {
"RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
"RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"
"RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE",
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"
}
violations = [
f for f in spotbugs.findings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ public XYMultiSeriesTransition(ChartComponent chart, XYMultipleSeriesDataset dat
protected void initTransition() {

getBuffer(); // initializes the buffer and seriesTranslations
int len = seriesTransitions.length;
for (int i = 0; i < len; i++) {
seriesTransitions[i].initTransition();
if (seriesTransitions != null) {
int len = seriesTransitions.length;
for (int i = 0; i < len; i++) {
seriesTransitions[i].initTransition();
}
}
super.initTransition();

Expand All @@ -86,9 +88,11 @@ protected void initTransition() {
@Override
protected void update(int progress) {
getBuffer(); // initializes the buffer and seriesTranslations
int len = seriesTransitions.length;
for (int i = 0; i < len; i++) {
seriesTransitions[i].update(progress);
if (seriesTransitions != null) {
int len = seriesTransitions.length;
for (int i = 0; i < len; i++) {
seriesTransitions[i].update(progress);
}
}
}

Expand All @@ -99,9 +103,11 @@ protected void update(int progress) {
protected void cleanup() {
super.cleanup();
getBuffer(); // initializes the buffer and seriesTranslations
int len = seriesTransitions.length;
for (int i = 0; i < len; i++) {
seriesTransitions[i].cleanup();
if (seriesTransitions != null) {
int len = seriesTransitions.length;
for (int i = 0; i < len; i++) {
seriesTransitions[i].cleanup();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ private void copyValues(XYSeries source, XYSeries target) {
@Override
protected void cleanup() {
super.cleanup();
this.cachedSeries.clear();
if (cachedSeries != null) {
this.cachedSeries.clear();
}
}


Expand All @@ -119,6 +121,7 @@ protected void cleanup() {
*/
protected void update(int progress) {
double dProgress = progress;
if (endVals == null || startVals == null) return;
int len = endVals.getItemCount(); // PMD Fix: UnusedLocalVariable removed unused endindex
for (int i = 0; i < len; i++) {
double x = endVals.getX(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ private void copyValues(XYValueSeries source, XYValueSeries target) {
@Override
protected void cleanup() {
super.cleanup();
this.cachedSeries.clear();
if (cachedSeries != null) {
this.cachedSeries.clear();
}
}


Expand All @@ -119,6 +121,7 @@ protected void cleanup() {
*/
protected void update(int progress) {
double dProgress = progress;
if (endVals == null || startVals == null) return;
int len = endVals.getItemCount(); // PMD Fix: UnusedLocalVariable removed unused endindex
for (int i = 0; i < len; i++) {
double x = endVals.getX(i);
Expand Down
1 change: 1 addition & 0 deletions CodenameOne/src/com/codename1/charts/views/XYChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ protected void drawText(Canvas canvas, String text, float x, float y, Paint pain
* @param inverse if the inverse transform needs to be applied
*/
private void transform(Canvas canvas, float angle, boolean inverse) {
if (mCenter == null) return;
if (inverse) {
canvas.scale(1 / mScale, mScale);
canvas.translate(mTranslate, -mTranslate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ public static void continueFetching(Container cnt) {
}

void reachedEnd() {
infiniteContainer.removeComponent(endMarker);
infiniteContainer.addComponent(ip);
infiniteContainer.revalidate();
Display.getInstance().callSerially(fetchMore);
if (infiniteContainer != null) {
infiniteContainer.removeComponent(endMarker);
infiniteContainer.addComponent(ip);
infiniteContainer.revalidate();
}
if (fetchMore != null) {
Display.getInstance().callSerially(fetchMore);
}
}

/**
Expand All @@ -147,6 +151,9 @@ void reachedEnd() {
* @param areThereMore whether additional components exist
*/
public void addMoreComponents(Component[] components, boolean areThereMore) {
if (infiniteContainer == null) {
return;
}
infiniteContainer.removeComponent(ip);
infiniteContainer.removeComponent(endMarker);
for (Component c : components) {
Expand Down Expand Up @@ -177,7 +184,7 @@ public void addMoreComponents(Component[] components, boolean areThereMore) {
* user interaction see https://github.com/codenameone/CodenameOne/issues/2721
*/
public void continueFetching() {
if (endMarker.getParent() == null) {
if (endMarker.getParent() == null && fetchMore != null) {
fetchMore.run();
}
}
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/facebook/FaceBookAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,9 @@ public void search(String objectType, String query, DefaultListModel results, Ac
* Kills the current request.
*/
public void killCurrentRequest() {
current.kill();
if (current != null) {
current.kill();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5636,7 +5636,10 @@ protected boolean isLogged() {
* @param content content of the message
*/
protected void log(String content) {
logger.actionPerformed(new ActionEvent(content, ActionEvent.Type.Log));
ActionListener l = logger;
if(l != null) {
l.actionPerformed(new ActionEvent(content, ActionEvent.Type.Log));
}
}

/**
Expand Down
9 changes: 7 additions & 2 deletions CodenameOne/src/com/codename1/io/NetworkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ public void shutdown() {
running = false;
if (networkThreads != null) {
for (NetworkThread n : networkThreads) {
n.stopped = true;
if(n != null) {
n.stopped = true;
}
}
}
networkThreads = null;
Expand Down Expand Up @@ -793,7 +795,10 @@ public ConnectionRequest getCurrentRequest() {

public void join() {
try {
threadInstance.join();
Thread t = threadInstance;
if(t != null) {
t.join();
}
} catch (InterruptedException ex) {
ex.printStackTrace();
}
Expand Down
2 changes: 2 additions & 0 deletions CodenameOne/src/com/codename1/io/WebServiceProxyCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ protected void handleException(Exception err) {
protected void readResponse(InputStream input) throws IOException {
DataInputStream dis = new DataInputStream(input);

if (def == null) return;
switch (def.returnType) {
case TYPE_VOID:
return;
Expand Down Expand Up @@ -512,6 +513,7 @@ protected void buildRequestBody(OutputStream os) throws IOException {
dos.writeUTF(def.name);
int alen = arguments.length;
for (int iter = 0; iter < alen; iter++) {
if (def == null || def.arguments == null) continue;
switch (def.arguments[iter]) {
case TYPE_BYTE:
dos.writeByte(((Byte) arguments[iter]).byteValue());
Expand Down
12 changes: 9 additions & 3 deletions CodenameOne/src/com/codename1/io/gzip/Inflate.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ int inflateReset() {
z.msg = null;
this.mode = HEAD;
this.need_bytes = -1;
this.blocks.reset();
if(this.blocks != null) {
this.blocks.reset();
}
return Z_OK;
}

Expand Down Expand Up @@ -311,7 +313,9 @@ int inflate(int f) {
this.marker = 0; // can try inflateSync
return Z_STREAM_ERROR;
case BLOCKS:
r = this.blocks.proc(r);
if (this.blocks != null) {
r = this.blocks.proc(r);
}
if (r == Z_DATA_ERROR) {
this.mode = BAD;
this.marker = 0; // can try inflateSync
Expand Down Expand Up @@ -595,7 +599,9 @@ int inflateSetDictionary(byte[] dictionary, int dictLength) {
length = (1 << this.wbits) - 1;
index = dictLength - length;
}
this.blocks.set_dictionary(dictionary, index, length);
if (this.blocks != null) {
this.blocks.set_dictionary(dictionary, index, length);
}
this.mode = BLOCKS;
return Z_OK;
}
Expand Down
12 changes: 6 additions & 6 deletions CodenameOne/src/com/codename1/io/gzip/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ private static int bi_reverse(
// not null.
void gen_bitlen(Deflate s) {
short[] tree = dyn_tree;
short[] stree = stat_desc.static_tree;
int[] extra = stat_desc.extra_bits;
int base = stat_desc.extra_base;
int max_length = stat_desc.max_length;
short[] stree = stat_desc != null ? stat_desc.static_tree : null;
int[] extra = stat_desc != null ? stat_desc.extra_bits : null;
int base = stat_desc != null ? stat_desc.extra_base : 0;
int max_length = stat_desc != null ? stat_desc.max_length : 0;
int h; // heap index
int n, m; // iterate over the tree elements
int bits; // bit length
Expand Down Expand Up @@ -275,8 +275,8 @@ void gen_bitlen(Deflate s) {
// also updated if stree is not null. The field max_code is set.
void build_tree(Deflate s) {
short[] tree = dyn_tree;
short[] stree = stat_desc.static_tree;
int elems = stat_desc.elems;
short[] stree = stat_desc != null ? stat_desc.static_tree : null;
int elems = stat_desc != null ? stat_desc.elems : 0;
int n, m; // iterate over heap elements
int max_code = -1; // largest code with non zero frequency
int node; // new node being created
Expand Down
9 changes: 9 additions & 0 deletions CodenameOne/src/com/codename1/io/rest/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,9 @@ public void actionPerformed(NetworkEvent evt) {
}
Response res = null;
Map response = (Map) evt.getMetaData();
if (response == null) {
return;
}
List<Map> lst = (List<Map>) response.get(root);
if (lst == null) {
return;
Expand Down Expand Up @@ -834,7 +837,13 @@ public Response<List<PropertyBusinessObject>> getAsPropertyList(Class type, Stri
CN.addToQueueAndWait(request);
Map response = ((Connection) request).json;
try {
if (response == null) {
return null;
}
List<Map> lst = (List<Map>) response.get(root);
if (lst == null) {
return null;
}
List<PropertyBusinessObject> result = new ArrayList<PropertyBusinessObject>();
for (Map m : lst) {
PropertyBusinessObject pb = (PropertyBusinessObject) type.newInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static PreferencesObject create(PropertyBusinessObject bo) {
* @return this to enable builder pattern binding
*/
public PreferencesObject bind() {
if (bo == null || bo.getPropertyIndex() == null) return this;
for (PropertyBase pb : bo.getPropertyIndex()) {
String name = (String) pb.getClientProperty("cn1-po-name");
if (name == null) {
Expand Down
4 changes: 3 additions & 1 deletion CodenameOne/src/com/codename1/share/ShareService.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public Form getOriginal() {
* method
*/
public void finish() {
original.showBack();
if (original != null) {
original.showBack();
}
}

}
16 changes: 12 additions & 4 deletions CodenameOne/src/com/codename1/ui/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -8024,25 +8024,33 @@ public void paint(Graphics g, Rectangle rect) {
int oAlpha = g.getAlpha();
if (alpha == 0) {
unSelectedStyle = originalStyle;
original.paint(g, rect);
if(original != null) {
original.paint(g, rect);
}
return;
}
if (alpha == 255) {
unSelectedStyle = destStyle;
dest.paint(g, rect);
if(dest != null) {
dest.paint(g, rect);
}
unSelectedStyle = originalStyle;
return;
}
int opa = unSelectedStyle.getBgTransparency() & 0xff;
unSelectedStyle.setBgTransparency(255 - alpha);
g.setAlpha(255 - alpha);
original.paint(g, rect);
if(original != null) {
original.paint(g, rect);
}
unSelectedStyle.setBgTransparency(opa);
unSelectedStyle = destStyle;
opa = unSelectedStyle.getBgTransparency() & 0xff;
g.setAlpha(alpha);
unSelectedStyle.setBgTransparency(alpha);
dest.paint(g, rect);
if(dest != null) {
dest.paint(g, rect);
}
unSelectedStyle.setBgTransparency(opa);
unSelectedStyle = originalStyle;
g.setAlpha(oAlpha);
Expand Down
10 changes: 6 additions & 4 deletions CodenameOne/src/com/codename1/ui/FontImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11880,10 +11880,12 @@ protected void drawImage(Graphics g, Object nativeGraphics, int x, int y) {
g.fillRect(x, y, width, height, backgroundOpacity);
}
g.setColor(color);
g.setFont(fnt);
int w = fnt.stringWidth(text);
int h = Math.round(fnt.getPixelSize());
if (h <= 0) h = fnt.getHeight();
if (fnt != null) {
g.setFont(fnt);
}
int w = fnt != null ? fnt.stringWidth(text) : 0;
int h = fnt != null ? Math.round(fnt.getPixelSize()) : 0;
if (h <= 0 && fnt != null) h = fnt.getHeight();
//int paddingPixels = Display.getInstance().convertToPixels(padding, true);
if (fgAlpha < 255) g.concatenateAlpha(fgAlpha);
if (rotated != 0) {
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/ui/SideMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ public void cleanup() {
public void paint(Graphics g) {
if (Display.getInstance().areMutableImagesFast()) {
// workaround for Android issue where the VKB breaks on screen size change
if (buffer.getHeight() != Display.getInstance().getDisplayHeight()) {
if (buffer == null || buffer.getHeight() != Display.getInstance().getDisplayHeight()) {
if (fwd) {
buffer = updateRightPanelBgImage(placement, getSource());
} else {
Expand Down
Loading
Loading