[Git][wxwidgets/wxwidgets][master] 14 commits: Fix assert checking for wxSocket flags compatibility

2 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Jul 31, 2025, 7:08:30 PMJul 31
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 943e4fb1
    by Vadim Zeitlin at 2025-07-28T17:32:42+02:00
    Fix assert checking for wxSocket flags compatibility
    
    While wxSOCKET_NOWAIT is incompatible with wxSOCKET_WAITALL, using
    wxSOCKET_NOWAIT_READ and wxSOCKET_WAITALL_WRITE should be allowed, but
    it was not.
    
    Fix this and also split the assert in two for a bit more clarity.
    
    Closes #17114.
    
  • 32355b04
    by Vadim Zeitlin at 2025-07-29T22:54:37+02:00
    Avoid error about wrong "override" when wxUSE_SOCKETS=0
    
    It doesn't make much sense to enable wxUSE_PROTOCOL without
    wxUSE_SOCKETS, but if this does happen, it shouldn't result in an error,
    so add another test for wxUSE_SOCKETS, in addition to the ones already
    present in this header.
    
  • 5f021749
    by Vadim Zeitlin at 2025-07-29T22:54:37+02:00
    Extract wxCloseSocket() definition in its own header
    
    It is used in wxWebRequestCURL which can be compiled even when
    wxUSE_SOCKETS=0, so make it available in all builds.
    
  • 05a513ba
    by Vadim Zeitlin at 2025-07-29T22:54:37+02:00
    Build wxNet if wxUSE_WEBREQUEST=1 even if wxUSE_SOCKETS=0
    
    wxSocket is not really useful nowadays, but wxWebRequest is, so ensure
    that wxNet library containing it still gets built even when wxSocket
    support is disabled by setting wxUSE_SOCKETS=0.
    
  • b9a0c18f
    by Vadim Zeitlin at 2025-07-31T19:52:03+02:00
    Add wx_option_auto() CMake helper function
    
    This just calls wx_option() to create an option taking ON/OFF/AUTO
    values.
    
  • 09fb3af7
    by Vadim Zeitlin at 2025-07-31T19:52:03+02:00
    Be more helpful if wxBUILD_LOCALES=ON and gettext not found
    
    Explain that in addition to installing gettext the error can also be
    avoided by not explicitly requesting translations to be built.
    
  • 36c15805
    by Vadim Zeitlin at 2025-07-31T19:52:03+02:00
    Stop configuring if wxUSE_SECRETSTORE=ON but libsecret not found
    
    This is similar to dd745f1e37 (Error in configure if wxSecretStore
    requested but not available, 2025-05-27) but for CMake: allow requesting
    wxSecretStore to be available by setting wxUSE_SECRETSTORE=ON explicitly
    and failing in this case if libsecret is not found.
    
  • 1bc68761
    by Vadim Zeitlin at 2025-07-31T19:52:03+02:00
    Fix typo in wxUSE_REPRODUCIBLE_BUILD option description
    
  • ce2fd1ac
    by Vadim Zeitlin at 2025-07-31T19:52:03+02:00
    Define HAVE_UNISTD_H when building bundled zlib with CMake
    
    Otherwise <unistd.h> is not included, resulting in many gcc
    -Wimplicit-function-declaration warnings, so include wx/setup.h, where
    configure will have defined this symbol if the header is available.
    
  • 1fb85300
    by Vadim Zeitlin at 2025-07-31T19:52:44+02:00
    Don't give summary at the end of CMake if nothing changed
    
    This avoids annoyingly redisplaying the same summary again and again
    when CMake is rerun due to some change to its files -- showing the
    summary again in this case is not useful, especially when wxWidgets is
    consumed by another project using CMake via add_subdirectory() and the
    change happens in some CMake file not related to wxWidgets at all.
    
  • 9b25c1c6
    by Vadim Zeitlin at 2025-07-31T19:52:44+02:00
    Use new wx_lib_include_directories_before() it for 3rd party libs
    
    Change wx_lib_include_directories() CMake helper to append include
    directories to the path and add wx_lib_include_directories_before()
    to prepend them to it in order to ensure that built-in 3rd party
    libraries directories come in front of the headers search path.
    
    This ensures that when src/common/imagpng.cpp includes png.h, the
    correct src/png/pnglibconf.h is used and not any pnglibconf.h from the
    system package, which wouldn't define PNG_PREFIX as "wx_", for example,
    resulting in link errors later.
    
  • 067925dc
    by Vadim Zeitlin at 2025-07-31T19:52:44+02:00
    Use MSVC-specific define for zlib only when MSVC is being used
    
    Test for the compiler, not platform, before defining
    _CRT_NONSTDC_NO_WARNINGS: even if it does no harm when another compiler
    is used, it's unnecessary.
    
  • 6adc1eed
    by Vadim Zeitlin at 2025-08-01T00:36:10+02:00
    Merge branch 'cmake-improvements'
    
    Miscellaneous CMake improvements, mostly for consuming the library via
    add_subdirectory().
    
    See #25666.
    
  • f9d5b783
    by Vadim Zeitlin at 2025-08-01T00:36:31+02:00
    Merge branch 'net-without-socket'
    
    Build wxNet without wxSocket if wxWebRequest is used.
    
    See #25669.
    

