tag 765341 patch
thanks

El 16/10/14 a les 20:19, Martin Steghöfer ha escrit:
2. Small buttons in the project recovery dialog

[...]

Regarding 2: I've observed this. It's a bug of wxWidgets 3.0.x. I've filed it in the wxWidget upstream tracker, but it doesn't seem to receive much attention:
http://trac.wxwidgets.org/ticket/16440

As upstream clearly won't provide a fix for that in time, I've attached a patch for audacity (workaround-wxwidgets-fit-recovery.patch) that works around this problem.

(I've attached the bug for your problem 1 again, to make sure it doesn't get lost. Both attached patches are necessary to fix/workaround problems 1 and 2.)

Cheers,
Martin

Description: Workaround for wx bug causing layout problems in recovery dialog
 Workaround for a bug in wxWidgets 3.0 that causes the Fit()
 function to fail in certain desktop environments (gnome, xfce) 
 before the first window of the same style class is shown on
 screen (http://trac.wxwidgets.org/ticket/16440). As a workaround,
 call Fit() and other methods that depend on its results again
 *after* we know that the window has been shown. While the bug
 may affect other calls to Fit() on a low level, the workaround
 is necessary only for the recovery dialog, which is particularly
 vulnerable because:
 1. It is shown very, very early in the program execution and
 therefore very likely to be the first dialog of its style class
 shown on screen.
 2. It doesn't have scrollbars or flexible-size controls that
 could compensate the wrong dialog size.
Author: Martin Steghöfer <mar...@steghoefer.eu>
Forwarded: llluc...@gmail.com, 2014-10-20
Bug-Debian: http://bugs.debian.org/765341

--- a/src/AutoRecovery.cpp
+++ b/src/AutoRecovery.cpp
@@ -38,6 +38,10 @@
 public:
    AutoRecoveryDialog(wxWindow *parent);
 
+#if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0)
+   void OnShow(wxShowEvent & event);
+#endif
+
 private:
    void PopulateList();
    void PopulateOrExchange(ShuttleGui & S);
@@ -65,6 +69,9 @@
    EVT_BUTTON(ID_RECOVER_ALL, AutoRecoveryDialog::OnRecoverAll)
    EVT_BUTTON(ID_RECOVER_NONE, AutoRecoveryDialog::OnRecoverNone)
    EVT_BUTTON(ID_QUIT_AUDACITY, AutoRecoveryDialog::OnQuitAudacity)
+#if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0)
+   EVT_SHOW(AutoRecoveryDialog::OnShow)
+#endif
 END_EVENT_TABLE()
 
 void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S)
@@ -102,6 +109,22 @@
    Center();
 }
 
+#if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0)
+void AutoRecoveryDialog::OnShow(wxShowEvent & event)
+{
+   // Workaround for wxWidgets bug #16440:
+   // http://trac.wxwidgets.org/ticket/16440
+   // Fit() doesn't work correctly in some desktop environments
+   // with GTK. But it does work after the first window of the
+   // same style class has been shown on screen. So re-execute
+   // Fit() and other methods that depend on its result AFTER
+   // we know that the window has been shown.
+   Fit();
+   SetMinSize(GetSize());
+   Center();
+}
+#endif
+
 void AutoRecoveryDialog::PopulateList()
 {
    mFileList->DeleteAllItems();
Description: Workaround for wxWidgets bug: Reentry in clipboard
 The wxWidgets bug http://trac.wxwidgets.org/ticket/16636 prevents
 us from doing clipboard operations in wxShowEvent and wxTimerEvent
 processing because those event could possibly be processed during
 the (not sufficiently protected) Yield() of a first clipboard
 operation, causing reentry. Audacity had a workaround in place
 for this problem (the class "CaptureEvents"), which however isn't
 applicable with wxWidgets 3.0 because it's based on changing the
 gdk event handler, a change that would be overridden by wxWidgets's
 own gdk event handler change.
 Instead, as a new workaround, specifically protect those processings
 of wxShowEvent and wxTimerEvent that try to do clipboard operations
 from being executed within Yield(). This is done by delaying their
 execution by posting pure wxWidgets events - which are never executed
 during Yield().
Author: Martin Steghöfer <mar...@steghoefer.eu>
Bug-Debian: https://bugs.debian.org/765341

--- a/src/Project.cpp
+++ b/src/Project.cpp
@@ -1625,9 +1625,13 @@
 
    // Call "OnSize" again (the previous calls to "OnSize" might not
    // have succeeded because some methods are not available before
-   // the actual creation/showing of the window)
-   wxSizeEvent sizeEvent(GetSize());
-   OnSize(sizeEvent);
+   // the actual creation/showing of the window).
+   // Post the event instead of calling OnSize(..) directly. This ensures that
+   // this is a pure wxWidgets event (no GDK event behind it) and that it
+   // therefore isn't processed within the YieldFor(..) of the clipboard
+   // operations (workaround for Debian bug #765341).
+   wxSizeEvent *sizeEvent = new wxSizeEvent(GetSize());
+   GetEventHandler()->QueueEvent(sizeEvent);
 
    // Further processing by default handlers
    event.Skip();
--- a/src/TrackPanel.cpp
+++ b/src/TrackPanel.cpp
@@ -360,6 +360,8 @@
     EVT_MENU(OnTimeTrackLinID, TrackPanel::OnTimeTrackLin)
     EVT_MENU(OnTimeTrackLogID, TrackPanel::OnTimeTrackLog)
     EVT_MENU(OnTimeTrackLogIntID, TrackPanel::OnTimeTrackLogInt)
+
+    EVT_TIMER(wxID_ANY, TrackPanel::OnTimer)
 END_EVENT_TABLE()
 
 /// Makes a cursor from an XPM, uses CursorId as a fallback.
@@ -927,7 +929,7 @@
 }
 
 /// AS: This gets called on our wx timer events.
-void TrackPanel::OnTimer()
+void TrackPanel::OnTimer(wxTimerEvent& event)
 {
    mTimeCount++;
    // AS: If the user is dragging the mouse and there is a track that
--- a/src/TrackPanel.h
+++ b/src/TrackPanel.h
@@ -207,7 +207,7 @@
 
    virtual double GetMostRecentXPos();
 
-   virtual void OnTimer();
+   virtual void OnTimer(wxTimerEvent& event);
 
    virtual int GetLeftOffset() const { return GetLabelWidth() + 1;}
 
@@ -541,7 +541,15 @@
 
    class AUDACITY_DLL_API AudacityTimer:public wxTimer {
    public:
-     virtual void Notify() { parent->OnTimer(); }
+     virtual void Notify() {
+       // Don't call parent->OnTimer(..) directly here, but instead post
+       // an event. This ensures that this is a pure wxWidgets event
+       // (no GDK event behind it) and that it therefore isn't processed
+       // within the YieldFor(..) of the clipboard operations (workaround
+       // for Debian bug #765341).
+       wxTimerEvent *event = new wxTimerEvent(*this);
+       parent->GetEventHandler()->QueueEvent(event);
+     }
      TrackPanel *parent;
    } mTimer;
 

Reply via email to