Committing modified version of jwiesemann's patch (see #11223):

Fix wxURL copy ctor and assignment: the default ones provided by the compiler are wrong because wxURL uses pointers internally. 
Also add a test for copy & assignment in URLTestCase.

Closes #11223

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2010-03-30 21:38:31 +00:00
parent 38442edb48
commit 00e075e551
3 changed files with 97 additions and 14 deletions

View File

@@ -65,9 +65,15 @@ wxURL::wxURL(const wxString& url) : wxURI(url)
ParseURL();
}
wxURL::wxURL(const wxURI& url) : wxURI(url)
wxURL::wxURL(const wxURI& uri) : wxURI(uri)
{
Init(url.BuildURI());
Init(uri.BuildURI());
ParseURL();
}
wxURL::wxURL(const wxURL& url) : wxURI(url)
{
Init(url.GetURL());
ParseURL();
}
@@ -102,18 +108,39 @@ void wxURL::Init(const wxString& url)
// Assignment
// --------------------------------------------------------------
wxURL& wxURL::operator = (const wxURI& url)
{
wxURI::operator = (url);
Init(url.BuildURI());
ParseURL();
return *this;
}
wxURL& wxURL::operator = (const wxString& url)
{
wxURI::operator = (url);
Free();
Init(url);
ParseURL();
return *this;
}
wxURL& wxURL::operator = (const wxURI& uri)
{
if (&uri != this)
{
wxURI::operator = (uri);
Free();
Init(uri.BuildURI());
ParseURL();
}
return *this;
}
wxURL& wxURL::operator = (const wxURL& url)
{
if (&url != this)
{
wxURI::operator = (url);
Free();
Init(url.GetURL());
ParseURL();
}
return *this;
}
@@ -195,7 +222,7 @@ void wxURL::CleanData()
}
}
wxURL::~wxURL()
void wxURL::Free()
{
CleanData();
#if wxUSE_PROTOCOL_HTTP
@@ -207,6 +234,11 @@ wxURL::~wxURL()
#endif
}
wxURL::~wxURL()
{
Free();
}
// --------------------------------------------------------------
// FetchProtocol
// --------------------------------------------------------------