check apps conflict
-
is there way to check if 2 identical qt app is running in the same directory?
for example both of same qt apps are try to modify a single file, thus create a conflict, is there anyway to check this type conflict.
-
is there way to check if 2 identical qt app is running in the same directory?
for example both of same qt apps are try to modify a single file, thus create a conflict, is there anyway to check this type conflict.
-
is there way to check if 2 identical qt app is running in the same directory?
for example both of same qt apps are try to modify a single file, thus create a conflict, is there anyway to check this type conflict.
@s002wjh
Qt has a QLockFile class
https://doc.qt.io/qt-5/qlockfile.htmlBut both Qt apps have to use it, from what I understand.
-
you could prevent second app to run by set a same QSharedMemory key to these.
I had this problem.if it can helped, Place this code in the two applications (their main.cpp before app.exec ();):
auto m_location=new QSharedMemory (); m_location->setKey(a_key); if (!memoadd->create (sizeof (int) ) { m_location->attach (); m_location->detach (); if (!m_location->create (sizeof (int))) { //exit(0); or what you want }
-
you could prevent second app to run by set a same QSharedMemory key to these.
I had this problem.if it can helped, Place this code in the two applications (their main.cpp before app.exec ();):
auto m_location=new QSharedMemory (); m_location->setKey(a_key); if (!memoadd->create (sizeof (int) ) { m_location->attach (); m_location->detach (); if (!m_location->create (sizeof (int))) { //exit(0); or what you want }
-
can I lock one of the apps, so if the 2nd apps is running and access certain directory, it output an error
@s002wjh said in check apps conflict:
is there way to check if 2 identical qt app is running in the same directory
can I lock one of the apps, so if the 2nd apps is running and access certain directory, it output an errorYou're going to have to a bit more precise if you want a precise answer. What exactly does "running in the same directory" & "access certain directory" mean to you?
And are you saying your solution is allowed to change the code of both Qt apps?
Some of the proposed solutions here are trying to prevent a second instance of a Qt application from running. But I think you're saying it's OK to run two instances, what you want is only to control simultaneous file/directory access across the processes? Please clarify which kind of solution you are seeking.