Commit Graph

70005 Commits

Author SHA1 Message Date
Vadim Zeitlin
5d236edeed Ensure wxWebRequest is in idle state before starting it
Check that current state is State_Idle in wxWebRequest itself only once
instead of doing it in 2 (out of 3) wxWebRequestImpl implementations.

Also assert if this is not the case instead of silently doing nothing
which would surely be more difficult to debug.
2021-01-09 21:00:38 +01:00
Vadim Zeitlin
af13bdde80 Remove redundant assignment in wxWebResponseWinHTTP::GetStatus()
No changes, just remove the unnecessary line -- status was already
initialized as 0.
2021-01-09 20:53:30 +01:00
Vadim Zeitlin
8c0855ad25 Fix test for invalid WinHTTP session handle
INVALID_HANDLE_VALUE is not used for WinHTTP handles and WinHttpOpen()
returns NULL (0) and not INVALID_HANDLE_VALUE (-1).
2021-01-09 18:44:05 +01:00
Vadim Zeitlin
5d256988be Add wxMSWFormatMessage() and use it from other places
Don't duplicate calls to ::FormatMessage(), which is difficult to use
correctly, in wxCrashReport and wxWebRequestWinHTTP, but just reuse the
same code that was already present in wxSysErrorMsgStr() after
refactoring it into a reusable function allowing to specify the module
name to use for the error code lookup (before falling back to
interpreting it as system error code).

