How to only launch one instance of my program
-
While I get the value of Qt Creator not shutting down previous executions of my application everytime I run or debug my application, this feature gets a little annoying. If I don't pay attention, I can have a dozen instances of my applicatoin runnin simultaneously! Is there a way to make Qt Creator shut down the previous tested application before launching a new one?
In Xcode, everytime I launch my application, it first shuts down the previously executed application and starts a new instance of my app.
Can Qt Creator do the same?
-
-
kloveridge means that the current running instance is not killed if you restart your application e.g. rebuilding and running it.
It might be question better suited for the Qt Creator mailing list
-
Mad Scientist has it right.
-
"Mad Scientist" is just a rank ;)
-
[quote author="SGaist" date="1411934198"]"Mad Scientist" is just a rank ;)[/quote]
I'd say in your case it's true ;-)
-
If the requirement is "only one instance of the application" even when not running it through Qt Creator, look at the qtsingleapplication solution that is part of the "Qt Solutions Archive":https://qt.gitorious.org/qt-solutions.
If it is only related to Qt Creator, I would second SGaist and ask on the Creator Mailing List
-
I have something for you.
I use this to do that:
@
QProcess x;
x.start("tasklist");
x.waitForStarted(200); //1000 avant
x.waitForReadyRead(200);
x.waitForFinished(200);
QString result( x.readAllStandardOutput() );
if(result.count("YOUR_APPLICATION.exe",Qt::CaseInsensitive) >=2 )
{
popupMessage(tr("This application is already running!"),2000,this);
QTimer::singleShot(2000, qApp, SLOT(quit()));
}
@I hope this will help you.
-
I will give this a try. Thanks for your help!