Don't allow concurrent requests, check return message of async request
[wxWidgets.git] / samples / clipboard / clipboard.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
     }