Skip to content

Commit f9991c8

Browse files
committed
removed unnecessary includes and moved the uncaught exception handler
1 parent 2812af3 commit f9991c8

9 files changed

+13
-14
lines changed

src/jni/ArrayElementAccessor.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "NativeScriptAssert.h"
88
#include "NativeScriptException.h"
99
#include "JType.h"
10-
#include <assert.h>
1110

1211
using namespace v8;
1312
using namespace std;

src/jni/JsArgConverter.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "JsArgConverter.h"
22
#include <sstream>
3-
#include <assert.h>
43
#include "ObjectManager.h"
54
#include "NativeScriptAssert.h"
65
#include "ArgConverter.h"

src/jni/JsArgToArrayConverter.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "JsArgToArrayConverter.h"
22
#include <limits>
33
#include <sstream>
4-
#include <assert.h>
54
#include "ObjectManager.h"
65
#include "NativeScriptAssert.h"
76
#include "ArgConverter.h"

src/jni/MetadataNode.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ Local<Function> MetadataNode::SetMembersFromRuntimeMetadata(Isolate *isolate, Lo
498498

499499
char chKind = kind[0];
500500

501+
// method or field
501502
assert((chKind == 'M') || (chKind == 'F'));
502503

503504
MetadataEntry entry;

src/jni/MetadataReader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ MetadataTreeNode* MetadataReader::GetOrCreateTreeNodeByName(const string& classN
526526
typeLine >> kind >> name;
527527
auto cKind = kind[0];
528528

529+
// package, class, interface
529530
assert((cKind == 'P') || (cKind == 'C') || (cKind == 'I'));
530531

531532
if ((cKind == 'C') || (cKind == 'I'))

src/jni/NativePlatform.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "NativePlatform.h"
2626
#include <sstream>
2727
#include <android/log.h>
28-
#include <assert.h>
2928
#include <string>
3029

3130
using namespace v8;

src/jni/Profiler.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "prof.h"
44
#include "NativeScriptException.h"
55
#include "NativeScriptAssert.h"
6-
#include <assert.h>
76
#include <stack>
87

98
using namespace v8;

src/jni/com_tns_NativeScriptActity.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "NativeScriptException.h"
1414
#include <sstream>
1515
#include <android/log.h>
16-
#include <assert.h>
1716
#include <string>
1817

1918
using namespace v8;

src/src/com/tns/NativeScriptApplication.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tns;
22

33
import java.io.File;
4+
import java.lang.Thread.UncaughtExceptionHandler;
45

56
import android.app.Application;
67
import android.content.pm.PackageManager.NameNotFoundException;
@@ -710,14 +711,18 @@ public void onCreate() {
710711

711712
System.loadLibrary("NativeScript");
712713

713-
Logger logger = new LogcatLogger(BuildConfig.DEBUG, this);
714+
Logger logger = new LogcatLogger(BuildConfig.DEBUG, this);
714715

715716
boolean showErrorIntent = hasErrorIntent();
716717
if (!showErrorIntent)
717718
{
718719
appInstance = this;
719720

720-
prepareAppBuilderCallbackImpl(logger);
721+
Thread.UncaughtExceptionHandler exHandler = new NativeScriptUncaughtExceptionHandler(logger, this);
722+
723+
prepareAppBuilderCallbackImpl(logger, exHandler);
724+
725+
Thread.setDefaultUncaughtExceptionHandler(exHandler);
721726

722727
// TODO: refactor
723728
ExtractPolicy extractPolicy = (appBuilderCallbackImpl != null)
@@ -782,7 +787,7 @@ public void onCreate() {
782787
}
783788
}
784789

785-
private void prepareAppBuilderCallbackImpl(Logger logger)
790+
private void prepareAppBuilderCallbackImpl(Logger logger, UncaughtExceptionHandler exHandler)
786791
{
787792
Class<?> appBuilderCallbackClass = null;
788793

@@ -824,11 +829,9 @@ private void prepareAppBuilderCallbackImpl(Logger logger)
824829
}
825830
}
826831

827-
Thread.UncaughtExceptionHandler exHandler = (appBuilderCallbackImpl != null)
828-
? appBuilderCallbackImpl.getDefaultUncaughtExceptionHandler()
829-
: new NativeScriptUncaughtExceptionHandler(logger, this);
830-
831-
Thread.setDefaultUncaughtExceptionHandler(exHandler);
832+
if(appBuilderCallbackImpl != null) {
833+
exHandler = appBuilderCallbackImpl.getDefaultUncaughtExceptionHandler();
834+
}
832835

833836
boolean shouldEnableDebugging = (appBuilderCallbackImpl != null)
834837
? appBuilderCallbackImpl.shouldEnableDebugging(this)

0 commit comments

Comments
 (0)