[Git][wxwidgets/wxwidgets][master] 6 commits: Fix wxMenu leak in a unit test

0 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Aug 24, 2025, 11:48:26 AM (14 days ago) Aug 24
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • 0aa9fc18
    by Vadim Zeitlin at 2025-08-22T16:28:36+02:00
    Fix wxMenu leak in a unit test
    
    Don't allocate wxMenu on the heap without ever freeing it, just create
    it on the stack.
    
  • 8d349dbd
    by Vadim Zeitlin at 2025-08-22T21:25:11+02:00
    Make it possible to call wxMenuItem::GetBitmapBundle() again
    
    The changes of 0dfe37a643 (Add wxMSW-specific wxBitmapBundle accessors
    to wxMenuItem, 2025-08-18) broke this as wxMSW-specific function taking
    bool hid the base class function.
    
    Just make the wxMSW function compatible with the base class one by
    defaulting "bChecked" to false. Alternatively, we could use using
    declaration to bring the base class function in scope, but this doesn't
    seem to have any advantages and this change seems more clear.
    
    In any case, add a unit test checking that the calls to these functions
    at least compile.
    
    See #25685, #25705.
    
    Closes #25719.
    
  • ea09c078
    by Vadim Zeitlin at 2025-08-24T16:57:26+02:00
    Don't include .git-blame-ignore-revs in source archives
    
    This file is only useful when using Git.
    
  • 65d0a9bc
    by BrianDelalex at 2025-08-24T17:21:25+02:00
    Add possibilities to configure timeout in wxWebRequest
    
    Add function allowing to set timeouts for WinHTTP and libcurl.
    
    Closes #25673.
    
  • db3a1351
    by Vadim Zeitlin at 2025-08-24T17:22:34+02:00
    Merge branch 'fix-menuitem-get-bb'
    
    Fix recently broken wxMenuItem::GetBitmapBundle().
    
    See #25720.
    
  • d6af1f50
    by Vadim Zeitlin at 2025-08-24T17:23:43+02:00
    Make wxTopLevelWindow label same as title in all ports
    
    This was previously done for wxGTK in a03b38ef68 (make Set/GetLabel()
    set and return title in wxTLW, fixes #12371: Dialog::GetLabel()
    Inconsistent behaviour across operating systems, 2010-08-21) and wxOSX
    in 033f86db5f (adding SetLabel -> SetTitle redirects, solves missing
    title updates using wxDocument/wxView, 2012-08-11) but wasn't done for
    the other ports, including wxMSW and updating the page title in
    wxAuiMDIChildFrame in docview framework didn't work because of it.
    
    While using SetLabel() for setting the title is suspicious and it might
    be a good idea to change docview code too, for now make it work by
    ensuring that this works consistently in all ports.
    
    See #12371.
    
    Closes #25712.
    

18 changed files:

