From 9f94aaf450200d1aab1dd7aff43cd8cf58de57a5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 10 Aug 2018 21:43:50 -0700 Subject: [PATCH] Whitespace cleanup, extra braces, and null checks Thanks to Lubomir for the review. Signed-off-by: Dirk Hohndel --- .../mobile/SubsurfaceMobileActivity.java | 12 ++++++++++++ core/android.cpp | 2 +- mobile-widgets/qmlmanager.cpp | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java index 66f5c1b0e..4c5bc576b 100644 --- a/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java +++ b/android-mobile/src/org/subsurfacedivelog/mobile/SubsurfaceMobileActivity.java @@ -53,6 +53,10 @@ public class SubsurfaceMobileActivity extends QtActivity public void onNewIntent(Intent intent) { Log.i(TAG + " onNewIntent", intent.getAction()); UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); + if (device == null) { + Log.i(TAG + " onNewIntent", "null device"); + return; + } Log.i(TAG + " onNewIntent toString", device.toString()); super.onNewIntent(intent); setIntent(intent); @@ -78,8 +82,16 @@ public class SubsurfaceMobileActivity extends QtActivity private void processIntent() { Intent intent = getIntent(); + if (intent == null) { + Log.i(TAG + " processIntent", "intent is null"); + return; + } Log.i(TAG + " processIntent", intent.getAction()); UsbDevice device = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); + if (device == null) { + Log.i(TAG + " processIntent", "null device"); + return; + } Log.i(TAG + " processIntent device name", device.getDeviceName()); setDeviceString(device.toString()); } // processIntent diff --git a/core/android.cpp b/core/android.cpp index 15f95612a..1a9e76e06 100644 --- a/core/android.cpp +++ b/core/android.cpp @@ -244,7 +244,7 @@ bool subsurface_user_is_root() void checkPendingIntents() { QAndroidJniObject activity = QtAndroid::androidActivity(); - if(activity.isValid()) { + if (activity.isValid()) { activity.callMethod("checkPendingIntents"); qDebug() << "checkPendingIntents "; return; diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index c79bf5b62..645ddd152 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1796,16 +1796,17 @@ void QMLManager::showDownloadPage(QString deviceString) } else if (deviceString.contains("mManufacturerName=ATOMIC AQUATICS") && deviceString.contains("mProductName=COBALT")) { - if (deviceString.contains("mVersion=2")) + if (deviceString.contains("mVersion=2")) { name = QString("%1;%2;%3") .arg(vendorList.indexOf("Atomic Aquatics")) .arg(productList["Atomic Aquatics"].indexOf("Cobalt 2")) .arg(connectionListModel.indexOf("USB device")); - else + } else { name = QString("%1;%2;%3") .arg(vendorList.indexOf("Atomic Aquatics")) .arg(productList["Atomic Aquatics"].indexOf("Cobalt")) .arg(connectionListModel.indexOf("USB device")); + } } else if (deviceString.contains("mVendorId=5267") && deviceString.contains("mProductId=48")) { name = QString("%1;%2;%3")