Commit Graph

36151 Commits

Author SHA1 Message Date
Vadim Zeitlin
3918c420b4 Check the active event loop in wxGenericProgressDialog dtor
Verify that the active loop didn't change during this object lifetime as
otherwise we could deactivate a different event loop from the one we
installed.

It's still a programming error to write code which doesn't destroy
wxGenericProgressDialog early enough, but at least now "just" assert and
leak memory in this case instead of resetting the active event loop and
hanging the program.

Closes #17983.
2017-11-16 01:35:53 +01:00
Vadim Zeitlin
5a3fd23a68 Remove a now redundant test in UpdateExpandedInformation()
Checking for m_progressBarMarquee is not necessary any longer, just
testing the value is enough.

Update the comments to explain why is it so.

No real changes.
2017-11-16 01:35:53 +01:00
Vadim Zeitlin
4ab676c967 Show elapsed/estimated times in wxMSW wxProgressDialog by default
This further improves the dialog usability when the main thread doesn't
update it frequently enough, as these times can be seen immediately
without having to expand the "details" part of the dialog which can be
very sluggish in this case.

It is also more consistent with the generic dialog and the behaviour of
the native dialog before 6b91c5dfab876f0f1b17d54304bfb2fda27398ef which
removed the code clearing TDF_EXPAND_FOOTER_AREA style.
2017-11-16 01:35:53 +01:00
Vadim Zeitlin
ed086ea044 Get rid of unnecessary variables in wxMSW wxProgressDialog
There doesn't seem to be any need to have both "foo" and "realFoo", just
reuse the existing variables instead.

No real changes.
2017-11-16 01:35:53 +01:00
Vadim Zeitlin
e49cde166f Improve progress bar updating in native wxMSW wxProgressDialog
Since the switch to tying the task dialog thread message queue with the
main thread, animating the progress bar didn't work well unless the
dialog was updated very frequently from the main thread and could lag
behind significantly, and confusingly for the user, otherwise.

Work around this by avoiding the progress bar animation and setting it
immediately to its real value. This works much better in practice.
2017-11-16 01:35:53 +01:00
Vadim Zeitlin
cac3d39fa1 Don't explicitly attach progress dialog thread input
This is actually completely unnecessary because this is done implicitly
by Windows itself anyhow when we create the dialog with the owner window
belonging to a different thread.

Notice that this also explains why the thread input can't be detached
later.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
1c62ebdcd7 Minor optimizations in wxProgressDialog
Don't bother performing the updates if nothing was requested.

And ensure that nothing is requested even more often than it already was
by not requesting an update if the new value is the same as the old one.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
ca7e1d8bd1 Remove manual wxProgressDialog centering code
This is not necessary any longer now that we use the correct parent for
the dialog window, the task dialog is centered automatically.

And unlike our own code, comctl32.dll code always puts the dialog fully
on one monitor instead of making it span two of them if the parent
window does.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
2b8e84ca49 Avoid deadlock when closing the progress dialog
Don't call EndDialog() while inside the critical section, this could
(and did, sometimes) result in a deadlock if the main thread was trying
to enter it in order to send us wxSPDD_DESTROYED notification as
EndDialog() needs it to process some messages.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
d7ec02636a Avoid spurious assert when cancelling wxProgressDialog
If Cancel/close button was pressed twice in a row, assert checking that
the dialog state was "Continue" could be triggered, which was worse than
annoying as it resulted in a deadlock due to trying to show the assert
dialog box while holding the critical section that prevented the main
thread from continuing.

Allow the state to be either "Continue" or already be set to "Canceled"
now to account for this case.

Still assert for the other invalid states, but they really aren't
supposed to be possible here.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
dc5802746d Set wxProgressDialog::m_parent too
This, in addition to the previous commit, allows Centre() to work
correctly as it needs to retrieve the parent window rectangle.

See #17768.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
a8eccd21c7 Implement wxProgressDialog::DoGetSize() for the native dialog too
DoGetPosition() was done in 1ef1f8fda6,
implement DoGetSize() too now in order to give a chance Centre() (which
needs both position and size to work).

See #17768.
2017-11-16 01:35:52 +01:00
Vadim Zeitlin
ffe84cfb99 Factor out wxProgressDialog::GetTaskDialogRect()
No real changes, just prepare for implementing DoGetSize() in this class
by extracting the common part between the existing DoGetPosition() and
it in a new function.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
df2a0eb67e Stop using m_winPosition to pass position to the main thread
We can just ask for the window rectangle directly from the main thread,
there is no need to update the position in wxProgressDialogSharedData
all the time.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
d240c1f20f Just use wxGenericProgressDialog::m_parentTop directly
Remove another redundant line of code from wxGenericProgressDialog::
Create(), there is no need to call GetParentForModalDialog() again when
we just did it to initialize m_parentTop, just use the latter directly.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
58f90d36a0 Remove redundant wxGenericProgressDialog::m_parentTop assignment
The line setting m_parentTop directly was mistakenly left over even
after 7e08367534 added the call to
SetTopParent() just above it.

