1. removed wxObject::CopyObject() and Clone() - some objects just can't be
copied 2. made wxEvent::Clone() pure virtual and added missing Clone()s to the other event classes which this changes has helped to discover git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12566 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -179,6 +179,9 @@ public:
|
||||
// process (i.e. does it result from our own attempt to establish the
|
||||
// connection)?
|
||||
bool IsOwnEvent() const { return m_id != 0; }
|
||||
|
||||
// implement the base class pure virtual
|
||||
virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); }
|
||||
};
|
||||
|
||||
// the type of dialup event handler function
|
||||
|
@@ -359,8 +359,10 @@ public:
|
||||
// exists only for optimization purposes.
|
||||
bool IsCommandEvent() const { return m_isCommandEvent; }
|
||||
|
||||
// specialized clone function since it is done a lot
|
||||
virtual wxEvent *Clone() const { return new wxEvent(*this); }
|
||||
// this function is used to create a copy of the event polymorphically and
|
||||
// all derived classes must implement it because otherwise wxPostEvent()
|
||||
// for them wouldn't work (it needs to do a copy of the event)
|
||||
virtual wxEvent *Clone() const = 0;
|
||||
|
||||
public:
|
||||
wxObject* m_eventObject;
|
||||
|
@@ -91,6 +91,8 @@ public:
|
||||
void SetAlignment(wxLayoutAlignment align) { m_alignment = align; }
|
||||
wxLayoutAlignment GetAlignment() const { return m_alignment; }
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxQueryLayoutInfoEvent(*this); }
|
||||
|
||||
protected:
|
||||
int m_flags;
|
||||
int m_requestedLength;
|
||||
@@ -119,13 +121,17 @@ public:
|
||||
m_flags = 0;
|
||||
m_id = id;
|
||||
}
|
||||
// Read by the app
|
||||
inline void SetFlags(int flags) { m_flags = flags; }
|
||||
inline int GetFlags() const { return m_flags; }
|
||||
|
||||
// Set by the app
|
||||
inline void SetRect(const wxRect& rect) { m_rect = rect; }
|
||||
inline wxRect GetRect() const { return m_rect; }
|
||||
// Read by the app
|
||||
void SetFlags(int flags) { m_flags = flags; }
|
||||
int GetFlags() const { return m_flags; }
|
||||
|
||||
// Set by the app
|
||||
void SetRect(const wxRect& rect) { m_rect = rect; }
|
||||
wxRect GetRect() const { return m_rect; }
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxCalculateLayoutEvent(*this); }
|
||||
|
||||
protected:
|
||||
int m_flags;
|
||||
wxRect m_rect;
|
||||
|
@@ -221,8 +221,6 @@ class WXDLLEXPORT wxObject
|
||||
virtual ~wxObject(void);
|
||||
|
||||
virtual wxClassInfo *GetClassInfo(void) const { return &sm_classwxObject; }
|
||||
wxObject *Clone(void) const;
|
||||
virtual void CopyObject(wxObject& object_dest) const;
|
||||
|
||||
bool IsKindOf(wxClassInfo *info) const;
|
||||
|
||||
|
@@ -114,8 +114,12 @@ public:
|
||||
// the exit code
|
||||
int GetExitCode() { return m_exitcode; }
|
||||
|
||||
// implement the base class pure virtual
|
||||
virtual wxEvent *Clone() const { return new wxProcessEvent(*this); }
|
||||
|
||||
public:
|
||||
int m_pid, m_exitcode;
|
||||
int m_pid,
|
||||
m_exitcode;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxProcessEvent)
|
||||
};
|
||||
|
@@ -39,7 +39,9 @@ public:
|
||||
void SetAddress(GAddress *address);
|
||||
const wxSockAddress& operator =(const wxSockAddress& addr);
|
||||
|
||||
void CopyObject(wxObject& dest) const;
|
||||
// we need to be able to create copies of the addresses polymorphically (i.e.
|
||||
// wihtout knowing the exact address class)
|
||||
virtual wxSockAddress *Clone() const = 0;
|
||||
|
||||
protected:
|
||||
GAddress *m_address;
|
||||
@@ -61,7 +63,8 @@ public:
|
||||
wxString Hostname();
|
||||
unsigned short Service();
|
||||
|
||||
inline int Type() { return wxSockAddress::IPV4; }
|
||||
virtual int Type() { return wxSockAddress::IPV4; }
|
||||
virtual wxSockAddress *Clone() const { return new wxIPV4address(*this); }
|
||||
};
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
@@ -82,7 +85,8 @@ public:
|
||||
wxString Hostname() const;
|
||||
unsigned short Service() const;
|
||||
|
||||
inline int Type() { return wxSockAddress::IPV6; }
|
||||
virtual int Type() { return wxSockAddress::IPV6; }
|
||||
virtual wxSockAddress *Clone() const { return new wxIPV6address(*this); }
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -103,7 +107,8 @@ public:
|
||||
void Filename(const wxString& name);
|
||||
wxString Filename();
|
||||
|
||||
inline int Type() { return wxSockAddress::UNIX; }
|
||||
virtual int Type() { return wxSockAddress::UNIX; }
|
||||
virtual wxSockAddress *Clone() const { return new wxUNIXaddress(*this); }
|
||||
};
|
||||
#endif
|
||||
// __UNIX__
|
||||
|
@@ -167,6 +167,9 @@ public:
|
||||
// accessors
|
||||
int GetInterval() const { return m_interval; }
|
||||
|
||||
// implement the base class pure virtual
|
||||
virtual wxEvent *Clone() const { return new wxTimerEvent(*this); }
|
||||
|
||||
private:
|
||||
int m_interval;
|
||||
|
||||
|
@@ -638,7 +638,7 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event)
|
||||
if ( !m_pendingEvents )
|
||||
m_pendingEvents = new wxList;
|
||||
|
||||
wxEvent *event2 = (wxEvent *)event.Clone();
|
||||
wxEvent *event2 = event.Clone();
|
||||
|
||||
m_pendingEvents->Append(event2);
|
||||
|
||||
|
@@ -185,11 +185,11 @@ bool wxHTTP::Connect(wxSockAddress& addr, bool WXUNUSED(wait))
|
||||
{
|
||||
if (m_addr) {
|
||||
delete m_addr;
|
||||
m_addr = NULL;
|
||||
Close();
|
||||
}
|
||||
|
||||
m_addr = (wxSockAddress *) addr.Clone();
|
||||
m_addr = addr.Clone();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -99,22 +99,6 @@ bool wxObject::IsKindOf(wxClassInfo *info) const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxObject *wxObject::Clone() const
|
||||
{
|
||||
wxObject *object = GetClassInfo()->CreateObject();
|
||||
CopyObject(*object);
|
||||
return object;
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
void wxObject::CopyObject(wxObject& object_dest) const
|
||||
#else // !Debug
|
||||
void wxObject::CopyObject(wxObject& WXUNUSED(object_dest)) const
|
||||
#endif // Debug/!Debug
|
||||
{
|
||||
wxASSERT(object_dest.GetClassInfo()->IsKindOf(GetClassInfo()));
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
|
||||
void wxObject::Dump(wxSTD ostream& str)
|
||||
{
|
||||
|
@@ -72,16 +72,8 @@ const wxSockAddress& wxSockAddress::operator=(const wxSockAddress& addr)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxSockAddress::CopyObject(wxObject& dest) const
|
||||
{
|
||||
wxSockAddress *addr = (wxSockAddress *)&dest;
|
||||
|
||||
wxObject::CopyObject(dest);
|
||||
addr->SetAddress(GetAddress());
|
||||
}
|
||||
|
||||
void wxSockAddress::Clear()
|
||||
{
|
||||
{
|
||||
GAddress_destroy(m_address);
|
||||
m_address = GAddress_new();
|
||||
}
|
||||
@@ -102,7 +94,7 @@ wxIPV4address::~wxIPV4address()
|
||||
bool wxIPV4address::Hostname(const wxString& name)
|
||||
{
|
||||
// Some people are sometimes fool.
|
||||
if (name == wxT(""))
|
||||
if (name == wxT(""))
|
||||
{
|
||||
wxLogWarning( _("Trying to solve a NULL hostname: giving up") );
|
||||
return FALSE;
|
||||
@@ -147,7 +139,7 @@ wxString wxIPV4address::Hostname()
|
||||
|
||||
unsigned short wxIPV4address::Service()
|
||||
{
|
||||
return GAddress_INET_GetPort(m_address);
|
||||
return GAddress_INET_GetPort(m_address);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -196,7 +188,7 @@ const wxString& wxIPV6address::Hostname()
|
||||
|
||||
unsigned short wxIPV6address::Service()
|
||||
{
|
||||
return GAddress_INET_GetPort(m_address);
|
||||
return GAddress_INET_GetPort(m_address);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -231,5 +223,5 @@ wxString wxUNIXaddress::Filename()
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
// wxUSE_SOCKETS
|
||||
|
Reference in New Issue
Block a user