Changes:

  • .gitattributes
    ... ... @@ -43,6 +43,7 @@ build/upmake -diff
    43 43
     .cirrus.yml                     export-ignore
    
    44 44
     .github/                        export-ignore
    
    45 45
     .gitattributes                  export-ignore
    
    46
    +.git-blame-ignore-revs          export-ignore
    
    46 47
     .gitignore                      export-ignore
    
    47 48
     .gitmodules                     export-ignore
    
    48 49
     .mailmap                        export-ignore
    

  • include/wx/gtk/toplevel.h
    ... ... @@ -71,9 +71,6 @@ public:
    71 71
         virtual void SetTitle( const wxString &title ) override;
    
    72 72
         virtual wxString GetTitle() const override { return m_title; }
    
    73 73
     
    
    74
    -    virtual void SetLabel(const wxString& label) override { SetTitle( label ); }
    
    75
    -    virtual wxString GetLabel() const override            { return GetTitle(); }
    
    76
    -
    
    77 74
         virtual wxVisualAttributes GetDefaultAttributes() const override;
    
    78 75
     
    
    79 76
         virtual bool SetTransparent(wxByte alpha) override;
    

  • include/wx/msw/menuitem.h
    ... ... @@ -83,6 +83,7 @@ public:
    83 83
             DoSetBitmap(bmp, bChecked);
    
    84 84
         }
    
    85 85
     
    
    86
    +    using wxMenuItemBase::GetBitmapBundle;
    
    86 87
         wxBitmapBundle GetBitmapBundle(bool bChecked) const
    
    87 88
         {
    
    88 89
             return bChecked ? m_bitmap : m_bmpUnchecked;
    

  • include/wx/msw/private/webrequest_winhttp.h
    ... ... @@ -85,6 +85,8 @@ public:
    85 85
     
    
    86 86
         void Start() override;
    
    87 87
     
    
    88
    +    void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs) override;
    
    89
    +
    
    88 90
         wxWebResponseImplPtr GetResponse() const override
    
    89 91
             { return m_response; }
    
    90 92
     
    
    ... ... @@ -120,6 +122,7 @@ private:
    120 122
         // returned later and this argument must be null.
    
    121 123
         wxNODISCARD Result DoWriteData(DWORD* bytesWritten = nullptr);
    
    122 124
     
    
    125
    +    void DoSetTimeouts();
    
    123 126
     
    
    124 127
         wxWebSessionWinHTTP& m_sessionImpl;
    
    125 128
         wxString m_url;
    
    ... ... @@ -140,6 +143,11 @@ private:
    140 143
         // the same flag for them as for the server credentials here.
    
    141 144
         bool m_tryProxyCredentials = false;
    
    142 145
     
    
    146
    +    // Store timeouts, in order to set these before sending request.
    
    147
    +    long m_connectionTimeoutMs = wxWebRequest::Timeout_Default;
    
    148
    +    long m_dataTimeoutMs = wxWebRequest::Timeout_Default;
    
    149
    +
    
    150
    +
    
    143 151
     
    
    144 152
         wxNODISCARD Result SendRequest();
    
    145 153
     
    

  • include/wx/osx/private/webrequest_urlsession.h
    ... ... @@ -97,6 +97,9 @@ public:
    97 97
     
    
    98 98
         void Start() override;
    
    99 99
     
    
    100
    +    void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs) override;
    
    101
    +
    
    102
    +
    
    100 103
         wxWebResponseImplPtr GetResponse() const override
    
    101 104
             { return m_response; }
    
    102 105
     
    

  • include/wx/osx/toplevel.h
    ... ... @@ -82,9 +82,6 @@ public:
    82 82
         virtual bool EnableMaximizeButton(bool enable = true) override;
    
    83 83
         virtual bool EnableMinimizeButton(bool enable = true) override;
    
    84 84
     
    
    85
    -    virtual void SetLabel(const wxString& label) override { SetTitle( label ); }
    
    86
    -    virtual wxString GetLabel() const            override { return GetTitle(); }
    
    87
    -
    
    88 85
         virtual void OSXSetModified(bool modified) override;
    
    89 86
         virtual bool OSXIsModified() const override;
    
    90 87
     
    

  • include/wx/private/webrequest.h
    ... ... @@ -88,6 +88,8 @@ public:
    88 88
         // cancelled.
    
    89 89
         void Cancel();
    
    90 90
     
    
    91
    +    virtual void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs) = 0;
    
    92
    +
    
    91 93
         virtual wxWebResponseImplPtr GetResponse() const = 0;
    
    92 94
     
    
    93 95
         virtual wxWebAuthChallengeImplPtr GetAuthChallenge() const = 0;
    

  • include/wx/private/webrequest_curl.h
    ... ... @@ -64,6 +64,8 @@ public:
    64 64
     
    
    65 65
         void Start() override;
    
    66 66
     
    
    67
    +    void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs) override;
    
    68
    +
    
    67 69
         wxWebResponseImplPtr GetResponse() const override
    
    68 70
             { return m_response; }
    
    69 71
     
    

  • include/wx/toplevel.h
    ... ... @@ -191,6 +191,10 @@ public:
    191 191
         virtual void SetTitle(const wxString& title) = 0;
    
    192 192
         virtual wxString GetTitle() const = 0;
    
    193 193
     
    
    194
    +    // label is the same as title for top-level windows
    
    195
    +    virtual void SetLabel(const wxString& label) override { SetTitle( label ); }
    
    196
    +    virtual wxString GetLabel() const override            { return GetTitle(); }
    
    197
    +
    
    194 198
         // enable/disable close button [x]
    
    195 199
         virtual bool EnableCloseButton(bool WXUNUSED(enable) = true) { return false; }
    
    196 200
         virtual bool EnableMaximizeButton(bool WXUNUSED(enable) = true) { return false; }
    

  • include/wx/webrequest.h
    ... ... @@ -194,6 +194,12 @@ public:
    194 194
             wxString error;
    
    195 195
         };
    
    196 196
     
    
    197
    +    enum Timeout
    
    198
    +    {
    
    199
    +        Timeout_Default = -1,
    
    200
    +        Timeout_Infinite = 0
    
    201
    +    };
    
    202
    +
    
    197 203
         bool IsOk() const { return m_impl.get() != nullptr; }
    
    198 204
     
    
    199 205
         void SetHeader(const wxString& name, const wxString& value);
    
    ... ... @@ -211,6 +217,8 @@ public:
    211 217
     
    
    212 218
         void SetStorage(Storage storage);
    
    213 219
     
    
    220
    +    void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs);
    
    221
    +
    
    214 222
         Storage GetStorage() const;
    
    215 223
     
    
    216 224
         wxWebResponse GetResponse() const;
    

  • interface/wx/toplevel.h
    ... ... @@ -227,6 +227,17 @@ public:
    227 227
         */
    
    228 228
         const wxIconBundle& GetIcons() const;
    
    229 229
     
    
    230
    +    /**
    
    231
    +        Get the window title.
    
    232
    +
    
    233
    +        This base class function is overridden in this class to behave as
    
    234
    +        GetTitle() and is useful when having only a `wxWindow*` pointer.
    
    235
    +
    
    236
    +        Please call GetTitle() directly instead of this function for clarity if
    
    237
    +        possible.
    
    238
    +     */
    
    239
    +    virtual wxString GetLabel() const;
    
    240
    +
    
    230 241
         /**
    
    231 242
             Gets a string containing the window title.
    
    232 243
     
    
    ... ... @@ -582,6 +593,20 @@ public:
    582 593
                           const wxSize& maxSize = wxDefaultSize,
    
    583 594
                           const wxSize& incSize = wxDefaultSize);
    
    584 595
     
    
    596
    +    /**
    
    597
    +        Sets the window title.
    
    598
    +
    
    599
    +        This base class function is overridden in this class to behave as
    
    600
    +        SetTitle() and is useful when having only a `wxWindow*` pointer.
    
    601
    +
    
    602
    +        Please call SetTitle() directly instead of this function for clarity if
    
    603
    +        possible.
    
    604
    +
    
    605
    +        @param title
    
    606
    +            The window title.
    
    607
    +     */
    
    608
    +    virtual void SetLabel(const wxString& title);
    
    609
    +
    
    585 610
         /**
    
    586 611
             Sets the window title.
    
    587 612
     
    

  • interface/wx/webrequest.h
    ... ... @@ -227,6 +227,26 @@ public:
    227 227
             Storage_None
    
    228 228
         };
    
    229 229
     
    
    230
    +    /**
    
    231
    +        Special timeout values.
    
    232
    +
    
    233
    +        Can be used as argument when calling wxWebRequest::SetTimeouts().
    
    234
    +
    
    235
    +        @since 3.3.2
    
    236
    +    */
    
    237
    +    enum Timeout
    
    238
    +    {
    
    239
    +        /**
    
    240
    +            Use the default value for the current timeout and implementation.
    
    241
    +        */
    
    242
    +        Timeout_Default,
    
    243
    +
    
    244
    +        /**
    
    245
    +            Set the timeout to infinite (No timeout).
    
    246
    +        */
    
    247
    +        Timeout_Infinite
    
    248
    +    };
    
    249
    +
    
    230 250
         /**
    
    231 251
             Default constructor creates an invalid object.
    
    232 252
     
    
    ... ... @@ -422,6 +442,41 @@ public:
    422 442
         */
    
    423 443
         void SetStorage(Storage storage);
    
    424 444
     
    
    445
    +    /**
    
    446
    +        Set the timeouts for the connection and data exchange time.
    
    447
    +
    
    448
    +        @param connectionTimeoutMs
    
    449
    +            Maximum time in milliseconds allowed for connection to the server.
    
    450
    +            For WinHTTP backend, this timeout is used for both the server name
    
    451
    +            resolution and the connection establishment. For libcurl backend,
    
    452
    +            this timeout is used for the complete connection establishment,
    
    453
    +            including name resolution.
    
    454
    +        @param dataTimeoutMs
    
    455
    +            The exact meaning of this parameter depends on the implementation:
    
    456
    +            for WinHTTP backend, it is the maximum time allowed for each read
    
    457
    +            or write operation. For libcurl backend it is the total time for
    
    458
    +            the entire operation, not counting the connection establishment
    
    459
    +            time.
    
    460
    +
    
    461
    +        @note Use wxWebRequest::Timeout_Default to set the timeout to the
    
    462
    +            default value (default depends on implementation). Use
    
    463
    +            wxWebRequest::Timeout_Infinite to set an infinite timeout.
    
    464
    +
    
    465
    +        @remarks The default timeout values vary depending on implementation:
    
    466
    +            - For WinHTTP backend, default connection timeout is infinite while
    
    467
    +              data timeout is 30 seconds.
    
    468
    +            - For CURL backend, default connection timeout is 5 minutes and
    
    469
    +              there is no data timeout.
    
    470
    +
    
    471
    +        @see Timeout
    
    472
    +
    
    473
    +        @note This function is currently not implemented for macOS backend and
    
    474
    +            does nothing when it is called when using it.
    
    475
    +
    
    476
    +        @since 3.3.2
    
    477
    +    */
    
    478
    +    void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs);
    
    479
    +
    
    425 480
         /**
    
    426 481
             Flags for disabling security features.
    
    427 482
     
    
    ... ... @@ -875,6 +930,41 @@ public:
    875 930
             Ignore_All = Ignore_Certificate | Ignore_Host
    
    876 931
         };
    
    877 932
     
    
    933
    +    /**
    
    934
    +        Set the timeouts for the connection and data exchange time.
    
    935
    +
    
    936
    +        @param connectionTimeoutMs
    
    937
    +            Maximum time in milliseconds allowed for connection to the server.
    
    938
    +            For WinHTTP backend, this timeout is used for both the server name
    
    939
    +            resolution and the connection establishment. For libcurl backend,
    
    940
    +            this timeout is used for the complete connection establishment,
    
    941
    +            including name resolution.
    
    942
    +        @param dataTimeoutMs
    
    943
    +            The exact meaning of this parameter depends on the implementation:
    
    944
    +            for WinHTTP backend, it is the maximum time allowed for each read
    
    945
    +            or write operation. For libcurl backend it is the total time for
    
    946
    +            the entire operation, not counting the connection establishment
    
    947
    +            time.
    
    948
    +
    
    949
    +        @note Use wxWebRequest::Timeout_Default to set the timeout to the
    
    950
    +            default value (default depends on implementation). Use
    
    951
    +            wxWebRequest::Timeout_Infinite to set an infinite timeout.
    
    952
    +
    
    953
    +        @remarks The default timeout values vary depending on implementation:
    
    954
    +            - For WinHTTP backend, default connection timeout is infinite while
    
    955
    +              data timeout is 30 seconds.
    
    956
    +            - For CURL backend, default connection timeout is 5 minutes and
    
    957
    +              there is no data timeout.
    
    958
    +
    
    959
    +        @see Timeout
    
    960
    +
    
    961
    +        @note This function is currently not implemented for macOS backend and
    
    962
    +            does nothing when it is called when using it.
    
    963
    +
    
    964
    +        @since 3.3.2
    
    965
    +    */
    
    966
    +    void SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs);
    
    967
    +
    
    878 968
         /**
    
    879 969
             Make connection insecure by disabling security checks.
    
    880 970
     
    

  • src/common/webrequest.cpp
    ... ... @@ -470,6 +470,14 @@ void wxWebRequestBase::SetStorage(Storage storage)
    470 470
         m_impl->SetStorage(storage);
    
    471 471
     }
    
    472 472
     
    
    473
    +void wxWebRequestBase::SetTimeouts(long connectionTimeoutMs, long dataTimeoutMs)
    
    474
    +{
    
    475
    +    wxCHECK_IMPL_VOID();
    
    476
    +
    
    477
    +    m_impl->SetTimeouts(connectionTimeoutMs, dataTimeoutMs);
    
    478
    +}
    
    479
    +
    
    480
    +
    
    473 481
     wxWebRequestBase::Storage wxWebRequestBase::GetStorage() const
    
    474 482
     {
    
    475 483
         wxCHECK_IMPL( Storage_None );
    

  • src/common/webrequest_curl.cpp
    ... ... @@ -50,6 +50,9 @@
    50 50
         #define CURLOPT_ACCEPT_ENCODING CURLOPT_ENCODING
    
    51 51
     #endif
    
    52 52
     
    
    53
    +// Define libcurl timeout constants
    
    54
    +static constexpr int LIBCURL_DEFAULT_CONNECT_TIMEOUT = 300000; // 5m in ms.
    
    55
    +
    
    53 56
     //
    
    54 57
     // wxWebResponseCURL
    
    55 58
     //
    
    ... ... @@ -524,6 +527,32 @@ void wxWebRequestCURL::Start()
    524 527
         StartRequest();
    
    525 528
     }
    
    526 529
     
    
    530
    +void wxWebRequestCURL::SetTimeouts(long connectionTimeoutMs,
    
    531
    +                                   long dataTimeoutMs)
    
    532
    +{
    
    533
    +    if ( connectionTimeoutMs == wxWebRequest::Timeout_Default )
    
    534
    +        connectionTimeoutMs = LIBCURL_DEFAULT_CONNECT_TIMEOUT;
    
    535
    +
    
    536
    +    if ( connectionTimeoutMs == wxWebRequest::Timeout_Infinite )
    
    537
    +        connectionTimeoutMs = LONG_MAX;
    
    538
    +
    
    539
    +    wxCURLSetOpt(m_handle, CURLOPT_CONNECTTIMEOUT_MS, connectionTimeoutMs);
    
    540
    +
    
    541
    +    // Don't set full request timeout if not specified.
    
    542
    +    if ( dataTimeoutMs == wxWebRequest::Timeout_Infinite ||
    
    543
    +         dataTimeoutMs == wxWebRequest::Timeout_Default )
    
    544
    +    {
    
    545
    +        return;
    
    546
    +    }
    
    547
    +
    
    548
    +    // Check that connectionTimeoutMs + dataTimeoutMs doesn't overflow.
    
    549
    +    const long overflowDiff = LONG_MAX - connectionTimeoutMs;
    
    550
    +    wxCHECK_RET( dataTimeoutMs <= overflowDiff, "Timeout values overflow" );
    
    551
    +
    
    552
    +    const long fullTimeoutMs = connectionTimeoutMs + dataTimeoutMs;
    
    553
    +    wxCURLSetOpt(m_handle, CURLOPT_TIMEOUT_MS, fullTimeoutMs);
    
    554
    +}
    
    555
    +
    
    527 556
     bool wxWebRequestCURL::StartRequest()
    
    528 557
     {
    
    529 558
         m_bytesSent = 0;
    

  • src/msw/toplevel.cpp
    ... ... @@ -1016,12 +1016,16 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
    1016 1016
     
    
    1017 1017
     void wxTopLevelWindowMSW::SetTitle( const wxString& title)
    
    1018 1018
     {
    
    1019
    -    SetLabel(title);
    
    1019
    +    // The base class version works for TLWs too in wxMSW but take care to
    
    1020
    +    // select it explicitly as our overridden SetLabel() just redirects to
    
    1021
    +    // SetTitle() itself.
    
    1022
    +    wxWindow::SetLabel(title);
    
    1020 1023
     }
    
    1021 1024
     
    
    1022 1025
     wxString wxTopLevelWindowMSW::GetTitle() const
    
    1023 1026
     {
    
    1024
    -    return GetLabel();
    
    1027
    +    // See comment in SetTitle() above.
    
    1028
    +    return wxWindow::GetLabel();
    
    1025 1029
     }
    
    1026 1030
     
    
    1027 1031
     bool wxTopLevelWindowMSW::DoSelectAndSetIcon(const wxIconBundle& icons,
    

  • src/msw/webrequest_winhttp.cpp
    ... ... @@ -60,6 +60,7 @@ public:
    60 60
             wxLOAD_FUNC(WinHttpQueryAuthSchemes)
    
    61 61
             wxLOAD_FUNC(WinHttpSetCredentials)
    
    62 62
             wxLOAD_FUNC(WinHttpOpen)
    
    63
    +        wxLOAD_FUNC(WinHttpSetTimeouts)
    
    63 64
     
    
    64 65
             if ( !result )
    
    65 66
                 m_winhttp.Unload();
    
    ... ... @@ -99,6 +100,8 @@ public:
    99 100
         static WinHttpSetCredentials_t WinHttpSetCredentials;
    
    100 101
         typedef HINTERNET(WINAPI* WinHttpOpen_t)(LPCWSTR, DWORD, LPCWSTR, LPCWSTR, DWORD);
    
    101 102
         static WinHttpOpen_t WinHttpOpen;
    
    103
    +    typedef BOOL(WINAPI* WinHttpSetTimeouts_t)(HINTERNET, int, int, int, int);
    
    104
    +    static WinHttpSetTimeouts_t WinHttpSetTimeouts;
    
    102 105
     
    
    103 106
     private:
    
    104 107
         static wxDynamicLibrary m_winhttp;
    
    ... ... @@ -121,6 +124,7 @@ wxWinHTTP::WinHttpReadData_t wxWinHTTP::WinHttpReadData;
    121 124
     wxWinHTTP::WinHttpQueryAuthSchemes_t wxWinHTTP::WinHttpQueryAuthSchemes;
    
    122 125
     wxWinHTTP::WinHttpSetCredentials_t wxWinHTTP::WinHttpSetCredentials;
    
    123 126
     wxWinHTTP::WinHttpOpen_t wxWinHTTP::WinHttpOpen;
    
    127
    +wxWinHTTP::WinHttpSetTimeouts_t wxWinHTTP::WinHttpSetTimeouts;
    
    124 128
     
    
    125 129
     
    
    126 130
     // Define constants potentially missing in old SDKs
    
    ... ... @@ -153,6 +157,11 @@ wxWinHTTP::WinHttpOpen_t wxWinHTTP::WinHttpOpen;
    153 157
     namespace
    
    154 158
     {
    
    155 159
     
    
    160
    +// Define default timeouts constant
    
    161
    +constexpr DWORD WINHTTP_DEFAULT_RESOLVE_TIMEOUT = 0;
    
    162
    +constexpr DWORD WINHTTP_DEFAULT_CONNECT_TIMEOUT = 60000;
    
    163
    +constexpr DWORD WINHTTP_DEFAULT_DATA_TIMEOUT    = 30000;
    
    164
    +
    
    156 165
     // Wrapper initializing URL_COMPONENTS struct.
    
    157 166
     struct wxURLComponents : URL_COMPONENTS
    
    158 167
     {
    
    ... ... @@ -536,6 +545,8 @@ wxWebRequest::Result wxWebRequestWinHTTP::Execute()
    536 545
         if ( !result )
    
    537 546
             return result;
    
    538 547
     
    
    548
    +    DoSetTimeouts();
    
    549
    +
    
    539 550
         // This loop executes until we exhaust all authentication possibilities: we
    
    540 551
         // may need to authenticate with the proxy first and then with the server
    
    541 552
         // and we even may need to authenticate with the proxy again after failing
    
    ... ... @@ -727,6 +738,8 @@ void wxWebRequestWinHTTP::Start()
    727 738
         if ( !CheckResult(DoPrepareRequest()) )
    
    728 739
             return;
    
    729 740
     
    
    741
    +    DoSetTimeouts();
    
    742
    +
    
    730 743
         // Register callback
    
    731 744
         if ( wxWinHTTP::WinHttpSetStatusCallback
    
    732 745
                (
    
    ... ... @@ -748,6 +761,49 @@ void wxWebRequestWinHTTP::Start()
    748 761
         CheckResult(SendRequest());
    
    749 762
     }
    
    750 763
     
    
    764
    +void wxWebRequestWinHTTP::SetTimeouts(long connectionTimeoutMs,
    
    765
    +                                      long dataTimeoutMs)
    
    766
    +{
    
    767
    +    m_connectionTimeoutMs = connectionTimeoutMs;
    
    768
    +    m_dataTimeoutMs = dataTimeoutMs;
    
    769
    +}
    
    770
    +
    
    771
    +void wxWebRequestWinHTTP::DoSetTimeouts()
    
    772
    +{
    
    773
    +    if ( m_connectionTimeoutMs == wxWebRequest::Timeout_Default &&
    
    774
    +            m_dataTimeoutMs == wxWebRequest::Timeout_Default )
    
    775
    +    {
    
    776
    +        // Nothing to do, don't bother calling WinHttpSetTimeouts().
    
    777
    +        return;
    
    778
    +    }
    
    779
    +
    
    780
    +    // Note that we don't have to test for Timeout_Infinite here as it is
    
    781
    +    // handled by WinHttpSetTimeouts() itself as long as its value is 0.
    
    782
    +    static_assert( wxWebRequest::Timeout_Infinite == 0,
    
    783
    +                   "wxWebRequest::Timeout_Infinite must be 0" );
    
    784
    +
    
    785
    +    int resolveTimeoutMs = WINHTTP_DEFAULT_RESOLVE_TIMEOUT;
    
    786
    +    int connectionTimeoutMs = WINHTTP_DEFAULT_CONNECT_TIMEOUT;
    
    787
    +    int dataTimeoutMs = WINHTTP_DEFAULT_DATA_TIMEOUT;
    
    788
    +
    
    789
    +    if ( m_connectionTimeoutMs != wxWebRequest::Timeout_Default )
    
    790
    +        resolveTimeoutMs = m_connectionTimeoutMs;
    
    791
    +
    
    792
    +    if ( m_dataTimeoutMs != wxWebRequest::Timeout_Default )
    
    793
    +        dataTimeoutMs = m_dataTimeoutMs;
    
    794
    +
    
    795
    +    if ( !wxWinHTTP::WinHttpSetTimeouts(
    
    796
    +        m_request,
    
    797
    +        resolveTimeoutMs,
    
    798
    +        connectionTimeoutMs,
    
    799
    +        dataTimeoutMs,
    
    800
    +        dataTimeoutMs) )
    
    801
    +    {
    
    802
    +        wxLogTrace(wxTRACE_WEBREQUEST,
    
    803
    +                   "Error while setting timeout. Error code: %d", ::GetLastError());
    
    804
    +    }
    
    805
    +}
    
    806
    +
    
    751 807
     wxWebRequest::Result wxWebRequestWinHTTP::SendRequest()
    
    752 808
     {
    
    753 809
         // Combine all headers to a string
    

  • src/osx/webrequest_urlsession.mm
    ... ... @@ -327,6 +327,11 @@ void wxWebRequestURLSession::Start()
    327 327
         [m_task resume];
    
    328 328
     }
    
    329 329
     
    
    330
    +void wxWebRequestURLSession::SetTimeouts(long WXUNUSED(connectionTimeoutMs),
    
    331
    +                                         long WXUNUSED(dataTimeoutMs))
    
    332
    +{
    
    333
    +}
    
    334
    +
    
    330 335
     void wxWebRequestURLSession::DoCancel()
    
    331 336
     {
    
    332 337
         [m_task cancel];
    

  • tests/menu/menu.cpp
    ... ... @@ -806,10 +806,10 @@ key specialKeys[] =
    806 806
     
    
    807 807
     TEST_CASE( "wxMenuItemAccelEntry", "[menu][accelentry]" )
    
    808 808
     {
    
    809
    -    wxMenu* menu = new wxMenu;
    
    809
    +    wxMenu menu;
    
    810 810
     
    
    811
    -    menu->Append( wxID_ANY, "Test" );
    
    812
    -    wxMenuItem* item = menu->FindItemByPosition( 0 );
    
    811
    +    menu.Append( wxID_ANY, "Test" );
    
    812
    +    wxMenuItem* item = menu.FindItemByPosition( 0 );
    
    813 813
     
    
    814 814
         SECTION( "Modifier keys" )
    
    815 815
         {
    
    ... ... @@ -849,4 +849,20 @@ TEST_CASE( "wxMenuItemAccelEntry", "[menu][accelentry]" )
    849 849
         }
    
    850 850
     }
    
    851 851
     
    
    852
    +TEST_CASE("wxMenuItemAccessors", "[menu]")
    
    853
    +{
    
    854
    +    wxMenu menu;
    
    855
    +
    
    856
    +    wxMenuItem* const item = menu.AppendCheckItem(wxID_ANY, "Check");
    
    857
    +
    
    858
    +    // Just check that we can call various functions.
    
    859
    +    CHECK( !item->GetBitmapBundle().IsOk() );
    
    860
    +    CHECK( !item->GetBitmap().IsOk() );
    
    861
    +
    
    862
    +#ifdef __WXMSW__
    
    863
    +    CHECK( !item->GetBitmapBundle(true).IsOk() );
    
    864
    +    CHECK( !item->GetBitmap(true).IsOk() );
    
    865
    +#endif // __WXMSW__
    
    866
    +}
    
    867
    +
    
    852 868
     #endif

Reply all
Reply to author
Forward
0 new messages