projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
018a48e
)
Add reset() to wx_ptr and allow it to be null.
author
Carl Hetherington
<cth@carlh.net>
Sat, 14 Jan 2023 21:50:09 +0000
(22:50 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Sat, 14 Jan 2023 21:50:09 +0000
(22:50 +0100)
src/wx/wx_ptr.h
patch
|
blob
|
history
diff --git
a/src/wx/wx_ptr.h
b/src/wx/wx_ptr.h
index de18846cc77f4ba7b69fa41be30a30352ee34fbe..7eff673a4e0d16e42519dec8b15b7d30f0f3e92c 100644
(file)
--- a/
src/wx/wx_ptr.h
+++ b/
src/wx/wx_ptr.h
@@
-23,6
+23,7
@@
#define DCPOMATIC_WX_PTR_H
+#include "lib/dcpomatic_assert.h"
#include <utility>
@@
-30,6
+31,8
@@
template <class T>
class wx_ptr
{
public:
+ wx_ptr() {}
+
explicit wx_ptr(T* wx)
: _wx(wx)
{}
@@
-60,11
+63,21
@@
public:
}
T* operator->() {
+ DCPOMATIC_ASSERT(_wx);
return _wx;
}
+ template <typename... Args>
+ void reset(Args... args)
+ {
+ if (_wx) {
+ _wx->Destroy();
+ }
+ _wx = new T(std::forward<Args>(args)...);
+ }
+
private:
- T* _wx;
+ T* _wx
= nullptr
;
};