From 799e8861bbfe63981b49e299eeb585424f86d98c Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 30 Dec 2014 23:28:07 +0100 Subject: 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. --- libmpv/qthelper.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libmpv/qthelper.hpp') 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 #include @@ -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 -- cgit v1.2.3