×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

When one kstars.exe is quited, then all kstars.exe are terminated.

  • Posts: 186
  • Thank you received: 27
I have multiple KStars for Windows running on one PC and when I terminate one, all KStars are terminated.

The reason is that the following code is used to terminate KStars for Windows.
taskkill terminates all running kstars.

kstars.cpp.
in KStars::~KStars()
#ifdef Q_OS_WIN
    QProcess::execute("taskkill /im kstars.exe /f");
#endif

It is commented in kstars.cpp that this is bug workaround code for Qt 5.8 as of 2016-11-24.
Is this Qt bug still unfixed today?

If the Qt bug is not fixed, is it possible to kill only a specific kstars.exe by specifying its PID instead of killing all kstars.exe?
8 months 3 weeks ago #94441

Please Log in or Create an account to join the conversation.

Yes it's worth checking if the bug is gone
The following user(s) said Thank You: tkakura
8 months 3 weeks ago #94497

Please Log in or Create an account to join the conversation.

  • Posts: 186
  • Thank you received: 27
Can you please tell me the ID of the KDE Bugtracking System for this issue?
8 months 2 weeks ago #94767

Please Log in or Create an account to join the conversation.

  • Posts: 186
  • Thank you received: 27
Hi Jasem

I wrote code to kill only the current kstars.exe process with taskkill.
I don't know the original Issue so I am not sure if this is really correct.
Do you have a record of that Issue, such as a BTS ticket?
Also, if Qt's own bug is fixed, then this code is also unnecessary.

Before fix
QProcess::execute("taskkill /im kstars.exe /f");
The taskkill command kills all running kstars.exe processes.

After Fix
QProcess::execute("taskkill /pid <Current kstars own PID> /f");
Specifying the PID of the process executing this code itself, taskkill kills a single kstars.exe process.


Patch created by git diff
diff --git a/kstars/kstars.cpp b/kstars/kstars.cpp
index 941e93977..99696b599 100644
--- a/kstars/kstars.cpp
+++ b/kstars/kstars.cpp
@@ -275,7 +275,13 @@ KStars::~KStars()
          * Hopefully we do not need this hack once the above bug is resolved.
          */
 #ifdef Q_OS_WIN
-    QProcess::execute("taskkill /im kstars.exe /f");
+    qint64 kstarsPid = QCoreApplication::applicationPid();
+    QString killCmd;
+    killCmd += "taskkill /pid ";
+    killCmd += QString::number(kstarsPid);
+    killCmd += " /f";
+
+    QProcess::execute(killCmd);
 #endif
 }
The following user(s) said Thank You: Jasem Mutlaq
8 months 2 weeks ago #94786
Attachments:

Please Log in or Create an account to join the conversation.

Maybe this is at all not required now? Maybe we should start by commenting that line entirely and checking if KStars shuts down gracefully.
8 months 2 weeks ago #94787

Please Log in or Create an account to join the conversation.

  • Posts: 186
  • Thank you received: 27
I agree with you.
It is best to have it fixed in the latest Qt5.
8 months 2 weeks ago #94793

Please Log in or Create an account to join the conversation.

  • Posts: 186
  • Thank you received: 27
Hi Jasem
Can you please let me know the results? If you can confirm that the QT problem has been fixed.
7 months 3 weeks ago #95623

Please Log in or Create an account to join the conversation.

Time to create page: 2.496 seconds