Skip to content

Commit

Permalink
MythDRMDevice: Guard against invalid devices
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-kendall committed Feb 12, 2020
1 parent 7512851 commit 5157ed0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mythtv/libs/libmythui/platforms/mythdisplaydrm.cpp
Expand Up @@ -8,6 +8,11 @@ MythDisplayDRM::MythDisplayDRM()
: MythDisplay()
{
m_device = new MythDRMDevice(m_screen);
if (!m_device->IsValid())
{
delete m_device;
m_device = nullptr;
}
Initialise();
}

Expand All @@ -27,7 +32,14 @@ void MythDisplayDRM::ScreenChanged(QScreen *qScreen)
}

if (!m_device)
{
m_device = new MythDRMDevice(m_screen);
if (!m_device->IsValid())
{
delete m_device;
m_device = nullptr;
}
}
}

void MythDisplayDRM::UpdateCurrentMode(void)
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmythui/platforms/mythdrmdevice.cpp
Expand Up @@ -26,6 +26,7 @@ MythDRMDevice::MythDRMDevice(QScreen *qScreen, const QString& Device)
return;
}

m_valid = true;
Authenticate();
if (m_authenticated)
LOG(VB_GENERAL, m_verbose, LOC + "Authenticated");
Expand Down Expand Up @@ -76,6 +77,11 @@ void MythDRMDevice::Close(void)
m_fd = 0;
}

bool MythDRMDevice::IsValid(void) const
{
return m_valid;
}

QString MythDRMDevice::GetSerialNumber(void) const
{
return m_serialNumber;
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythui/platforms/mythdrmdevice.h
Expand Up @@ -21,6 +21,7 @@ class MythDRMDevice : public ReferenceCounter
explicit MythDRMDevice(QScreen *qScreen, const QString& Device = QString());
~MythDRMDevice() override;

bool IsValid (void) const;
QString GetSerialNumber(void) const;
QScreen* GetScreen (void) const;
QSize GetResolution (void) const;
Expand All @@ -42,6 +43,7 @@ class MythDRMDevice : public ReferenceCounter
drmModePropertyBlobPtr GetBlobProperty(drmModeConnectorPtr Connector, const QString& Property);

private:
bool m_valid { false };
QScreen* m_screen { nullptr };
QString m_deviceName { };
int m_fd { -1 };
Expand Down

0 comments on commit 5157ed0

Please sign in to comment.