Using stat before open can be dangerous. Better to

From: Erik Hovland <erik@hovland.org>

do it the other way around.
---

 mythplugins/mythvideo/mtd/dvdprobe.cpp |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/mythplugins/mythvideo/mtd/dvdprobe.cpp b/mythplugins/mythvideo/mtd/dvdprobe.cpp
index 2a999a4..6a06287 100644
--- a/mythplugins/mythvideo/mtd/dvdprobe.cpp
+++ b/mythplugins/mythvideo/mtd/dvdprobe.cpp
@@ -19,6 +19,8 @@
 #include <cmath>
 #include <climits> // for CDSL_CURRENT which is currently INT_MAX
 
+#include <QFile>
+
 #include "dvdprobe.h"
 
 #include <mythtv/mythcontext.h>
@@ -414,15 +416,13 @@ bool DVDProbe::probe()
     //  a drive with media in it
     //
 
-    struct stat fileinfo;
+    QFile dvdDevice((device.toAscii()).constData());
 
-    QByteArray dev = device.toAscii();
-    int ret = stat(dev.constData(), &fileinfo);
-    if (ret < 0)
+    if (!dvdDevice.exists() && !dvdDevice.open(QIODevice::ReadOnly))
     {
         //
-        //  Can't even stat the device, it probably
-        //  doesn't exist. Silly user
+        //  Device doesn't exists or can't be opened. The probe can't
+        //  continue.
         //
         wipeClean();
         return false;
@@ -435,7 +435,7 @@ bool DVDProbe::probe()
     //  this, but it seems to work.
     //
 
-    int drive_handle = open(dev.constData(), O_RDONLY | O_NONBLOCK);
+    int drive_handle = dvdDevice.handle();
 
     if (drive_handle == -1)
     {
@@ -461,13 +461,11 @@ bool DVDProbe::probe()
         //  3 = not ready
         //
         wipeClean();
-        close(drive_handle);
         return false;
 
     }
 
     status = ioctl(drive_handle, CDROM_MEDIA_CHANGED, NULL);
-    close(drive_handle);
 
     if (!status)
     {
@@ -493,9 +491,10 @@ bool DVDProbe::probe()
     //  could be a path, file, whatever).
     //
 
+    dvdDevice.close();
     wipeClean();
     first_time = false;
-    dvd = DVDOpen(dev.constData());
+    dvd = DVDOpen(dvdDevice.fileName());
     if (dvd)
     {
         //
