Use range-based for loops in dialup and mediaplayer samples (PR #26640)

56 views
Skip to first unread message

Nong Thi Quynh Anh

unread,
Jun 27, 2026, 9:22:54 AMJun 27
to wx-...@googlegroups.com, Subscribed

This PR modernizes loops in the samples/ directory by replacing index‑based iteration with C++11 range‑based for loops where appropriate.

  • These changes improve readability and reduce the risk of indexing errors.
  • Only loops that do not rely on the index for logic were modified.
  • No behavior changes are introduced.

You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26640

Commit Summary

  • b063caa Use range-based for loops in dialup and mediaplayer samples

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640@github.com>

Nong Thi Quynh Anh

unread,
Jun 27, 2026, 10:54:08 AMJun 27
to wx-...@googlegroups.com, Subscribed
anhnong90 left a comment (wxWidgets/wxWidgets#26640)

Hi, just a small note:
The Ubuntu 18.04 GTK2/GTK3 jobs seem to fail due to the CI environment itself. The logs show a PPA/GPG issue during setup, long before the build reaches any of the sample code. All other platforms passed fine. This PR only updates simple loops in the samples and doesn’t change behavior.
Thanks a lot for taking a look!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c4818535312@github.com>

VZ

unread,
Jun 27, 2026, 12:35:10 PMJun 27
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26640)

Thanks, this can be merged but are these the only example of for loops that could be modernized? I'm a bit surprised by this... Have you done this manually or did you try running clang-tidy which I think has a check to do this automatically?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c4819174501@github.com>

Nong Thi Quynh Anh

unread,
Jun 27, 2026, 1:13:36 PMJun 27
to wx-...@googlegroups.com, Subscribed
anhnong90 left a comment (wxWidgets/wxWidgets#26640)

Thanks for the feedback!

I found these loops while working through the samples/, and decided to modernize them to make the sample code a bit clearer for newer learners. I searched the samples/ folder using some useful commands like:

git grep -n "for (size_t" samples/
git grep -n "for.*size_t.*<.*Count"

and manually checked each match to ensure it was safe to convert. These were the only cases that met the criteria.

I haven’t used clang‑tidy for this pass, but I’m happy to do so — and I’m also willing to continue in this direction in more areas if that would be helpful.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c4819595929@github.com>

Nong Thi Quynh Anh

unread,
Jun 30, 2026, 7:55:42 PMJun 30
to wx-...@googlegroups.com, Push

@anhnong90 pushed 2 commits.

  • 2e09f4f Merge branch 'master' into modernize-sample-loops
  • 187af2e Modernize loops across core source files using clang-tidy


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/before/b063caa23f0f59a791a63aaf2117de386ef2d625/after/187af2ed3b7bdf859e12be381c8d61971505c1d9@github.com>

VZ

unread,
Jun 30, 2026, 8:45:42 PMJun 30
to wx-...@googlegroups.com, Subscribed

@vadz requested changes on this pull request.

Sorry, I stopped reviewing after the first few files because while the changes are good, per se, we really should use loop variable names that make sense. Could you please recheck them? TIA!


In include/wx/private/fswatcher.h:

> @@ -87,11 +87,9 @@ class wxFSWatcherImpl
     virtual bool RemoveAll()
     {
         bool ret = true;
-        for ( wxFSWatchEntries::iterator it = m_watches.begin();
-              it != m_watches.end();
-              ++it )
+        for (auto & m_watche : m_watches)

Not sure if this is clang-tidy doing, but this variable name is bad, it should be watch, of course.

It should also probably be const...


In include/wx/unix/pipe.h:

> @@ -80,12 +80,12 @@ class wxPipe
     // close the pipe descriptors
     void Close()
     {
-        for ( size_t n = 0; n < WXSIZEOF(m_fds); n++ )
+        for (int & m_fd : m_fds)

This one should be called fd.


In include/wx/arrstr.h:

> @@ -128,8 +128,8 @@ class WXDLLIMPEXP_BASE wxSortedArrayString : public wxSortedArrayStringBase
     {
         reserve(src.size());
 
-        for ( size_t n = 0; n < src.size(); n++ )
-            Add(src[n]);
+        for (const auto & n : src)

There is a real problem with the loop variable names. This one should be called s or str, not n.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/review/4604974707@github.com>

Nong Thi Quynh Anh

unread,
Jul 1, 2026, 11:45:23 AMJul 1
to wx-...@googlegroups.com, Subscribed
anhnong90 left a comment (wxWidgets/wxWidgets#26640)

Yes, this was the automated behavior of clang-tidy, which unfortunately generated poor variable names. I ran clang-tidy with the modernize-loop-convert checker across the entire repository (src/, include/, interface/, and tests/). In the samples/ directory, clang-tidy found no additional loops requiring modification beyond my initial manual changes.

I am currently reviewing all modified files to manually rename the loop variables according to the codebase conventions.

Thank you for the feedback!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c4857165423@github.com>

Nong Thi Quynh Anh

unread,
Jul 3, 2026, 9:28:13 PMJul 3
to wx-...@googlegroups.com, Push

@anhnong90 pushed 3 commits.

  • 675b7c4 Use range-based for loops in dialup and mediaplayer samples
  • 5ab606e Modernize loops across core source files using clang-tidy
  • ba7183a Modernize safe for-loops; revert unsafe internal containers


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/before/187af2ed3b7bdf859e12be381c8d61971505c1d9/after/ba7183abedabaa2306c2318a18c1bd2d19016ceb@github.com>

Nong Thi Quynh Anh

unread,
Jul 4, 2026, 3:39:03 PMJul 4
to wx-...@googlegroups.com, Subscribed
anhnong90 left a comment (wxWidgets/wxWidgets#26640)

The modernized loop conversions compile successfully locally, and local test execution passes 100% cleanly when using a stable display server backend (GDK_BACKEND=x11).
The three GUI pipeline failures on Grid::Size are known spurious UI automation bugs tracked under Upstream Issue #25779. The CI output logs explicitly show a warning that a timed-out waiting for mouse release to be processed, which means the simulated column-drag actions timed out or were swallowed by the virtual cloud displays before the layout metrics updated. Could you please take a look, @vadz?
Thank you!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c4883585653@github.com>

VZ

unread,
Jul 6, 2026, 7:40:28 PMJul 6
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26640)

Thanks, I'll have a look at it but there will be some delay, sorry.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c4898607594@github.com>

VZ

unread,
Jul 20, 2026, 1:34:39 PM (18 hours ago) Jul 20
to wx-...@googlegroups.com, Push

@vadz pushed 1 commit.

  • 9a770d4 Don't compile the loop containing wxASSERT when it does nothing


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/before/ba7183abedabaa2306c2318a18c1bd2d19016ceb/after/9a770d401c28d758a5998bfa0729da089de99bd8@github.com>

VZ

unread,
Jul 20, 2026, 1:35:20 PM (18 hours ago) Jul 20
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26640)

FYI, I've pushed a small fix for the 2 real CI failures.

If/when the CI builds pass, I'll look the changes over one more time and merge them, thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26640/c5025217493@github.com>

Reply all
Reply to author
Forward
0 new messages