Do not log bogus system error in wxRenameFile() on non-Windows (PR #25985)

44 views
Skip to first unread message

Lauri Nurmi

unread,
Nov 23, 2025, 8:55:16 AM (9 days ago) Nov 23
to wx-...@googlegroups.com, Subscribed

On non-Windows, there is no failed system call in the case when destination file exists, so there is no relevant system error available either.


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

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

Commit Summary

  • f153989 Do not log bogus system error in wxRenameFile() on non-Windows

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25985@github.com>

VZ

unread,
Nov 23, 2025, 10:17:35 AM (9 days ago) Nov 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25985)

Maybe I'm confused, but I think that there is no system call under Windows either: this error is only given if !overwrite but ::ReplaceFile() is called only if overwrite.

So shouldn't this wxLogSysError() be just replaced with wxLogError() unconditionally?


Reply to this email directly, view it on GitHub, or unsubscribe.

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

Lauri Nurmi

unread,
Nov 24, 2025, 4:02:31 AM (8 days ago) Nov 24
to wx-...@googlegroups.com, Subscribed
lanurmi left a comment (wxWidgets/wxWidgets#25985)

Oh, apparently I was confused and misread the code. I'll push a fixup that calls wxLogError(), and additionally logs a system error if ::ReplaceFile() failed.


Reply to this email directly, view it on GitHub, or unsubscribe.

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

Lauri Nurmi

unread,
Nov 24, 2025, 4:02:59 AM (8 days ago) Nov 24
to wx-...@googlegroups.com, Push

@lanurmi pushed 1 commit.

  • 87af775 fixup! Do not log bogus system error in wxRenameFile() on non-Windows


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25985/before/f1539892f0466a43888c7c479052ba90354ec733/after/87af7759432fc832d11ee01f0a08cae156614433@github.com>

PB

unread,
Nov 24, 2025, 6:43:43 AM (8 days ago) Nov 24
to wx-...@googlegroups.com, Subscribed

@PBfordev commented on this pull request.


In src/common/filefn.cpp:

> @@ -593,6 +593,14 @@ wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
         {
             return true;
         }
+        else
+        {
+            wxLogSysError
+            (
+                _("Failed to rename the file '%s' to '%s' by overwriting the already existing destination file"),
+                file1.c_str(), file2.c_str()

Do we need those two c_str() calls here? I thought it has been safe to pass wxString directly to wx vararg functions since at least v2.9?

Also, by changing the message, we are losing its translations...


Reply to this email directly, view it on GitHub, or unsubscribe.

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

VZ

unread,
Nov 24, 2025, 8:38:23 AM (8 days ago) Nov 24
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.


In src/common/filefn.cpp:

> @@ -593,6 +593,14 @@ wxRenameFile(const wxString& file1, const wxString& file2, bool overwrite)
         {
             return true;
         }
+        else
+        {
+            wxLogSysError
+            (
+                _("Failed to rename the file '%s' to '%s' by overwriting the already existing destination file"),
+                file1.c_str(), file2.c_str()

We definitely don't need c_str()s, there are just unfortunately many of them left over.

But this is not a changed message, it's a new one, so this is not a problem.

What is a problem, however, is that we give an error before potentially succeeding in renaming the file ourselves below, which is definitely confusing and I would say wrong. I think we'll just have to live without a specific error in this case because otherwise you'd need more extensive changes (like remembering last error here and using it below, for wxMSW only).


Reply to this email directly, view it on GitHub, or unsubscribe.

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

Lauri Nurmi

unread,
Nov 25, 2025, 7:06:56 AM (7 days ago) Nov 25
to wx-...@googlegroups.com, Push

@lanurmi pushed 1 commit.

  • bb56b21 Do not log bogus system error in wxRenameFile()


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/25985/before/87af7759432fc832d11ee01f0a08cae156614433/after/bb56b21a6e9f7240b19f586da81b23c868aa1afd@github.com>

VZ

unread,
Nov 28, 2025, 11:04:46 AM (4 days ago) Nov 28
to wx-...@googlegroups.com, Subscribed

Closed #25985 via b261545.


Reply to this email directly, view it on GitHub, or unsubscribe.

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

Reply all
Reply to author
Forward
0 new messages