]> git.saurik.com Git - wxWidgets.git/commitdiff
don't test whether m_selection is NULL both before calling CopySelection() and inside...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 25 Nov 2003 23:52:48 +0000 (23:52 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 25 Nov 2003 23:52:48 +0000 (23:52 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24663 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/html/htmlwin.cpp

index 5f249c18889e0fc525828e6abb0a3a581922cbbc..24fc17ca09b14ebf20db993e530dca4469c82bfd 100644 (file)
@@ -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)