This fixes not trimming the trailing "\r\n" from the string in the other
places (wxWinHTTPErrorToString() had code to do it, but it was wrong,
while wxCrashContext::GetExceptionString() didn't do it at all) and
avoids duplication.
2021-01-09 17:41:49 +01:00
Paul Cornett
4ed8ccff95 Use a better method of drawing a point in wxGCDC::DrawPoint()
Drawing a circular point into a square pixel does not completely fill the pixel
with the new color, resulting in an alpha-blended appearance. Instead, draw a
square into the pixel. As a bonus, this is much faster, at least with Cairo.
See #19037
2021-01-09 08:39:17 -08:00
Vadim Zeitlin
2869e1ccd6 Implement wxSysErrorMsg() in terms of wxSysErrorMsgStr()
Instead of doing it the other way round, as it has several advantages:

1. wxSysErrorMsgStr() is not limited by the static buffer size any
   longer, i.e. doesn't truncate errors even longer than 1KiB.
2. Code is much simpler and more obviously correct.
3. We avoid an extra and absolutely unnecessary buffer copy.

No real changes.
2021-01-09 17:32:12 +01:00
Vadim Zeitlin
ccd2064ae8 Remove unnecessary use of __WXFUNCTION__ from wxLog code
Just micro cleanup: there doesn't seem to be any need to show which
function we're in as FormatMessage() is only called from a single place
anyhow, so shorten and simplify the code.
2021-01-09 17:21:02 +01:00
Vadim Zeitlin
c70ac66200 Simplify and make more robust wxWebSessionWinHTTP initialization
Rename Init() to Open() as we need this method to return bool to
indicate its success in order to avoid using non-initialized handle
later. Init() is also reserved, by convention, for the common part of
all class ctors in wx code.

Remove m_initialized entirely, it doesn't seem to be obviously better to
cache the failure to create a session than to retry doing it every time
(in fact, it would seem to be worse) and not having it is simpler.

This commit is best viewed ignoring white space.
2021-01-09 16:56:04 +01:00
Stefan Csomor
108b48f691 fixing bug concerning retain counts for native representation of custom data formats
The native NSPasteboardType is a CFStringRef. Assigning this had two leaks, also the array iteration was not properly reflecting the desired direction
2021-01-09 13:43:54 +01:00
Dimitri Schoolwerth
b86bcb09ce Travis CI: Use default target for CMake iOS build
Remove an explicitly set CMAKE_OSX_DEPLOYMENT_TARGET from the CMake iOS
build in order to use the default value which is now also set to an iOS
instead of macOS version.
2021-01-08 13:03:24 +01:00
Dimitri Schoolwerth
086ad7bc9a CMake: Fix out of sync iOS/macOS deployment target
The minimal sample doesn't have an implicit deployment target set, while
the library does through CMakeLists.txt in root. This can result in iOS
link errors when not explicitly setting CMAKE_OSX_DEPLOYMENT_TARGET as
the sample will then use a target OS with an architecture that may not
be present in the library with its current target OS version.

Fix by copying the part setting CMAKE_OSX_DEPLOYMENT_TARGET in the
library to the minimal sample as well. Both parts should be kept in sync
but that still seemed preferable to additionally polluting an example
file for CMake usage with a dependency by introducing a common include
file.
2021-01-08 13:02:30 +01:00
Dimitri Schoolwerth
161ecbf01d CMake: Separate minimal support for iOS and macOS
Differentiate between the minimal supported version of macOS (10.10)
and iOS (12.0) instead of setting CMAKE_OSX_DEPLOYMENT_TARGET to
(macOS-only) 10.10 for both platforms.
2021-01-08 13:00:02 +01:00
Jouk
003d24d3c1 workaround for which is probably a compiler-bug on OpenVMS-AXP 2021-01-07 09:47:46 +01:00
Vadim Zeitlin
ec2ea5c7fa Handle request still in progress gracefully on shut down
Cancel the request and wait until it actually is cancelled when exiting
the sample.

This is a bit ugly, especially the busy-waiting part, but still better
than potentially crashing.
2021-01-06 23:54:51 +01:00
Stefan Csomor
86c1fe4c79 Fixing crash under BigSur
We get a late redraw event in the current 11.X versions, fixes #19030
2021-01-05 15:35:48 +01:00
Vadim Zeitlin
d22956a56a Tiny simplification in wxWebRequestWinHTTP code
Add and use SetFailed(error) function for symmetry with the existing
SetFailedWithLastError().
2021-01-05 00:41:21 +01:00
Vadim Zeitlin
dbc1d9c40e Fix cancelling wxWebRequest under MSW
A cancelled request is not supposed to end up in the "failed" state, but
it did, resulting in showing an error in the webrequest sample after
pressing on the "Cancel" button, which was clearly unwanted.
2021-01-05 00:38:16 +01:00
Vadim Zeitlin
dd23d2cf25 Fix and simplify wxWebRequestImpl objects ref counting
When cancelling a request it was possible for it to be deleted while it
was still used from another thread.

Fix this and make the code much more obviously correct by simply
"locking" the request until the event generated by it is processed: now
IncRef() and DecRef() calls are always balanced as they're called from
ctor and dtor of StateEventProcessor helper only.
2021-01-05 00:26:49 +01:00
Vadim Zeitlin
d2dc11da4f Allow starting request by pressing "Enter" in the sample
Just a small ergonomic improvement.
2021-01-04 23:16:52 +01:00
Vadim Zeitlin
f89781bfdd Simplify status bar updates in the webrequest sample
Use wxLogStatus() to update the status bar, this is shorter and simpler
than using GetStatusBar()->SetStatusText(wxString::Format(...)).

Also use wxFrame::SetStatusText() which forwards to wxStatusBar method
with the same name when we want to just clear the status bar.

No real changes.
2021-01-04 02:13:53 +01:00
Vadim Zeitlin
6e546a3d4b Don't use wxSharedPtr<> in factory registration code
Shared ownership semantics again seems inappropriate here as we're not
actually sharing the pointers here, so just use raw pointers instead
(with C++11 we could use std::unique_ptr<>, but this is impossible with
our own map and scoped pointer implementations).

No real changes.
2021-01-04 02:06:10 +01:00
Vadim Zeitlin
989cafe535 Take raw pointer and not wxSharedPtr<> in SetData()
Using shared pointer seems to be ill-advised here, the stream shouldn't
be shared as it's going to be used by wxWebRequest itself and can't be
used by the application code in parallel, so the ownership transfer
semantics is more appropriate.

We could take a wxScopedPtr<> instead, but wx API takes ownership of raw
pointers everywhere else, so do it here too.

Incidentally fix a bug with calling IsOk() on a possibly null pointer.
2021-01-04 01:57:36 +01:00
Vadim Zeitlin
b58ee58a7b Update copyright years to 2021
Just run misc/scripts/inc_year and commit the results.

See #18690.
2021-01-03 18:12:37 +01:00
Vadim Zeitlin
b2cb5e7f3b Fix wxChoice drop down height without visual theme in wxMSW
When using pre-v6 comctl32.dll (e.g. by disabling the visual styles
explicitly or by just not using the manifest), we need to update the
drop down height manually, and for this we must ensure that overridden
wxChoice::DoMoveWindow() is called from MSWUpdateDropDownHeight().

Closes #19026.
2021-01-03 18:10:03 +01:00
Vadim Zeitlin
35b0d4e696 Merge branch 'update-third-party-libs'
Update third party libraries to their latest releases.

See https://github.com/wxWidgets/wxWidgets/pull/2157
2021-01-03 15:35:23 +01:00
Artur Wieczorek
31ae1f8094 Fix build with wxUSE_OLE==0 2021-01-02 10:20:12 +01:00
Vadim Zeitlin
faff721ef0 Merge branch 'image_data_object' of https://github.com/a-wi/wxWidgets
Implement wxImageDataObject to allow copying wxImage, including its
metadata, to/from clipboard.

See https://github.com/wxWidgets/wxWidgets/pull/2156
2021-01-02 00:27:44 +01:00
Stefan Csomor
405eb4779e moving archs to xcconfig 2021-01-01 21:10:05 +01:00
Václav Slavík
d28771cfb5 Tweak wxStatusBar size for macOS 11
Finder's status bar size increased by 4pt in Big Sur.
2021-01-01 12:15:58 +01:00
Václav Slavík
e687d0c4f6 Render statusbar natively on macOS
Instead of trying to mimic native statusbar background rendering in our
own code, use NSWindow setContentBorderThickness:forEdge: to extend the
border that is drawn by the system. This is the canonical way of doing
statusbars ("bottom bar") in AppKit.

The text is still drawn generically, but that's a much smaller issue
than trying to match the border gradient.
2020-12-31 18:51:46 +01:00
Vadim Zeitlin
e5428d5c7b Upgrade libtiff to the latest 4.2.0 release
Apply some workarounds of our own to fix -Wundef warnings and MSVS 200x
build.
2020-12-31 14:37:55 +01:00
Václav Slavík
5ebd76c5db Fix window background tinting on macOS 11
macOS 11 has an option (on by default) to tint window backgrounds with wallpaper colors. This means that standard window background color is not a constant anymore and can change as the window is moved across the screen.

The key to supporting this is to _not set background color_ internally to what we think is the correct default color, or to repaint backgrounds. Let the OS handle the default behavior instead.
2020-12-31 14:00:43 +01:00
Artur Wieczorek
0a06a5066a Add test of putting wxImage on and retrieving it from clipboard 2020-12-31 13:59:13 +01:00
Artur Wieczorek
51cd4ceb5c Demonstrate storing wxImage to clipboard in image sample 2020-12-31 12:58:23 +01:00
Artur Wieczorek
e09c35efb5 Implement wxImageDataObject
Using this object we can put an wxImage on or retrieve it from the clipboard. wxImage is stored internally as a blob with either a PNG file (wxMSW, wxGTK) or a TIFF file (wxOSX) and therefore some its metadata (like resolution) is stored on the clipboard too (what is not the case for wxBitmap stored with wxBitmapDataObject). wxImages stored with wxImageDataObject can be used by native applications.

Closes #17631.
2020-12-31 12:49:06 +01:00
Artur Wieczorek
a27a7656ea Provide support for storing PNG files on the clipboard (wxMSW)
PNG is a custom clipboard format but images stored in this format are supported by e.g. MS Excel, MS PowerPoint, GIMP (including image transparency).

See #17631.
2020-12-31 12:14:08 +01:00
Vadim Zeitlin
88332e06c8 Update expat to the latest 2.2.10 release 2020-12-30 23:33:55 +01:00
Vadim Zeitlin
28348b578a Update libpng to fix compatibility with older macOS versions
See https://github.com/wxWidgets/libpng/pull/5
2020-12-30 23:33:03 +01:00
Vadim Zeitlin
c069a62bd6 Merge branch 'github-ci-asan' of https://github.com/thesiv/wxWidgets
Switch to GitHub Actions for the ASAN CI build: running it on Travis CI
often fails (see https://github.com/google/sanitizers/issues/1353),
making it more trouble than it's worth, so try running it on GitHub
instead.

If it works fine there, we can move more Travis CI builds to that
platform later.

See https://github.com/google/sanitizers/issues/1353
2020-12-30 15:23:18 +01:00
Jorge Moraleda
ca9fa09fd8 Fix drawing expander column without values in generic wxDVC
When an item is marked as not containing any value in the expander
column, we must still draw the expander button if it has children, so
skip only drawing the item value in this case (and also preparing it for
drawing it, as calling PrepareForItem() would trigger an assert failure
for the items without value), but still execute the rest of the drawing
code for it, including drawing the background and expander button.

Closes https://github.com/wxWidgets/wxWidgets/pull/2144
2020-12-30 14:47:01 +01:00
Vadim Zeitlin
63f1260739 Skip wxWebRequest authentication tests when using NSURLSession
The NSURLSession-based backend is missing authentication support, so
these tests always fail there, skip them for now.
2020-12-30 14:41:17 +01:00
Vadim Zeitlin
a2a409f7a5 Remove references to non-existent wxWebRequest headers
Remove the platform-specific wxWebRequest headers from the files lists
and from MSVS 200x project files.

This should have been done in e5bd5a926c (Move backend-specific
wxWebRequest headers to private subdirs, 2020-12-26) manually, as
update-setup-h script doesn't remove the old files from the variable
definitions.

It notably fixes CMake build under MSW and Mac, which failed due to not
finding the referenced files.
2020-12-30 14:36:06 +01:00
Vadim Zeitlin
7b6c4cb9e9 Include required module before using check_c_source_compiles()
Fix CMake build with 3.10, which gave the following errors

CMake Error at build/cmake/init.cmake:321 (check_c_source_compiles):
  Unknown CMake command "check_c_source_compiles".
Call Stack (most recent call first):
  build/cmake/main.cmake:16 (include)
  CMakeLists.txt:69 (include)

previously. Apparently the required CheckCSourceCompiles module was
already included from somewhere else with later CMake versions, but not
with this one, so do include it explicitly.
2020-12-30 14:26:06 +01:00
Ilya Sinitsyn
67d286d499 Remove build with ASAN from Travis builds 2020-12-30 13:50:59 +07:00
Ilya Sinitsyn
ea6af85859 Add GitHub CI Workflow action for ASAN build
Unfortunately Travis build with ASAN fails with the segmentation violation
so build wx with GitHub CI.
2020-12-30 13:37:17 +07:00
Robin Dunn
bf6fee0af9 Avoid array overrun in OSX's wxCheckListBox::IsChecked 2020-12-29 18:07:20 -08:00
Vadim Zeitlin
50424cba2c Change wxWebRequest and related objects to hide ref counting
Don't force the application code to deal with wxObjectDataPtr<> or,
worse, calling {Inc,Dec}Ref() manually by hiding it inside the wx
objects themselves and giving the value-like semantics to them.

There should be no real changes in the behaviour, but the API does
change significantly. Notably, wxWebRequest is not a wxEvtHandler itself
any longer, as this would be incompatible with the value semantics, and
an event handler needs to be specified when creating it, so that it
could be notified about the request state changes.
2020-12-30 02:02:20 +01:00
Vadim Zeitlin
04bbb844ae Allow constructing/assigning wxObjectDataPtr from compatible type
Generalize copy ctor and assignment operators to allow implicit
conversions from wxObjectDataPtr<D> to wxObjectDataPtr<B> if D is
implicitly convertible to B (e.g. if B is the base class and D is a
class derived from it).

This makes wxObjectDataPtr<> more like standard smart pointer classes
and more useful.
2020-12-30 01:02:47 +01:00
Xaviou
be5b68459d Add scripts used for building MinGW official binaries
Add the scripts themselves and the documentation explaining how to use
them and which compilers are currently supported.

Closes https://github.com/wxWidgets/wxWidgets/pull/2129
2020-12-29 17:41:01 +01:00
Vadim Zeitlin
f742bbaddf Merge branch '15943-grid-autosize-loop' of https://github.com/discnl/wxWidgets
Fix infinite loop with auto-wrapped multi-line cells in wxGrid.

See https://github.com/wxWidgets/wxWidgets/pull/2154

Closes #15943.
2020-12-29 17:28:17 +01:00