From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Tue, 25 Nov 2003 23:52:48 +0000 (+0000)
Subject: don't test whether m_selection is NULL both before calling CopySelection() and inside... 
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8feaa81f86151eca0bec1ad214e12a50dc735dea

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
---

diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp
index 5f249c1888..24fc17ca09 100644
--- a/src/html/htmlwin.cpp
+++ b/src/html/htmlwin.cpp
@@ -756,7 +756,7 @@ wxString wxHtmlWindow::SelectionToText()
 
 #endif // wxUSE_CLIPBOARD
 
-void wxHtmlWindow::CopySelection(ClipboardType t)
+bool wxHtmlWindow::CopySelection(ClipboardType t)
 {
 #if wxUSE_CLIPBOARD
     if ( m_selection )
@@ -769,7 +769,7 @@ void wxHtmlWindow::CopySelection(ClipboardType t)
         //
         // TODO: this should be abstracted at wxClipboard level!
         if ( t == Primary )
-            return;
+            return false;
 #endif // __UNIX__/!__UNIX__
 
         if ( wxTheClipboard->Open() )
@@ -779,9 +779,13 @@ void wxHtmlWindow::CopySelection(ClipboardType t)
             wxTheClipboard->Close();
             wxLogTrace(_T("wxhtmlselection"),
                        _("Copied to clipboard:\"%s\""), txt.c_str());
+
+            return true;
         }
     }
 #endif // wxUSE_CLIPBOARD
+
+    return false;
 }
 
 
@@ -943,10 +947,8 @@ void wxHtmlWindow::OnMouseUp(wxMouseEvent& event)
         m_makingSelection = false;
 
         // 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
             // handled as mouse click and e.g. follow hyperlink:
             return;
@@ -1215,15 +1217,13 @@ void wxHtmlWindow::OnKeyUp(wxKeyEvent& event)
     if ( IsSelectionEnabled() &&
          event.GetKeyCode() == 'C' && event.ControlDown() )
     {
-        if ( m_selection )
-            CopySelection();
+        CopySelection();
     }
 }
 
 void wxHtmlWindow::OnCopy(wxCommandEvent& WXUNUSED(event))
 {
-    if ( m_selection )
-        CopySelection();
+    CopySelection();
 }
 
 void wxHtmlWindow::OnDoubleClick(wxMouseEvent& event)