Remove it now (better late than never), it's redundant at best and even
wrong if the top level parent can't be used as the dialog parent because
SetTopParent() checks for this but this line did not.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
12efb20ad2 Disable close title bar button in wxProgressDialog too
When the "Cancel" button inside the dialog is disabled, disable the
close title bar button as well as it serves the same purpose.

In particular, this avoids asserts when clicking the close title bar
button while showing the confirmation message box asking the user
whether the dialog should be cancelled in the dialogs sample.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
fdfd8efa83 Factor out wxTopLevelWindow::MSWEnableCloseButton()
Make it possible to reuse this code for other, non-wx, windows.

No real changes, this is just a pure refactoring.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
79e2adf916 Remove unused wxSPDD_DISABLE_ABORT notification
This notification and the code handling it were never used, so just
remove it.
2017-11-16 01:35:51 +01:00
Vadim Zeitlin
0f1590a90b Create MSW task dialog progress window with non-null parent
This ensures the correct relationship between wxProgressDialog and its
parent window, fixing different problems with Z-order and the progress
dialog icon, but requires attaching the progress dialog thread input to
the main thread, which creates its own problems: in particular, the task
dialog is now only updated when the messages are dispatched in the main
thread, i.e. more sluggishly than before.

It also requires taking care to avoid the deadlocks as the task dialog
thread now waits for the main thread to dispatch its messages too, as
the child dialog sends messages to the parent window. In particular, we
can't simply wait for the task dialog thread to terminate, but must do
it while dispatching the events as well.

Closes #13185.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
6818d0909e Factor out wxGenericProgressDialog::EnsureActiveEventLoopExists()
Make this function reusable in order to allow it to be called from the
native MSW wxProgressDialog implementation in the upcoming commit.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
0b96d3b905 Dispatch events from the native MSW wxProgressDialog too
Do this for compatibility with wxGenericProgressDialog, which always did
this and can't really do otherwise as it needs to react to the clicks on
its buttons, and also because not doing it results in the other
application windows being marked as "not responding" by MSW, which looks
bad.

Closes #17768.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
93c9ec2f01 Remove unnecessary check from DoNativeBeforeUpdate()
Don't test if we're using the native task dialog in this function
because it is only called if we are, so simplify the code by omitting
this check.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
046d3be215 Don't require calling DoNativeBeforeUpdate() with locked CS
Acquire the lock in wxProgressDialog::DoNativeBeforeUpdate() itself
instead of relying on the caller to do it.

This is just a refactoring in preparation for further changes.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
aac673391c Make state change in wxProgressDialog::Resume() more explicit
Reset the state to "Continue" instead of assigning it the dialogs own
m_state which was also set to "Continue" from the base class Resume()
called just before, but this wasn't necessarily obvious from just
reading the code.

No real changes.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
1206b7e0bd Return HRESULT, not BOOL, from TaskDialogCallbackProc
Although this doesn't change anything because, by a happy concourse of
circumstances, FALSE is the same as S_OK and TRUE is the same as S_FALSE
numerically, it is still better and more clear, because consistent with
the documentation, to return these constants from the task dialog
callback function rather than boolean ones.
2017-11-16 01:35:50 +01:00
Vadim Zeitlin
ed88275a88 Ensure we don't crash in wxProgressDialog::DoGetPosition()
Check that we do have the shared data before dereferencing the pointer
to it. While this normally will always be the case, it could be null if
some error happened, so add a check for it, just as we already do it
elsewhere.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
759c0461e1 Remove state assigning from wxProgressDialog::DoGetPosition() too
This was accidentally copy-and-pasted from another function in
1ef1f8fda6, just remove it as it was done
for the original check in the last commit but one.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
3f6e557f18 Tiny style fix in wxProgressDialog::GetHandle()
No real changes, just remove the trailing spaces and add post-#endif
comment for consistency.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
25d9faca17 Remove state assigning from wxProgressDialog::GetHandle()
This was added in 01bd848eb9 without any
explanation and probably was a copy-and-paste typo as it just doesn't
make any sense to change the state of the dialog in this accessor
function (and if the state doesn't change, then this assignment is just
completely useless).

Remove the apparently unnecessary assignment and also an unnecessary
temporary variable.
2017-11-16 01:35:49 +01:00
Andrew Radke
4101849b4d Grow wxGenericProgressDialog automatically if needed
If the new message is longer than the previously shown one, increase the
dialog size to fit it, instead of truncating the message. Still don't do
anything if the new message is shorter to avoid unwanted constant
changes in the dialog size if the message keeps changing.

This is the original patch proposed in #10624, which it really makes
sense to apply now because it makes the generic version match the
behaviour of the native one under MSW (and the behaviour of the native
version cannot be changed).

See #10624.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
0473d14ef1 Make wxProgressDialog::Fit() work in native MSW version
This method is supposed to adjust the dialog size to its contents and
while the dialog increases automatically when using native
implementation under MSW, it doesn't shrink back on its own and so it's
still useful to allow Fit() to do it.

