Ticket #13239: 20180723_1243_fix_themechange_segfault_with_restart_also_startup_gui.patch

File 20180723_1243_fix_themechange_segfault_with_restart_also_startup_gui.patch, 3.4 KB (added by Peter Bennett, 19 months ago)

Fix for seg fault

  • mythtv/libs/libmyth/mythcontext.cpp

    diff --git a/mythtv/libs/libmyth/mythcontext.cpp b/mythtv/libs/libmyth/mythcontext.cpp
    index 183b4884b20..f2129844222 100644
    a b bool MythContext::Init(const bool gui, 
    16561656    saveSettingsCache();
    16571657    if (d->m_settingsCacheDirty)
    16581658    {
     1659#ifndef Q_OS_ANDROID
    16591660        DestroyMythMainWindow();
     1661#endif
    16601662        d->m_settingsCacheDirty = false;
    16611663    }
    16621664    gCoreContext->ActivateSettingsCache(true);
  • mythtv/programs/mythfrontend/main.cpp

    diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp
    index 29c17d5e2bd..74dfb3ee050 100644
    a b using namespace std; 
    2020#include <QProcessEnvironment>
    2121#endif
    2222
     23#ifdef Q_OS_ANDROID
     24#include <QtAndroidExtras>
     25#endif
     26
    2327#include "previewgeneratorqueue.h"
    2428#include "referencecounter.h"
    2529#include "mythmiscutil.h"
    static bool resetTheme(QString themedir, const QString &badtheme) 
    13961400
    13971401static int reloadTheme(void)
    13981402{
     1403
     1404#ifdef Q_OS_ANDROID
     1405
     1406    // jni code to launch the application again
     1407    // reinitializing the main windows causes a segfault
     1408    // with android
     1409
     1410    auto activity = QtAndroid::androidActivity();
     1411    auto packageManager = activity.callObjectMethod
     1412        (   "getPackageManager",
     1413            "()Landroid/content/pm/PackageManager;"  );
     1414
     1415    auto activityIntent = packageManager.callObjectMethod
     1416        (   "getLaunchIntentForPackage",
     1417            "(Ljava/lang/String;)Landroid/content/Intent;",
     1418            activity.callObjectMethod("getPackageName",
     1419            "()Ljava/lang/String;").object()  );
     1420
     1421    auto pendingIntent = QAndroidJniObject::callStaticObjectMethod
     1422        (   "android/app/PendingIntent",
     1423            "getActivity",
     1424            "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;",
     1425            activity.object(),
     1426            jint(0),
     1427            activityIntent.object(),
     1428            QAndroidJniObject::getStaticField<jint>("android/content/Intent",
     1429            "FLAG_ACTIVITY_CLEAR_TOP")  );
     1430
     1431    auto alarmManager = activity.callObjectMethod
     1432        (   "getSystemService",
     1433            "(Ljava/lang/String;)Ljava/lang/Object;",
     1434            QAndroidJniObject::getStaticObjectField("android/content/Context",
     1435            "ALARM_SERVICE",
     1436            "Ljava/lang/String;").object()  );
     1437
     1438    alarmManager.callMethod<void>
     1439        (   "set",
     1440            "(IJLandroid/app/PendingIntent;)V",
     1441            QAndroidJniObject::getStaticField<jint>("android/app/AlarmManager", "RTC"),
     1442            jlong(QDateTime::currentMSecsSinceEpoch() + 100),
     1443            pendingIntent.object()  );
     1444
     1445    qApp->quit();
     1446    // QString title = QObject::tr("Your change will take effect the next time "
     1447    //                     "mythfrontend is started.");
     1448    //     MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");    MythConfirmationDialog *okPopup =
     1449    //         new MythConfirmationDialog(popupStack, title, false);
     1450    // if (okPopup->Create())
     1451    //     popupStack->AddScreen(okPopup);
     1452    return 0;
     1453#else
     1454
    13991455    QString themename = gCoreContext->GetSetting("Theme", DEFAULT_UI_THEME);
    14001456    QString themedir = GetMythUI()->FindThemeDir(themename);
    14011457    if (themedir.isEmpty())
    static int reloadTheme(void) 
    14371493    }
    14381494
    14391495    return 0;
     1496#endif // Q_OS_ANDROID else
    14401497}
    14411498
    14421499static void reloadTheme_void(void)