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 <martin@steghoefer.eu>
Forwarded: lllucius@gmail.com, 2014-10-20
Bug-Debian: http://bugs.debian.org/765341
a
|
b
|
|
38 | 38 | public: |
39 | 39 | AutoRecoveryDialog(wxWindow *parent); |
40 | 40 | |
| 41 | #if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0) |
| 42 | void OnShow(wxShowEvent & event); |
| 43 | #endif |
| 44 | |
41 | 45 | private: |
42 | 46 | void PopulateList(); |
43 | 47 | void PopulateOrExchange(ShuttleGui & S); |
… |
… |
|
65 | 69 | EVT_BUTTON(ID_RECOVER_ALL, AutoRecoveryDialog::OnRecoverAll) |
66 | 70 | EVT_BUTTON(ID_RECOVER_NONE, AutoRecoveryDialog::OnRecoverNone) |
67 | 71 | EVT_BUTTON(ID_QUIT_AUDACITY, AutoRecoveryDialog::OnQuitAudacity) |
| 72 | #if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0) |
| 73 | EVT_SHOW(AutoRecoveryDialog::OnShow) |
| 74 | #endif |
68 | 75 | END_EVENT_TABLE() |
69 | 76 | |
70 | 77 | void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui& S) |
… |
… |
|
102 | 109 | Center(); |
103 | 110 | } |
104 | 111 | |
| 112 | #if defined(__WXGTK__) && wxCHECK_VERSION(3, 0, 0) |
| 113 | void AutoRecoveryDialog::OnShow(wxShowEvent & event) |
| 114 | { |
| 115 | // Workaround for wxWidgets bug #16440: |
| 116 | // http://trac.wxwidgets.org/ticket/16440 |
| 117 | // Fit() doesn't work correctly in some desktop environments |
| 118 | // with GTK. But it does work after the first window of the |
| 119 | // same style class has been shown on screen. So re-execute |
| 120 | // Fit() and other methods that depend on its result AFTER |
| 121 | // we know that the window has been shown. |
| 122 | Fit(); |
| 123 | SetMinSize(GetSize()); |
| 124 | Center(); |
| 125 | } |
| 126 | #endif |
| 127 | |
105 | 128 | void AutoRecoveryDialog::PopulateList() |
106 | 129 | { |
107 | 130 | mFileList->DeleteAllItems(); |