Update the sample to test Fit() too.
2017-11-16 01:35:49 +01:00
Vadim Zeitlin
0736bdfb28 Prevent constant size changes in native MSW wxProgressDialog
MSW implementation of wxProgressDialog adjusted the dialog size to the
size of the message shown in it on each update, resulting in visually
unpleasant constant jumping around (this is the same problem that we
used to have in wxGenericProgressDialog long time ago, see #10624).

Minimize this by using TDM_UPDATE_ELEMENT_TEXT instead of
TDM_SET_ELEMENT_TEXT for changing the element text. This still increases
the dialog size if the new element text is longer than the old value,
but at least doesn't shrink it back if it is shorter, which is already
quite an improvement.

Notice that this change requires using TDF_EXPAND_FOOTER_AREA style, as
otherwise the expanded information can't be updated without a re-layout.
But this doesn't seem to be a big loss and it's not really clear why did
we explicitly clear this flag before anyhow.

Update the dialogs sample to make it easy to test for this behaviour and
the documentation to mention MSW version peculiarities.
2017-11-16 01:35:48 +01:00
Vadim Zeitlin
6d2f903a48 Remove an apparently unnecessary line from MSW wxProgressDialog
It doesn't seem necessary to disable the use of common buttons, so don't
do it.
2017-11-16 01:35:48 +01:00
Paul Cornett
c1c9c2c5e5 Fix build with GTK+ 2.6 2017-11-15 10:52:21 -08:00
Paul Cornett
21620da3e5 Move GTK3 wxNO_BORDER handling to wxControl
So wxNO_BORDER works with other controls, such as wxBitmapButton.
Also use GTK prefix on ApplyCssStyle(), and add an overload that
creates the GtkCssProvider.
2017-11-15 10:51:38 -08:00
Scott Talbert
0d62f728ae Avoid crashing when wxTaskBarIcon is used with a non-X11 display
Fixes #17779
2017-11-13 20:30:59 -08:00
Vadim Zeitlin
ad448da284 Suppress deprecation warnings for g_option_group_free()
Closes #17877.
2017-11-14 00:41:31 +01:00
Vadim Zeitlin
99367a1530 Update glib version check in GetStandardCmdLineOptions()
This code still works fine with glib 2.50.
2017-11-14 00:41:31 +01:00
Vadim Zeitlin
91697a8724 Use correct commit of src/png submodule
Fixes wrong commit accidentally used in the previous commit.
2017-11-13 22:25:59 +01:00
Vadim Zeitlin
760bd1bf4e Update png submodule to avoid -Wundef warnings 2017-11-13 22:16:10 +01:00
Václav Slavík
926d486f54 Fix NSFont bridging crash with Asian input methods on 10.11
There's a bug in OS X 10.11 where a toll-free bridged font may have an
attributed of private class __NSCFCharacterSet that unlike
NSCharacterSet doesn't conform to NSSecureCoding. This poses a problem
when such font is used in user-editable content, because some Asian
input methods then crash in 10.11 when editing the string. As a
workaround for this bug, don't use toll-free bridging, but re-create
NSFont from the descriptor instead on buggy OS X versions.

Fixes regression introduced in a77066d530
(#507).
2017-11-13 18:46:37 +02:00
Vadim Zeitlin
818a710af6 Update bundled libtiff to not use wxjpeg_boolean any more
This is not needed after e35f01384f.
2017-11-12 23:23:48 +01:00
Artur Wieczorek
4df04a88c5 Set wxPG cell background colour as wxPGComboBox background colour
Default wxGenericComboCtrl background colour is obtained under wxGTK
with wxComboBox::GetClassDefaultAttributes(). For wxGTK 3 returned colour
is fully transparent (00000000) which can cause problems with
proper drawing of controls deriving from wxGenericComboCtrl, like
wxPGComboBox which in turn is used by wxEnumProperty, wxCursorProperty,
etc.
wxPGComboBox should have background with the same colour as the cell
so we can explicitly set background colour to avoid using default one.

Closes #17986.
2017-11-12 22:09:09 +01:00
Paul Cornett
142004884f Build fixes for wxUSE_UNICODE==0 2017-11-12 09:35:12 -08:00
Paul Cornett
cdb9436975 Use wxFALLTHROUGH 2017-11-12 09:34:22 -08:00
Vadim Zeitlin
4e226d6784 Merge branch 'extra-warn-fixes'
Fix a few harmless warnings given with -Wextra.
2017-11-12 17:48:16 +01:00
Vadim Zeitlin
fc9d41fad3 Avoid -Wmissing-field-initializers for Dl_info struct
Rely on the default initialization, this is arguably slightly less
clear, but allows to avoid the warning (which is disabled by default,
but still).

Closes #17997.
2017-11-12 17:07:35 +01:00
Scott Furry
b39d29f433 Fix harmless -Wmissing-field-initializers in wxGTK
Closes #17996.
2017-11-12 17:05:55 +01:00
Vadim Zeitlin
a03441f959 Suppress harmless -Wmissing-fields-initialize in wxSecretStore
This warning is difficult to avoid as we don't want to initialize the
unused/reserved fields of SecretSchema struct, yet the compiler warns
about it (when using -Wextra).
2017-11-12 16:57:40 +01:00