summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-30 23:28:07 +0100
committerwm4 <wm4@nowhere>2014-12-30 23:28:07 +0100
commit799e8861bbfe63981b49e299eeb585424f86d98c (patch)
treef4136a1b6a5f475e3392fc40d0d627c3b343a314
parent628f1dcb42e31669a89f7e934ea134a44006c201 (diff)
downloadmpv-799e8861bbfe63981b49e299eeb585424f86d98c.tar.bz2
mpv-799e8861bbfe63981b49e299eeb585424f86d98c.tar.xz
client API: qthelper: return NULL as handle if unset
Creating a plain Handle() should yield a NULL mpv_handle. Also, remove the redundant non-const definition of the conversion operator. At least in this situation it's not needed. Also, add include guards around qthelper.hpp.
-rw-r--r--libmpv/qthelper.hpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libmpv/qthelper.hpp b/libmpv/qthelper.hpp
index c36a7d7924..c25315f3b4 100644
--- a/libmpv/qthelper.hpp
+++ b/libmpv/qthelper.hpp
@@ -19,6 +19,9 @@
* for other languages.
*/
+#ifndef MPV_CLIENT_API_QTHELPER_H_
+#define MPV_CLIENT_API_QTHELPER_H_
+
#include <cstring>
#include <QVariant>
@@ -57,8 +60,7 @@ public:
}
// Return the raw handle; for use with the libmpv C API.
- operator mpv_handle*() { return (*sptr).mpv; }
- operator mpv_handle*() const { return (*sptr).mpv; }
+ operator mpv_handle*() const { return sptr ? (*sptr).mpv : 0; }
};
static inline QVariant node_to_variant(const mpv_node *node)
@@ -272,3 +274,5 @@ static inline QVariant command_variant(mpv_handle *ctx, const QVariant &args)
}
}
+
+#endif