19 changed files:

Changes:

  • build/cmake/README.md
    ... ... @@ -36,7 +36,7 @@ Files
    36 36
         * Includes all other cmake files
    
    37 37
     * options.cmake
    
    38 38
         * All user selectable build options should be defined in this file via
    
    39
    -      calls to `wx_option()`
    
    39
    +      calls to `wx_option()` or `wx_option_auto()`
    
    40 40
     * policies.cmake
    
    41 41
         * [CMake policies][2] for wxWidgets should be defined in this file
    
    42 42
     * setup.cmake
    

  • build/cmake/functions.cmake
    ... ... @@ -558,6 +558,17 @@ macro(wx_lib_include_directories name)
    558 558
         if(wxBUILD_MONOLITHIC)
    
    559 559
             list(APPEND wxMONO_INCLUDE_DIRS ${ARGN})
    
    560 560
             set(wxMONO_INCLUDE_DIRS ${wxMONO_INCLUDE_DIRS} PARENT_SCOPE)
    
    561
    +    else()
    
    562
    +        target_include_directories(${name} PRIVATE ${ARGN})
    
    563
    +    endif()
    
    564
    +endmacro()
    
    565
    +
    
    566
    +# Same as wx_lib_include_directories() but prepends the given directories to
    
    567
    +# the include path instead of appending them.
    
    568
    +macro(wx_lib_include_directories_before name)
    
    569
    +    if(wxBUILD_MONOLITHIC)
    
    570
    +        list(PREPEND wxMONO_INCLUDE_DIRS ${ARGN})
    
    571
    +        set(wxMONO_INCLUDE_DIRS ${wxMONO_INCLUDE_DIRS} PARENT_SCOPE)
    
    561 572
         else()
    
    562 573
             target_include_directories(${name} BEFORE PRIVATE ${ARGN})
    
    563 574
         endif()
    
    ... ... @@ -712,6 +723,7 @@ function(wx_print_thirdparty_library_summary)
    712 723
         foreach(entry IN LISTS wxTHIRD_PARTY_LIBRARIES)
    
    713 724
             if(NOT var_name)
    
    714 725
                 set(var_name ${entry})
    
    726
    +            string(APPEND wxTHIRD_PARTY_SUMMARY_NOW "${var_name}=${${var_name}}-")
    
    715 727
             else()
    
    716 728
                 string(LENGTH ${var_name} len)
    
    717 729
                 if(len GREATER nameLength)
    
    ... ... @@ -724,6 +736,15 @@ function(wx_print_thirdparty_library_summary)
    724 736
                 set(var_name)
    
    725 737
             endif()
    
    726 738
         endforeach()
    
    739
    +
    
    740
    +    # Avoid printing out the message if we're being reconfigured and nothing
    
    741
    +    # has changed since the previous run, so check if the current summary
    
    742
    +    # differs from the cached value.
    
    743
    +    if("${wxTHIRD_PARTY_SUMMARY_NOW}" STREQUAL "${wxTHIRD_PARTY_SUMMARY}")
    
    744
    +        return()
    
    745
    +    endif()
    
    746
    +    set(wxTHIRD_PARTY_SUMMARY ${wxTHIRD_PARTY_SUMMARY_NOW} CACHE INTERNAL "internal summary of 3rd party libraries used by wxWidgets")
    
    747
    +
    
    727 748
         math(EXPR nameLength "${nameLength}+1") # account for :
    
    728 749
     
    
    729 750
         set(message "Which libraries should wxWidgets use?\n")
    
    ... ... @@ -1025,6 +1046,15 @@ function(wx_option name desc)
    1025 1046
         endif()
    
    1026 1047
     endfunction()
    
    1027 1048
     
    
    1049
    +# A convenient wrapper for wx_option() for an option set to AUTO by default but
    
    1050
    +# also allowing ON and OFF values, with AUTO meaning that the option is set to
    
    1051
    +# ON if possible (e.g. required support for it is detected) and turned OFF with
    
    1052
    +# just a warning otherwise, while ON means that an error is given if it can't
    
    1053
    +# be enabled.
    
    1054
    +function(wx_option_auto name desc)
    
    1055
    +    wx_option(${name} ${desc} AUTO STRINGS ON OFF AUTO)
    
    1056
    +endfunction()
    
    1057
    +
    
    1028 1058
     # Force a new value for an option created with wx_option
    
    1029 1059
     function(wx_option_force_value name value)
    
    1030 1060
         get_property(helpstring CACHE ${name} PROPERTY HELPSTRING)
    

  • build/cmake/init.cmake
    ... ... @@ -400,6 +400,11 @@ if(UNIX)
    400 400
             # have GNOME libsecret under Unix to be able to compile this class.
    
    401 401
             find_package(LIBSECRET)
    
    402 402
             if(NOT LIBSECRET_FOUND)
    
    403
    +            if(wxUSE_SECRETSTORE STREQUAL ON)
    
    404
    +                message(FATAL_ERROR "wxSecretStore support requested, but libsecret was not found: either install it or don't set wxUSE_SECRETSTORE to ON")
    
    405
    +            endif()
    
    406
    +
    
    407
    +            # wxUSE_SECRETSTORE must be AUTO, continue with a warning.
    
    403 408
                 message(WARNING "libsecret not found, wxSecretStore won't be available")
    
    404 409
                 wx_option_force_value(wxUSE_SECRETSTORE OFF)
    
    405 410
             endif()
    

  • build/cmake/lib/CMakeLists.txt
    ... ... @@ -45,7 +45,14 @@ endmacro()
    45 45
     
    
    46 46
     # Define base libraries
    
    47 47
     set(LIBS base)
    
    48
    -add_opt_lib(net wxUSE_SOCKETS)
    
    48
    +
    
    49
    +# wxNet should be built if either wxUSE_SOCKETS or wxUSE_WEBREQUEST is on.
    
    50
    +if(wxUSE_SOCKETS OR wxUSE_WEBREQUEST)
    
    51
    +    set(wxUSE_NET ON)
    
    52
    +else()
    
    53
    +    set(wxUSE_NET OFF)
    
    54
    +endif()
    
    55
    +add_opt_lib(net wxUSE_NET)
    
    49 56
     
    
    50 57
     # Define UI libraries
    
    51 58
     if(wxUSE_GUI)
    

  • build/cmake/lib/base/CMakeLists.txt
    ... ... @@ -28,12 +28,15 @@ endif()
    28 28
     
    
    29 29
     wx_add_library(wxbase IS_BASE ${BASE_FILES})
    
    30 30
     
    
    31
    +# Note that when using built-in versions of the libraries, their include
    
    32
    +# directories must come before the system ones which could be used by some
    
    33
    +# other dependency.
    
    31 34
     if(wxUSE_ZLIB)
    
    32
    -    wx_lib_include_directories(wxbase ${ZLIB_INCLUDE_DIRS})
    
    35
    +    wx_lib_include_directories_before(wxbase ${ZLIB_INCLUDE_DIRS})
    
    33 36
         wx_lib_link_libraries(wxbase PRIVATE ${ZLIB_LIBRARIES})
    
    34 37
     endif()
    
    35 38
     if(wxUSE_REGEX)
    
    36
    -    wx_lib_include_directories(wxbase ${REGEX_INCLUDE_DIRS})
    
    39
    +    wx_lib_include_directories_before(wxbase ${REGEX_INCLUDE_DIRS})
    
    37 40
         wx_lib_link_libraries(wxbase PRIVATE ${REGEX_LIBRARIES})
    
    38 41
     endif()
    
    39 42
     if(wxUSE_LIBLZMA)
    

  • build/cmake/lib/core/CMakeLists.txt
    ... ... @@ -64,10 +64,12 @@ foreach(lib JPEG PNG TIFF NANOSVG WebP)
    64 64
         if(${lib}_LIBRARIES)
    
    65 65
             wx_lib_link_libraries(wxcore PRIVATE ${${lib}_LIBRARIES})
    
    66 66
         endif()
    
    67
    +    # When using built-in versions of the libraries, their include directories
    
    68
    +    # must come before the system ones which could be used by the toolkit.
    
    67 69
         if(${lib}_INCLUDE_DIRS)
    
    68
    -        wx_lib_include_directories(wxcore ${${lib}_INCLUDE_DIRS})
    
    70
    +        wx_lib_include_directories_before(wxcore ${${lib}_INCLUDE_DIRS})
    
    69 71
         elseif(${lib}_INCLUDE_DIR)
    
    70
    -        wx_lib_include_directories(wxcore ${${lib}_INCLUDE_DIR})
    
    72
    +        wx_lib_include_directories_before(wxcore ${${lib}_INCLUDE_DIR})
    
    71 73
         endif()
    
    72 74
     endforeach()
    
    73 75
     if(wxUSE_NANOSVG STREQUAL "sys" AND wxUSE_NANOSVG_EXTERNAL_ENABLE_IMPL)
    

  • build/cmake/lib/zlib.cmake
    ... ... @@ -27,12 +27,14 @@ if(wxUSE_ZLIB STREQUAL "builtin")
    27 27
             src/zlib/uncompr.c
    
    28 28
             src/zlib/zutil.c
    
    29 29
         )
    
    30
    -    if(WIN32)
    
    30
    +    if(MSVC)
    
    31 31
             # Define this to get rid of many warnings about using open(),
    
    32 32
             # read() and other POSIX functions in zlib code. This is much
    
    33 33
             # more convenient than having to modify it to avoid them.
    
    34 34
             target_compile_definitions(wxzlib PRIVATE _CRT_NONSTDC_NO_WARNINGS)
    
    35 35
         endif()
    
    36
    +    # Tell our modified zconf.h to include wx/setup.h.
    
    37
    +    target_compile_definitions(wxzlib PRIVATE wxHAVE_SETUP_H=1)
    
    36 38
         if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    
    37 39
             target_compile_options(wxzlib PRIVATE -Wno-deprecated-non-prototype)
    
    38 40
         endif()
    

  • build/cmake/locale/CMakeLists.txt
    1
    -if(wxBUILD_LOCALES STREQUAL "AUTO")
    
    2
    -    find_package(Gettext QUIET)
    
    3
    -elseif(wxBUILD_LOCALES)
    
    4
    -    find_package(Gettext REQUIRED)
    
    1
    +if(wxBUILD_LOCALES)
    
    2
    +    if(wxBUILD_LOCALES STREQUAL "ON")
    
    3
    +        find_package(Gettext)
    
    4
    +    else() # wxBUILD_LOCALES is AUTO, don't give any messages if Gettext is not available
    
    5
    +        find_package(Gettext QUIET)
    
    6
    +    endif()
    
    7
    +    if(NOT GETTEXT_FOUND)
    
    8
    +        if(wxBUILD_LOCALES STREQUAL "ON")
    
    9
    +            message(FATAL_ERROR "Translations can't be built without gettext: either install it or don't set wxBUILD_LOCALES to ON")
    
    10
    +        endif()
    
    11
    +        wx_option_force_value(wxBUILD_LOCALES OFF)
    
    12
    +    endif()
    
    5 13
     endif()
    
    6 14
     
    
    7
    -mark_as_advanced(GETTEXT_MSGMERGE_EXECUTABLE)
    
    8
    -mark_as_advanced(GETTEXT_MSGFMT_EXECUTABLE)
    
    9
    -
    
    10
    -if(NOT GETTEXT_FOUND OR wxBUILD_LOCALES STREQUAL "OFF")
    
    15
    +if(NOT wxBUILD_LOCALES)
    
    11 16
         return()
    
    12 17
     endif()
    
    13 18
     
    
    19
    +mark_as_advanced(GETTEXT_MSGMERGE_EXECUTABLE)
    
    20
    +mark_as_advanced(GETTEXT_MSGFMT_EXECUTABLE)
    
    21
    +
    
    14 22
     # list and process the po files
    
    15 23
     file(GLOB _po_files "${wxSOURCE_DIR}/locale/*.po")
    
    16 24
     foreach(_po_file ${_po_files})
    

  • build/cmake/main.cmake
    ... ... @@ -73,6 +73,20 @@ endif()
    73 73
     # Print configuration summary
    
    74 74
     wx_print_thirdparty_library_summary()
    
    75 75
     
    
    76
    +# Avoid printing out the message if we're being reconfigured and nothing has
    
    77
    +# changed since the previous run, so check if the current summary differs from
    
    78
    +# the cached value.
    
    79
    +set(wxSUMMARY_NOW
    
    80
    +    "${CMAKE_SYSTEM_NAME}-${wxVERSION}-${wxREQUIRED_OS_DESC}-"
    
    81
    +    "${wxBUILD_TOOLKIT}-${wxTOOLKIT_VERSION}-${wxTOOLKIT_EXTRA}-"
    
    82
    +    "${wxBUILD_MONOLITHIC}-${wxBUILD_SHARED}-${wxBUILD_COMPATIBILITY}-"
    
    83
    +)
    
    84
    +if("${wxSUMMARY_NOW}" STREQUAL "${wxSUMMARY}")
    
    85
    +  return()
    
    86
    +endif()
    
    87
    +
    
    88
    +set(wxSUMMARY ${wxSUMMARY_NOW} CACHE INTERNAL "internal summary of wxWidgets build options")
    
    89
    +
    
    76 90
     if(wxTOOLKIT_EXTRA)
    
    77 91
         string(REPLACE ";" ", " wxTOOLKIT_DESC "${wxTOOLKIT_EXTRA}")
    
    78 92
         set(wxTOOLKIT_DESC "with support for: ${wxTOOLKIT_DESC}")
    

  • build/cmake/options.cmake
    ... ... @@ -16,7 +16,7 @@ wx_option(wxBUILD_TESTS "Build console tests (CONSOLE_ONLY) or ALL" OFF
    16 16
         STRINGS CONSOLE_ONLY ALL OFF)
    
    17 17
     wx_option(wxBUILD_DEMOS "Build demos" OFF)
    
    18 18
     wx_option(wxBUILD_BENCHMARKS "Build benchmarks" OFF)
    
    19
    -wx_option(wxBUILD_LOCALES "Build locales" AUTO STRINGS ON OFF AUTO)
    
    19
    +wx_option_auto(wxBUILD_LOCALES "Build locales")
    
    20 20
     mark_as_advanced(wxBUILD_LOCALES)
    
    21 21
     wx_option(wxBUILD_PRECOMP "Use precompiled headers" ON STRINGS ON OFF COTIRE)
    
    22 22
     mark_as_advanced(wxBUILD_PRECOMP)
    
    ... ... @@ -95,7 +95,7 @@ mark_as_advanced(wxBUILD_INSTALL_PDB)
    95 95
     
    
    96 96
     # Use the MSVC/makefile naming convention, or the configure naming convention,
    
    97 97
     # this is the same check as used in FindwxWidgets.
    
    98
    -wx_option(wxBUILD_WIN32_MSVC_NAMING "Force the MSVC / makefile.[gcc/vc] naming convention" AUTO STRINGS ON OFF AUTO)
    
    98
    +wx_option_auto(wxBUILD_WIN32_MSVC_NAMING "Force the MSVC / makefile.[gcc/vc] naming convention")
    
    99 99
     mark_as_advanced(wxBUILD_WIN32_MSVC_NAMING)
    
    100 100
     if(wxBUILD_WIN32_MSVC_NAMING STREQUAL "AUTO")
    
    101 101
         if(MSVC)
    
    ... ... @@ -121,7 +121,7 @@ if(NOT WIN32)
    121 121
     endif()
    
    122 122
     wx_option(wxUSE_STD_STRING_CONV_IN_WXSTRING "provide implicit conversions to std::wstring and std::string in wxString" OFF)
    
    123 123
     wx_option(wxUSE_UNSAFE_WXSTRING_CONV "provide unsafe implicit conversions in wxString to const char* or std::string")
    
    124
    -wx_option(wxUSE_REPRODUCIBLE_BUILD "enable reproducable build" OFF)
    
    124
    +wx_option(wxUSE_REPRODUCIBLE_BUILD "enable reproducible build" OFF)
    
    125 125
     
    
    126 126
     # ---------------------------------------------------------------------------
    
    127 127
     # external libraries
    
    ... ... @@ -221,7 +221,7 @@ wx_option(wxUSE_GEOMETRY "use geometry class")
    221 221
     wx_option(wxUSE_LOG "use logging system")
    
    222 222
     wx_option(wxUSE_MIMETYPE "use wxMimeTypesManager")
    
    223 223
     wx_option(wxUSE_PRINTF_POS_PARAMS "use wxVsnprintf() which supports positional parameters")
    
    224
    -wx_option(wxUSE_SECRETSTORE "use wxSecretStore class")
    
    224
    +wx_option_auto(wxUSE_SECRETSTORE "use wxSecretStore class")
    
    225 225
     wx_option(wxUSE_SNGLINST_CHECKER "use wxSingleInstanceChecker class")
    
    226 226
     wx_option(wxUSE_SOUND "use wxSound class")
    
    227 227
     wx_option(wxUSE_SPELLCHECK "enable spell checking in wxTextCtrl")
    

  • configure
    ... ... @@ -40985,7 +40985,7 @@ STD_BASE_LIBS="base"
    40985 40985
     STD_GUI_LIBS=""
    
    40986 40986
     BUILT_WX_LIBS="base"
    
    40987 40987
     
    
    40988
    -if test "$wxUSE_SOCKETS" = "yes" ; then
    
    40988
    +if test "$wxUSE_SOCKETS" = "yes" -o "$wxUSE_WEBREQUEST" = "yes"; then
    
    40989 40989
         STD_BASE_LIBS="net $STD_BASE_LIBS"
    
    40990 40990
         BUILT_WX_LIBS="net $BUILT_WX_LIBS"
    
    40991 40991
     fi
    

  • configure.ac
    ... ... @@ -7564,7 +7564,7 @@ STD_BASE_LIBS="base"
    7564 7564
     STD_GUI_LIBS=""
    
    7565 7565
     BUILT_WX_LIBS="base"
    
    7566 7566
     
    
    7567
    -if test "$wxUSE_SOCKETS" = "yes" ; then
    
    7567
    +if test "$wxUSE_SOCKETS" = "yes" -o "$wxUSE_WEBREQUEST" = "yes"; then
    
    7568 7568
         STD_BASE_LIBS="net $STD_BASE_LIBS"
    
    7569 7569
         BUILT_WX_LIBS="net $BUILT_WX_LIBS"
    
    7570 7570
     fi
    

  • include/wx/msw/private/sockmsw.h
    ... ... @@ -13,7 +13,7 @@
    13 13
     #ifndef _WX_MSW_GSOCKMSW_H_
    
    14 14
     #define _WX_MSW_GSOCKMSW_H_
    
    15 15
     
    
    16
    -#include "wx/msw/wrapwin.h"
    
    16
    +#include "wx/private/sockettype.h"
    
    17 17
     
    
    18 18
     #if defined(__CYGWIN__)
    
    19 19
         //CYGWIN gives annoying warning about runtime stuff if we don't do this
    
    ... ... @@ -34,8 +34,6 @@
    34 34
         #define wxIoctlSocketArg_t u_long
    
    35 35
     #endif
    
    36 36
     
    
    37
    -#define wxCloseSocket closesocket
    
    38
    -
    
    39 37
     // ----------------------------------------------------------------------------
    
    40 38
     // MSW-specific socket implementation
    
    41 39
     // ----------------------------------------------------------------------------
    

  • include/wx/private/sockettype.h
    1
    +///////////////////////////////////////////////////////////////////////////////
    
    2
    +// Name:        wx/private/sockettype.h
    
    3
    +// Purpose:     Low-level header defining wxCloseSocket()
    
    4
    +// Author:      Vadim Zeitlin
    
    5
    +// Created:     2025-07-29
    
    6
    +// Copyright:   (c) 2025 Vadim Zeitlin <va...@wxwidgets.org>
    
    7
    +// Licence:     wxWindows licence
    
    8
    +///////////////////////////////////////////////////////////////////////////////
    
    9
    +
    
    10
    +#ifndef _WX_PRIVATE_SOCKETTYPE_H_
    
    11
    +#define _WX_PRIVATE_SOCKETTYPE_H_
    
    12
    +
    
    13
    +// Note that this header is not affected by wxUSE_SOCKETS as wxCloseSocket() is
    
    14
    +// also used by wxWebRequestCURL.
    
    15
    +#if defined(__WINDOWS__)
    
    16
    +    #include "wx/msw/wrapwin.h"
    
    17
    +
    
    18
    +    #define wxCloseSocket closesocket
    
    19
    +#else
    
    20
    +    #include <unistd.h>
    
    21
    +
    
    22
    +    #define wxCloseSocket close
    
    23
    +#endif
    
    24
    +
    
    25
    +#endif // _WX_PRIVATE_SOCKETTYPE_H_

  • include/wx/protocol/protocol.h
    ... ... @@ -84,10 +84,12 @@ public:
    84 84
     
    
    85 85
         virtual void SetDefaultTimeout(wxUint32 Value);
    
    86 86
     
    
    87
    +#if wxUSE_SOCKETS
    
    87 88
         // override wxSocketBase::SetTimeout function to avoid that the internal
    
    88 89
         // m_uiDefaultTimeout goes out-of-sync:
    
    89 90
         virtual void SetTimeout(long seconds) override
    
    90 91
             { SetDefaultTimeout(static_cast<wxUint32>(seconds)); }
    
    92
    +#endif // wxUSE_SOCKETS
    
    91 93
     
    
    92 94
     
    
    93 95
         // logging support: each wxProtocol object may have the associated logger
    

  • include/wx/unix/private/sockunix.h
    ... ... @@ -11,7 +11,8 @@
    11 11
     #ifndef _WX_UNIX_GSOCKUNX_H_
    
    12 12
     #define _WX_UNIX_GSOCKUNX_H_
    
    13 13
     
    
    14
    -#include <unistd.h>
    
    14
    +#include "wx/private/sockettype.h"
    
    15
    +
    
    15 16
     #include <sys/ioctl.h>
    
    16 17
     
    
    17 18
     // Under older (Open)Solaris versions FIONBIO is declared in this header only.
    
    ... ... @@ -23,8 +24,6 @@
    23 24
     
    
    24 25
     #include "wx/private/fdiomanager.h"
    
    25 26
     
    
    26
    -#define wxCloseSocket close
    
    27
    -
    
    28 27
     class wxSocketImplUnix : public wxSocketImpl,
    
    29 28
                              public wxFDIOHandler
    
    30 29
     {
    

  • src/common/socket.cpp
    ... ... @@ -1716,12 +1716,18 @@ void wxSocketBase::SetTimeout(long seconds)
    1716 1716
     
    
    1717 1717
     void wxSocketBase::SetFlags(wxSocketFlags flags)
    
    1718 1718
     {
    
    1719
    -    // Do some sanity checking on the flags used: not all values can be used
    
    1720
    -    // together.
    
    1721
    -    wxASSERT_MSG( !(flags & wxSOCKET_NOWAIT) ||
    
    1722
    -                  !(flags & (wxSOCKET_WAITALL | wxSOCKET_BLOCK)),
    
    1723
    -                  "Using wxSOCKET_WAITALL or wxSOCKET_BLOCK with "
    
    1724
    -                  "wxSOCKET_NOWAIT doesn't make sense" );
    
    1719
    +    // Do some sanity checking on the flags used: we can't not wait at all and
    
    1720
    +    // wait for all data in the same direction (but using wxSOCKET_NOWAIT_READ
    
    1721
    +    // with wxSOCKET_WAITALL_WRITE, or vice versa, is fine).
    
    1722
    +    wxASSERT_MSG( (!(flags & wxSOCKET_NOWAIT_READ) ||
    
    1723
    +                   !(flags & wxSOCKET_WAITALL_READ)) &&
    
    1724
    +                  (!(flags & wxSOCKET_NOWAIT_WRITE) ||
    
    1725
    +                   !(flags & wxSOCKET_WAITALL_WRITE)),
    
    1726
    +                  "wxSOCKET_WAITALL and wxSOCKET_NOWAIT are incompatible" );
    
    1727
    +
    
    1728
    +    // And blocking is not compatible with not waiting, in any direction.
    
    1729
    +    wxASSERT_MSG( !(flags & wxSOCKET_BLOCK) || !(flags & wxSOCKET_NOWAIT),
    
    1730
    +                  "wxSOCKET_BLOCK and wxSOCKET_NOWAIT are incompatible" );
    
    1725 1731
     
    
    1726 1732
         // Blocking sockets are very different from non-blocking ones and we need
    
    1727 1733
         // to [un]register the socket with the event loop if wxSOCKET_BLOCK is
    

  • src/common/webrequest_curl.cpp
    ... ... @@ -23,7 +23,7 @@
    23 23
     #endif
    
    24 24
     
    
    25 25
     #include "wx/uri.h"
    
    26
    -#include "wx/private/socket.h"
    
    26
    +#include "wx/private/sockettype.h"
    
    27 27
     #include "wx/evtloop.h"
    
    28 28
     
    
    29 29
     #ifdef __WINDOWS__
    

  • src/zlib
    1
    -Subproject commit 91f4e5236abcf379cda43fe27b3bb70911343915
    1
    +Subproject commit d672063aa21e7b12f6ea00f9e9027637f79cbff8

Reply all
Reply to author
Forward
0 new messages