Ticket #8641: 8641-v2.patch

File 8641-v2.patch, 11.8 KB (added by danielk, 9 years ago)
  • libs/libmythtv/tv_play.cpp

     
    10371037    player.push_back(new PlayerContext(kPlayerInUseID));
    10381038    playerActive = 0;
    10391039    playerLock.unlock();
     1040
     1041    GetMythMainWindow()->PushDrawDisabled(__FILE__, __LINE__);
     1042
    10401043    VERBOSE(VB_PLAYBACK, LOC + "ctor -- end");
    10411044}
    10421045
     
    11691172
    11701173    gCoreContext->removeListener(this);
    11711174
    1172     GetMythMainWindow()->SetDrawEnabled(true);
     1175    GetMythMainWindow()->PopDrawDisabled(__FILE__, __LINE__);
    11731176
    11741177    if (myWindow)
    11751178    {
     
    19571960        VERBOSE(VB_IMPORTANT, "We have a RingBuffer");
    19581961
    19591962        GetMythUI()->DisableScreensaver();
    1960         GetMythMainWindow()->SetDrawEnabled(false);
     1963        //GetMythMainWindow()->PushDrawDisabled(__FILE__, __LINE__);
    19611964
    19621965        if (ctx->playingInfo && StartRecorder(ctx,-1))
    19631966        {
     
    20232026
    20242027        if (ctx->buffer && ctx->buffer->IsOpen())
    20252028        {
    2026             GetMythMainWindow()->SetDrawEnabled(false);
     2029            //GetMythMainWindow()->PushDrawDisabled(__FILE__, __LINE__);
    20272030            GetMythUI()->DisableScreensaver();
    20282031
    20292032            if (desiredNextState == kState_WatchingRecording)
     
    77577760        }
    77587761    }
    77597762
    7760     //we are embedding in a mythui window so show the gui paint window again
    7761     GetMythMainWindow()->SetDrawEnabled(true);
     7763    // We are embedding in a mythui window so show the gui paint window again
     7764    GetMythMainWindow()->PopDrawDisabled(__FILE__, __LINE__);
    77627765    GetMythMainWindow()->GetPaintWindow()->show();
    77637766}
    77647767
     
    84378440    if (message.left(11) == "EPG_EXITING" ||
    84388441        message.left(18) == "PROGFINDER_EXITING" ||
    84398442        message.left(21) == "VIEWSCHEDULED_EXITING" ||
    8440         message.left(19)   == "PLAYBACKBOX_EXITING" ||
     8443        message.left(19) == "PLAYBACKBOX_EXITING" ||
    84418444        message.left(22) == "SCHEDULEEDITOR_EXITING")
    84428445    {
    8443         GetMythMainWindow()->SetDrawEnabled(false);
     8446        GetMythMainWindow()->PushDrawDisabled(__FILE__, __LINE__);
    84448447        // Resize the window back to the MythTV Player size
    84458448        PlayerContext *actx = GetPlayerReadLock(-1, __FILE__, __LINE__);
    84468449        PlayerContext *mctx;
  • libs/libmythtv/videoout_xv.cpp

     
    25632563
    25642564void VideoOutputXv::DrawUnusedRects(bool sync)
    25652565{
     2566    VERBOSE(VB_IMPORTANT, "VideoOutputXv::DrawUnusedRects()");
     2567
    25662568    // boboff assumes the smallest interlaced resolution is 480 lines - 5%
    25672569    bool use_bob   = (m_deinterlacing && m_deintfiltername == "bobdeint");
    25682570    const QRect display_visible_rect = windows[0].GetDisplayVisibleRect();
  • libs/libmythui/mythmainwindow.cpp

     
    1515#include <QGLWidget>
    1616#endif
    1717
     18#include <QWaitCondition>
    1819#include <QApplication>
    1920#include <QTimer>
    2021#include <QDesktopWidget>
     
    7576
    7677#define GESTURE_TIMEOUT 1000
    7778
     79#define LOC      QString("MythMainWindow: ")
     80#define LOC_WARN QString("MythMainWindow, Warning: ")
     81#define LOC_ERR  QString("MythMainWindow, Error: ")
     82
    7883class KeyContext
    7984{
    8085  public:
     
    113118class MythMainWindowPrivate
    114119{
    115120  public:
     121    MythMainWindowPrivate() :
     122        wmult(1.0f), hmult(1.0f),
     123        screenwidth(0), screenheight(0),
     124        xbase(0), ybase(0),
     125        does_fill_screen(false),
     126        ignore_lirc_keys(false),
     127        ignore_joystick_keys(false),
     128        lircThread(NULL),
     129#ifdef USE_JOYSTICK_MENU
     130        joystickThread(NULL),
     131#endif
     132
     133#ifdef USING_APPLEREMOTE
     134        appleRemoteListener(NULL),
     135        appleRemote(NULL),
     136#endif
     137        exitingtomain(false),
     138        popwindows(false),
     139
     140        m_useDB(true),
     141
     142        exitmenucallback(NULL),
     143
     144        exitmenumediadevicecallback(NULL),
     145        mediadeviceforcallback(NULL),
     146
     147        escapekey(0),
     148
     149        sysEventHandler(NULL),
     150
     151        drawTimer(NULL),
     152        mainStack(NULL),
     153
     154        painter(NULL),
     155
     156#ifdef USE_OPENGL_PAINTER
     157        render(NULL),
     158#endif
     159
     160        AllowInput(true),
     161
     162        gestureTimer(NULL),
     163
     164        paintwin(NULL),
     165
     166        oldpaintwin(NULL),
     167        oldpainter(NULL),
     168
     169        m_drawDisabledDepth(0),
     170        m_drawEnabled(true)
     171    {
     172    }
     173
    116174    int TranslateKeyNum(QKeyEvent *e);
    117175
    118176    float wmult, hmult;
     
    182240    QWidget *oldpaintwin;
    183241    MythPainter *oldpainter;
    184242
    185     volatile bool m_drawEnabled;
     243    QMutex m_drawDisableLock;
     244    QMutex m_setDrawEnabledLock;
     245    QWaitCondition m_setDrawEnabledWait;
     246    uint m_drawDisabledDepth;
     247    bool m_drawEnabled;
    186248};
    187249
    188250// Make keynum in QKeyEvent be equivalent to what's in QKeySequence
     
    11141176}
    11151177/* FIXME: end compatibility */
    11161178
     1179uint MythMainWindow::PushDrawDisabled(const char *file, int line)
     1180{
     1181    QMutexLocker locker(&d->m_drawDisableLock);
     1182    VERBOSE(VB_IMPORTANT, QString("PushDrawDisabled(%1@%2) -- begin")
     1183            .arg(file).arg(line));
     1184    d->m_drawDisabledDepth++;
     1185    if (d->m_drawDisabledDepth && d->m_drawEnabled)
     1186        SetDrawEnabled(false);
     1187    VERBOSE(VB_IMPORTANT, QString("PushDrawDisabled(%1@%2) -- end")
     1188            .arg(file).arg(line));
     1189    return d->m_drawDisabledDepth;
     1190}
     1191
     1192uint MythMainWindow::PopDrawDisabled(const char *file, int line)
     1193{
     1194    QMutexLocker locker(&d->m_drawDisableLock);
     1195    VERBOSE(VB_IMPORTANT, QString("PopDrawDisabled(%1@%2) -- begin")
     1196            .arg(file).arg(line));
     1197    if (d->m_drawDisabledDepth)
     1198    {
     1199        d->m_drawDisabledDepth--;
     1200        if (!d->m_drawDisabledDepth && !d->m_drawEnabled)
     1201            SetDrawEnabled(true);
     1202    }
     1203    VERBOSE(VB_IMPORTANT, QString("PopDrawDisabled(%1@%2) -- end")
     1204            .arg(file).arg(line));
     1205    return d->m_drawDisabledDepth;
     1206}
     1207
    11171208void MythMainWindow::SetDrawEnabled(bool enable)
    11181209{
     1210    QMutexLocker locker(&d->m_setDrawEnabledLock);
     1211
     1212    if (!gCoreContext->IsUIThread())
     1213    {
     1214        VERBOSE(VB_IMPORTANT, LOC + QString("SetDrawEnabled(%1) -- outside UI")
     1215                .arg(enable));
     1216
     1217        QCoreApplication::postEvent(
     1218            this, new MythEvent(
     1219                (enable) ?
     1220                MythEvent::kSetDrawEnabledEventType :
     1221                MythEvent::kSetDrawDisabledEventType));
     1222
     1223        VERBOSE(VB_IMPORTANT, LOC + QString("SetDrawEnabled(%1) -- waiting")
     1224                .arg(enable));
     1225
     1226        while (QCoreApplication::hasPendingEvents())
     1227            d->m_setDrawEnabledWait.wait(&d->m_setDrawEnabledLock);
     1228
     1229        VERBOSE(VB_IMPORTANT, LOC + QString("SetDrawEnabled(%1) -- done")
     1230                .arg(enable));
     1231
     1232        return;
     1233    }
     1234
     1235    static uint ecnt = 0, dcnt = 0;
     1236    ecnt += enable ? 1 : 0;
     1237    dcnt += enable ? 0 : 1;
     1238
     1239    VERBOSE(VB_IMPORTANT, LOC + QString("SetDrawEnabled(%1) cnt %2")
     1240            .arg(enable).arg(enable?ecnt:dcnt));
     1241
    11191242    setUpdatesEnabled(enable);
    11201243    d->m_drawEnabled = enable;
    11211244
     
    11231246        d->drawTimer->start(1000 / 70);
    11241247    else
    11251248        d->drawTimer->stop();
     1249
     1250    d->m_setDrawEnabledWait.wakeAll();
    11261251}
    11271252
    11281253void MythMainWindow::SetEffectsEnabled(bool enable)
     
    19262051            }
    19272052        }
    19282053    }
    1929     else if (ce->type() == MythEvent::kDisableDrawingEventType)
     2054    else if (ce->type() == MythEvent::kPushDisableDrawingEventType)
    19302055    {
    1931         SetDrawEnabled(false);
     2056        PushDrawDisabled(__FILE__, __LINE__);
    19322057    }
    1933     else if (ce->type() == MythEvent::kEnableDrawingEventType)
     2058    else if (ce->type() == MythEvent::kPopDisableDrawingEventType)
    19342059    {
     2060        PopDrawDisabled(__FILE__, __LINE__);
     2061    }
     2062    else if (ce->type() == MythEvent::kSetDrawEnabledEventType)
     2063    {
     2064        VERBOSE(VB_IMPORTANT, LOC + "kSetDrawEnabledEvent");
    19352065        SetDrawEnabled(true);
    19362066    }
     2067    else if (ce->type() == MythEvent::kSetDrawDisabledEventType)
     2068    {
     2069        VERBOSE(VB_IMPORTANT, LOC + "kSetDrawDisabledEvent");
     2070        SetDrawEnabled(false);
     2071    }
    19372072    else if ((MythEvent::Type)(ce->type()) == MythEvent::MythEventMessage)
    19382073    {
    19392074        MythEvent *me = (MythEvent *)ce;
  • libs/libmythui/mythmainwindow.h

     
    113113
    114114    QWidget *currentWidget(void);
    115115
    116     void SetDrawEnabled(bool enable);
     116    uint PushDrawDisabled(const char *file, int line);
     117    uint PopDrawDisabled(const char *file, int line);
    117118    void SetEffectsEnabled(bool enable);
    118119
    119120  public slots:
     
    140141
    141142    QObject *getTarget(QKeyEvent &key);
    142143
     144    void SetDrawEnabled(bool enable);
     145
    143146    MythMainWindowPrivate *d;
    144147};
    145148
  • libs/libmyth/util.cpp

     
    12771277#endif
    12781278    bool res = myth_system(command,
    12791279                           MYTH_SYSTEM_DONT_BLOCK_LIRC |
    1280                            MYTH_SYSTEM_DONT_BLOCK_JOYSTICK_MENU |
    1281                            MYTH_SYSTEM_DONT_BLOCK_PARENT);
     1280                           MYTH_SYSTEM_DONT_BLOCK_JOYSTICK_MENU);
    12821281    return !res;
    12831282}
    12841283
  • libs/libmythdb/mythsystem.cpp

     
    8080    // since this function could be called inside one of those events.
    8181    if (ready_to_lock && !(flags & MYTH_SYSTEM_DONT_BLOCK_PARENT))
    8282    {
    83         QEvent event(MythEvent::kDisableDrawingEventType);
     83        QEvent event(MythEvent::kPushDisableDrawingEventType);
    8484        QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event);
    8585    }
    8686
     
    216216    // since this function could be called inside one of those events.
    217217    if (ready_to_lock && !(flags & MYTH_SYSTEM_DONT_BLOCK_PARENT))
    218218    {
    219         QEvent event(MythEvent::kEnableDrawingEventType);
     219        QEvent event(MythEvent::kPopDisableDrawingEventType);
    220220        QCoreApplication::sendEvent(gCoreContext->GetGUIObject(), &event);
    221221    }
    222222
  • libs/libmythdb/mythevent.h

     
    5252    static Type MythEventMessage;
    5353    static Type kExitToMainMenuEventType;
    5454    static Type kMythPostShowEventType;
    55     static Type kDisableDrawingEventType;
    56     static Type kEnableDrawingEventType;
     55    static Type kPushDisableDrawingEventType;
     56    static Type kPopDisableDrawingEventType;
     57    static Type kSetDrawEnabledEventType;
     58    static Type kSetDrawDisabledEventType;
    5759
    5860  private:
    5961    QString message;
  • libs/libmythdb/mythevent.cpp

     
    66    (QEvent::Type) QEvent::registerEventType();
    77QEvent::Type MythEvent::kMythPostShowEventType =
    88    (QEvent::Type) QEvent::registerEventType();
    9 QEvent::Type MythEvent::kDisableDrawingEventType =
     9QEvent::Type MythEvent::kPushDisableDrawingEventType =
    1010    (QEvent::Type) QEvent::registerEventType();
    11 QEvent::Type MythEvent::kEnableDrawingEventType =
     11QEvent::Type MythEvent::kPopDisableDrawingEventType =
    1212    (QEvent::Type) QEvent::registerEventType();
     13QEvent::Type MythEvent::kSetDrawEnabledEventType =
     14    (QEvent::Type) QEvent::registerEventType();
     15QEvent::Type MythEvent::kSetDrawDisabledEventType =
     16    (QEvent::Type) QEvent::registerEventType();
    1317QEvent::Type ExternalKeycodeEvent::kEventType =
    1418    (QEvent::Type) QEvent::registerEventType();