]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't allow concurrent requests, check return message of async request
authorRobert Roebling <robert@roebling.de>
Tue, 23 Dec 2008 20:46:46 +0000 (20:46 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 23 Dec 2008 20:46:46 +0000 (20:46 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57518 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/clipboard/clipboard.cpp
src/gtk/clipbrd.cpp

index 6a20dea42ca1eed5919062179091b2ef2f5caaa7..3843e7ab2c35ae0ee7dcd79de8852a866220fc3b 100644 (file)
@@ -27,7 +27,7 @@
 #endif
 
 
-#define USE_ASYNCHRONOUS_CLIPBOARD_REQUEST 0
+#define USE_ASYNCHRONOUS_CLIPBOARD_REQUEST 1
 
 class MyApp : public wxApp
 {
@@ -167,7 +167,12 @@ void MyFrame::OnUpdateUI(wxUpdateUIEvent&event)
 #if USE_ASYNCHRONOUS_CLIPBOARD_REQUEST
     if (m_request == Idle)
     {
-        wxTheClipboard->IsSupportedAsync( this );
+        if (!wxTheClipboard->IsSupportedAsync( this ))
+        {
+            // request failed, try again later
+            event.Enable( m_clipboardSupportsText ); // not yet known, assume last value
+            return;
+        }
         m_request = Waiting;
         event.Enable( m_clipboardSupportsText ); // not yet known, assume last value
     } 
index 55a2ba66c610ffaf267ce703a8540dc7356eb96a..15ffd8be44b703f29bcbc00688f0697544092cff 100644 (file)
@@ -367,6 +367,7 @@ async_targets_selection_received( GtkWidget *WXUNUSED(widget),
     if ( !selection_data || selection_data->length <= 0 )
     {
         clipboard->m_sink->QueueEvent( event );
+        clipboard->m_sink.Release();
         return;
     }
 
@@ -380,6 +381,7 @@ async_targets_selection_received( GtkWidget *WXUNUSED(widget),
                         _T("got unsupported clipboard target") );
 
             clipboard->m_sink->QueueEvent( event );
+            clipboard->m_sink.Release();
             return;
         }
     }
@@ -405,6 +407,7 @@ async_targets_selection_received( GtkWidget *WXUNUSED(widget),
     }
     
     clipboard->m_sink->QueueEvent( event );
+    clipboard->m_sink.Release();
 }
 }
 
@@ -521,8 +524,12 @@ void wxClipboard::AddSupportedTarget(GdkAtom atom)
 
 bool wxClipboard::IsSupportedAsync(wxEvtHandler *sink)
 {
+    if (m_sink.get())
+        return false;  // currently busy, come back later
+        
+    wxCHECK_MSG( sink, false, wxT("no sink given") );
+      
     m_sink = sink;
-    
     gtk_selection_convert( m_targetsWidgetAsync,
                            GTKGetClipboardAtom(),
                            g_targetsAtom,