Added reset button to exposure settings
[harmattan/cameraplus] / lib / qtcamautofocus_p.h
index 159c0a6..a833a9f 100644 (file)
@@ -3,7 +3,7 @@
 /*!
  * This file is part of CameraPlus.
  *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,7 @@
 #include "qtcamgstreamermessagelistener.h"
 #include "qtcamdevice.h"
 #include "qtcamdevice_p.h"
-
+#include <QPointer>
 #include <QDebug>
 
 #ifndef GST_USE_UNSTABLE_API
@@ -63,8 +63,11 @@ public:
   }
 
   ~QtCamAutoFocusPrivate() {
-    dev->listener()->removeHandler(handler);
-    delete handler; handler = 0;
+    if (dev && dev->listener()) {
+      dev->listener()->removeHandler(handler);
+      delete handler; handler = 0;
+    }
+
     dev = 0;
     q_ptr = 0;
   }
@@ -100,7 +103,6 @@ public:
   bool setStatus(QtCamAutoFocus::Status *status, GstMessage *message) {
     const GstStructure *s = gst_message_get_structure(message);
     int st = GST_PHOTOGRAPHY_FOCUS_STATUS_NONE;
-
     if (gst_structure_get_int(s, "status", &st)) {
       if (*status != st) {
        *status = (QtCamAutoFocus::Status) st;
@@ -114,7 +116,6 @@ public:
 public slots:
   void handleMessage(GstMessage *message) {
     if (setStatus(&status, message)) {
-      // TODO: focus-window-rows, focus-window-columns, focus-windows and the rest
       emit q_ptr->statusChanged();
     }
   }
@@ -126,7 +127,7 @@ public slots:
   }
 
 public:
-  QtCamDevice *dev;
+  QPointer<QtCamDevice> dev;
   QtCamAutoFocus *q_ptr;
 
   QtCamAutoFocus::Status status;