don't test whether m_selection is NULL both before calling CopySelection() and inside it; one time is enough

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24663 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-11-25 23:52:48 +00:00
parent 689c48297e
commit 8feaa81f86

View File

@@ -756,7 +756,7 @@ wxString wxHtmlWindow::SelectionToText()
#endif // wxUSE_CLIPBOARD #endif // wxUSE_CLIPBOARD
void wxHtmlWindow::CopySelection(ClipboardType t) bool wxHtmlWindow::CopySelection(ClipboardType t)
{ {
#if wxUSE_CLIPBOARD #if wxUSE_CLIPBOARD
if ( m_selection ) if ( m_selection )
@@ -769,7 +769,7 @@ void wxHtmlWindow::CopySelection(ClipboardType t)
// //
// TODO: this should be abstracted at wxClipboard level! // TODO: this should be abstracted at wxClipboard level!
if ( t == Primary ) if ( t == Primary )
return; return false;
#endif // __UNIX__/!__UNIX__ #endif // __UNIX__/!__UNIX__
if ( wxTheClipboard->Open() ) if ( wxTheClipboard->Open() )
@@ -779,9 +779,13 @@ void wxHtmlWindow::CopySelection(ClipboardType t)
wxTheClipboard->Close(); wxTheClipboard->Close();
wxLogTrace(_T("wxhtmlselection"), wxLogTrace(_T("wxhtmlselection"),
_("Copied to clipboard:\"%s\""), txt.c_str()); _("Copied to clipboard:\"%s\""), txt.c_str());
return true;
} }
} }
#endif // wxUSE_CLIPBOARD #endif // wxUSE_CLIPBOARD
return false;
} }
@@ -943,10 +947,8 @@ void wxHtmlWindow::OnMouseUp(wxMouseEvent& event)
m_makingSelection = false; m_makingSelection = false;
// did the user move the mouse far enough from starting point? // did the user move the mouse far enough from starting point?
if ( m_selection ) if ( CopySelection(Primary) )
{ {
CopySelection(Primary);
// we don't want mouse up event that ended selecting to be // we don't want mouse up event that ended selecting to be
// handled as mouse click and e.g. follow hyperlink: // handled as mouse click and e.g. follow hyperlink:
return; return;
@@ -1215,14 +1217,12 @@ void wxHtmlWindow::OnKeyUp(wxKeyEvent& event)
if ( IsSelectionEnabled() && if ( IsSelectionEnabled() &&
event.GetKeyCode() == 'C' && event.ControlDown() ) event.GetKeyCode() == 'C' && event.ControlDown() )
{ {
if ( m_selection )
CopySelection(); CopySelection();
} }
} }
void wxHtmlWindow::OnCopy(wxCommandEvent& WXUNUSED(event)) void wxHtmlWindow::OnCopy(wxCommandEvent& WXUNUSED(event))
{ {
if ( m_selection )
CopySelection(); CopySelection();
} }