diff --git a/include/wx/secretstore.h b/include/wx/secretstore.h index ba7dc64422..26e49bd342 100644 --- a/include/wx/secretstore.h +++ b/include/wx/secretstore.h @@ -30,7 +30,10 @@ public: wxSecretValue() : m_impl(NULL) { } // Creates a secret value from the given data. - wxSecretValue(size_t size, const void *data); + wxSecretValue(size_t size, const void *data) + : m_impl(NewImpl(size, data)) + { + } wxSecretValue(const wxSecretValue& other); wxSecretValue& operator=(const wxSecretValue& other); @@ -60,6 +63,10 @@ public: static void Wipe(size_t size, void *data); private: + // This method is implemented in platform-specific code and must return a + // new heap-allocated object initialized with the given data. + static wxSecretValueImpl* NewImpl(size_t size, const void *data); + // This ctor is only used by wxSecretStore and takes ownership of the // provided existing impl pointer. explicit wxSecretValue(wxSecretValueImpl* impl) : m_impl(impl) { } diff --git a/src/msw/secretstore.cpp b/src/msw/secretstore.cpp index 9898473fa1..6ce67aa4d1 100644 --- a/src/msw/secretstore.cpp +++ b/src/msw/secretstore.cpp @@ -155,9 +155,10 @@ private: // MSW-specific implementation of common methods // ============================================================================ -wxSecretValue::wxSecretValue(size_t size, const void *data) - : m_impl(new wxSecretValueGenericImpl(size, data)) +/* static */ +wxSecretValueImpl* wxSecretValue::NewImpl(size_t size, const void *data) { + return new wxSecretValueGenericImpl(size, data); } /* static */ diff --git a/src/osx/core/secretstore.cpp b/src/osx/core/secretstore.cpp index 7a3a373b81..d4b885a6a1 100644 --- a/src/osx/core/secretstore.cpp +++ b/src/osx/core/secretstore.cpp @@ -231,9 +231,10 @@ private: // OSX-specific implementation of common methods // ============================================================================ -wxSecretValue::wxSecretValue(size_t size, const void *data) - : m_impl(new wxSecretValueGenericImpl(size, data)) +/* static */ +wxSecretValueImpl* wxSecretValue::NewImpl(size_t size, const void *data) { + return new wxSecretValueGenericImpl(size, data); } /* static */ diff --git a/src/unix/secretstore.cpp b/src/unix/secretstore.cpp index 5a2f260bb9..0aba702c10 100644 --- a/src/unix/secretstore.cpp +++ b/src/unix/secretstore.cpp @@ -251,9 +251,10 @@ const char* wxSecretStoreLibSecretImpl::FIELD_USER = "user"; // LibSecret-specific implementation of common methods // ============================================================================ -wxSecretValue::wxSecretValue(size_t size, const void *data) - : m_impl(new wxSecretValueLibSecretImpl(size, data)) +/* static */ +wxSecretValueImpl* wxSecretValue::NewImpl(size_t size, const void *data) { + return new wxSecretValueLibSecretImpl(size, data); } /* static */