From 2c4f42608b2c5aae6b8aa934ed0fce49a6db2294 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Dec 2019 00:05:16 +0100 Subject: [PATCH 1/2] Avoid spurious error from wxThread::SetPriority() in wxMSW Just skip calling ::SetThreadPriority() if the thread hadn't been created yet: this was useless and just resulted in an error message. --- src/msw/thread.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index a04625d4fd..3c3d7c8b74 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -606,6 +606,14 @@ void wxThreadInternal::SetPriority(unsigned int priority) { m_priority = priority; + if ( !m_hThread ) + { + // The thread hasn't been created yet, so calling SetThreadPriority() + // right now would just result in an error -- just skip doing this, as + // the priority will be set when Create() is called later. + return; + } + // translate wxWidgets priority to the Windows one int win_priority; if (m_priority <= 20) From 84f7e925e5d24a97727df72d915db4046b61c56c Mon Sep 17 00:00:00 2001 From: Lauri Nurmi Date: Fri, 20 Dec 2019 11:01:07 +0200 Subject: [PATCH 2/2] Fix wxThread::SetPriority() documentation The documentation's notes about MSW limitations about setting priority before creating the thread do not appear to be true (anymore). Thread priority is already set by Create() if SetPriority() was called earlier. Setting it immediately just failed, because the thread did not exist yet, but this was fixed by the previous commit. --- include/wx/thread.h | 3 --- interface/wx/thread.h | 5 ----- 2 files changed, 8 deletions(-) diff --git a/include/wx/thread.h b/include/wx/thread.h index d21ea64d23..5a0ac27514 100644 --- a/include/wx/thread.h +++ b/include/wx/thread.h @@ -559,9 +559,6 @@ public: // priority // Sets the priority to "prio" which must be in 0..100 range (see // also wxPRIORITY_XXX constants). - // - // NB: under MSW the priority can only be set after the thread is - // created (but possibly before it is launched) void SetPriority(unsigned int prio); // Get the current priority. diff --git a/interface/wx/thread.h b/interface/wx/thread.h index 8f26acc33a..2ee4a1de72 100644 --- a/interface/wx/thread.h +++ b/interface/wx/thread.h @@ -1267,11 +1267,6 @@ public: - @c wxPRIORITY_DEFAULT: 50 - @c wxPRIORITY_MAX: 100 - Notice that in the MSW implementation the thread priority can currently - be only set after creating the thread with CreateThread(). But under - all platforms this method can be called either before launching the - thread using Run() or after doing it. - Please note that currently this function is not implemented when using the default (@c SCHED_OTHER) scheduling policy under POSIX systems. */