Ticket #1915: 1915.patch

File 1915.patch, 7.6 KB (added by danielk, 15 years ago)

possible fix

  • libs/libmythtv/videoout_xv.cpp

     
    982982    (void)stream_type, (void)xvmc_chroma, (void)test_surface;
    983983
    984984#ifdef USING_XVMC
    985     Display *disp;
    986     X11S(disp = XOpenDisplay(NULL));
     985    Display *disp = MythXOpenDisplay();
    987986
    988987    // Disable features based on environment and DB values.
    989988    bool use_xvmc_vld = false, use_xvmc_idct = false, use_xvmc = false;
     
    11851184
    11861185    XV_INIT_FATAL_ERROR_TEST(winid <= 0, "Invalid Window ID.");
    11871186
    1188     X11S(XJ_disp = XOpenDisplay(NULL));
     1187    XJ_disp = MythXOpenDisplay();
    11891188    XV_INIT_FATAL_ERROR_TEST(!XJ_disp, "Failed to open display.");
    11901189
    11911190    // Initialize X stuff
  • libs/libmythtv/XvMCSurfaceTypes.cpp

     
    55
    66static inline Display* createXvMCDisplay()
    77{
    8     Display *disp = NULL;
    9     X11S(disp = XOpenDisplay(NULL));
     8    Display *disp = MythXOpenDisplay();
    109    if (!disp)
    11     {
    12         VERBOSE(VB_IMPORTANT, "XOpenDisplay failed");
    13         return 0;
    14     }
     10        return NULL;
    1511
    1612    unsigned int p_version, p_release, p_request_base, p_event_base,
    1713                 p_error_base;
  • libs/libmyth/mythcontext.h

     
    222222
    223223/// Update this whenever the plug-in API changes.
    224224/// Including changes in the libmythtv class methods used by plug-ins.
    225 #define MYTH_BINARY_VERSION "0.19.20060614-1"
     225#define MYTH_BINARY_VERSION "0.19.20060619-1"
    226226
    227227/** \brief Increment this whenever the MythTV network protocol changes.
    228228 *
     
    412412    QString removeCurrentLocation(void);
    413413    QString getCurrentLocation(void);
    414414
     415    void SetX11Display(const QString &display);
     416    QString GetX11Display(void) const;
     417
    415418    static QMutex verbose_mutex;
    416419
    417420  private:
  • libs/libmyth/util-x11.cpp

     
    3434    int nr_xinerama_screens = 0;
    3535
    3636#ifdef Q_WS_X11
     37    Display *d = MythXOpenDisplay();
    3738    X11L;
    38     Display *d = XOpenDisplay(NULL);
    3939    int event_base = 0, error_base = 0;
    4040    if (XineramaQueryExtension(d, &event_base, &error_base) &&
    4141        XineramaIsActive(d))
     
    5151    return nr_xinerama_screens;
    5252}
    5353
     54Display *MythXOpenDisplay(void)
     55{
     56#ifdef Q_WS_X11
     57    QString dispStr = gContext->GetX11Display();
     58    const char *dispCStr = NULL;
     59    if (!dispStr.isEmpty())
     60        dispCStr = dispStr.ascii();
     61
     62    X11L;
     63    Display *disp = XOpenDisplay(dispCStr);
     64    X11U;
     65
     66    if (!disp)
     67        VERBOSE(VB_IMPORTANT, "MythXOpenDisplay() failed");
     68
     69    return disp;
     70#else
     71    return NULL;
     72#endif
     73}
     74
    5475// Everything below this line is only compiled if using X11
    5576
    5677#ifdef Q_WS_X11
  • libs/libmyth/util-x11.h

     
    1010#include <X11/Xlib.h>
    1111#include <vector>
    1212
     13Display *MythXOpenDisplay(void);
    1314int XJ_error_catcher(Display * d, XErrorEvent * xeev);
    1415void InstallXErrorHandler(Display *d);
    1516void PrintXErrors(Display *d, const std::vector<XErrorEvent>& events);
  • libs/libmyth/DisplayResX.cpp

     
    1212#include <X11/extensions/Xrandr.h>
    1313}
    1414
    15 
    1615#include "util-x11.h"
    1716
    1817using namespace X11;
    1918
     19Display *MythXOpenDisplay(void);
    2020static XRRScreenConfiguration *GetScreenConfig(Display*& display);
    2121
    2222DisplayResX::DisplayResX(void)
     
    3030
    3131bool DisplayResX::GetDisplaySize(int &width_mm, int &height_mm) const
    3232{
    33     Display *display = NULL;
    34     X11S(display = XOpenDisplay(NULL));
     33    Display *display = MythXOpenDisplay();
    3534    if (display == NULL)
    3635        return false;
    3736
     
    113112
    114113static XRRScreenConfiguration *GetScreenConfig(Display*& display)
    115114{
    116     X11S(display = XOpenDisplay(NULL));
     115    display = MythXOpenDisplay();
    117116    if (!display)
    118117    {
    119         cerr<<"DisplaResX: Unable to XOpenDisplay"<<endl;
     118        cerr<<"DisplaResX: MythXOpenDisplay call failed"<<endl;
    120119        return NULL;
    121120    }
    122121
  • libs/libmyth/mythcontext.cpp

     
    218218
    219219    MythMainWindow *mainWindow;
    220220
     221    QString m_x11_display;
     222
    221223    float m_wmult, m_hmult;
    222224
    223225    // The part of the screen(s) allocated for the GUI. Unless
     
    276278      attemptingToConnect(false),
    277279      language(""),
    278280      mainWindow(NULL),
     281      m_x11_display(QString::null),
    279282      m_wmult(1.0), m_hmult(1.0),
    280283      m_screenxbase(0), m_screenybase(0), m_screenwidth(0), m_screenheight(0),
    281284      m_geometry_x(0), m_geometry_y(0), m_geometry_w(0), m_geometry_h(0),
     
    28812884    return d->screensaver->Asleep();
    28822885}
    28832886
     2887void MythContext::SetX11Display(const QString &display)
     2888{
     2889    d->m_x11_display = QDeepCopy<QString>(display);
     2890}
     2891
     2892QString MythContext::GetX11Display(void) const
     2893{
     2894    return QDeepCopy<QString>(d->m_x11_display);
     2895}
     2896
    28842897/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • programs/mythfrontend/main.cpp

     
    746746int main(int argc, char **argv)
    747747{
    748748    QString geometry = "";
     749    QString display  = QString::null;
    749750#ifdef Q_WS_X11
    750     // Remember any -geometry argument which QApplication init will remove
     751    // Remember any -display or -geometry argument
     752    // which QApplication init will remove.
    751753    for(int argpos = 1; argpos + 1 < argc; ++argpos)
     754    {
    752755        if (!strcmp(argv[argpos],"-geometry"))
    753756            geometry = argv[argpos+1];
     757        else if (!strcmp(argv[argpos],"-display"))
     758            display = argv[argpos+1];
     759    }
    754760#endif
    755761
    756762#ifdef Q_WS_MACX
     
    870876
    871877            ++argpos;
    872878        }
     879        else if (!strcmp(a.argv()[argpos],"-display") ||
     880                 !strcmp(a.argv()[argpos],"--display"))
     881        {
     882            if (a.argc()-1 > argpos)
     883            {
     884                display = a.argv()[argpos+1];
     885                if (display.startsWith("-"))
     886                {
     887                    cerr << "Invalid or missing argument to -display option\n";
     888                    return FRONTEND_EXIT_INVALID_CMDLINE;
     889                }
     890                else
     891                    ++argpos;
     892            }
     893            else
     894            {
     895                cerr << "Missing argument to -display option\n";
     896                return FRONTEND_EXIT_INVALID_CMDLINE;
     897            }
     898        }
    873899        else if (!strcmp(a.argv()[argpos],"-geometry") ||
    874900                 !strcmp(a.argv()[argpos],"--geometry"))
    875901        {
     
    9801006       return FRONTEND_EXIT_OK;
    9811007    }
    9821008
     1009    if (!display.isEmpty())
     1010    {
     1011        gContext->SetX11Display(display);
     1012    }
     1013
    9831014    if (geometry != "" && !gContext->ParseGeometryOverride(geometry))
    9841015    {
    9851016        VERBOSE(VB_IMPORTANT,