Android: use QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS for debugging only
Enable the workaround to sleep and wait for the debugger to attach from Qt Creator using QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS only when running a debugger and not with all debug apps. Fixes: QTBUG-128298 Pick-to: 6.7 Change-Id: I0a0866fada27de250fd6946a8ccfd254824d70e0 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Cristian Adam <cristian.adam@qt.io> (cherry picked from commit e8a35410c4c699ea588791006b36dd363cc25d9c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
87b21e3ded
commit
03bf2cba3f
@ -11,7 +11,6 @@ import android.content.Intent;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.system.Os;
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -113,14 +112,6 @@ class QtActivityLoader extends QtLoader {
|
|||||||
String extraAppParams = extras.getString("extraappparams");
|
String extraAppParams = extras.getString("extraappparams");
|
||||||
appendApplicationParameters(getDecodedUtfString(extraAppParams));
|
appendApplicationParameters(getDecodedUtfString(extraAppParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_debuggerSleepMs = 3000;
|
|
||||||
if (Os.getenv("QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS") != null) {
|
|
||||||
try {
|
|
||||||
m_debuggerSleepMs = Integer.parseInt(Os.getenv("QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(QtNative.QtTAG, "Not in debug mode! It is not allowed to use extra arguments " +
|
Log.d(QtNative.QtTAG, "Not in debug mode! It is not allowed to use extra arguments " +
|
||||||
"in non-debug mode.");
|
"in non-debug mode.");
|
||||||
|
@ -17,6 +17,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Debug;
|
||||||
|
import android.system.Os;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -47,8 +49,6 @@ abstract class QtLoader {
|
|||||||
protected String m_applicationParameters = "";
|
protected String m_applicationParameters = "";
|
||||||
protected HashMap<String, String> m_environmentVariables = new HashMap<>();
|
protected HashMap<String, String> m_environmentVariables = new HashMap<>();
|
||||||
|
|
||||||
protected int m_debuggerSleepMs = 0;
|
|
||||||
|
|
||||||
protected static QtLoader m_instance = null;
|
protected static QtLoader m_instance = null;
|
||||||
protected boolean m_librariesLoaded;
|
protected boolean m_librariesLoaded;
|
||||||
|
|
||||||
@ -440,11 +440,23 @@ abstract class QtLoader {
|
|||||||
ArrayList<String> nativeLibraries = getQtLibrariesList();
|
ArrayList<String> nativeLibraries = getQtLibrariesList();
|
||||||
nativeLibraries.addAll(getLocalLibrariesList());
|
nativeLibraries.addAll(getLocalLibrariesList());
|
||||||
|
|
||||||
if (m_debuggerSleepMs > 0) {
|
if (Debug.isDebuggerConnected()) {
|
||||||
Log.i(QtTAG, "Sleeping for " + m_debuggerSleepMs +
|
final String debuggerSleepEnvVarName = "QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS";
|
||||||
"ms, helping the native debugger to settle. " +
|
int debuggerSleepMs = 3000;
|
||||||
"Use the env QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS variable to change this value.");
|
if (Os.getenv(debuggerSleepEnvVarName) != null) {
|
||||||
QtNative.getQtThread().sleep(m_debuggerSleepMs);
|
try {
|
||||||
|
debuggerSleepMs = Integer.parseInt(Os.getenv(debuggerSleepEnvVarName));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debuggerSleepMs > 0) {
|
||||||
|
Log.i(QtTAG, "Sleeping for " + debuggerSleepMs +
|
||||||
|
"ms, helping the native debugger to settle. " +
|
||||||
|
"Use the env " + debuggerSleepEnvVarName +
|
||||||
|
" variable to change this value.");
|
||||||
|
QtNative.getQtThread().sleep(debuggerSleepMs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadLibraries(nativeLibraries)) {
|
if (!loadLibraries(nativeLibraries)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user