Improved IPC behavior when the running instance does not respond for whatever reason.
This commit is contained in:
parent
ff3f5516d8
commit
72a9145a5d
@ -57,6 +57,7 @@ bool IPCThread::initialize(bool *firstInstance)
|
||||
if(m_sharedMem->create(sizeof(DWORD), QSharedMemory::ReadWrite))
|
||||
{
|
||||
m_firstInstance = m_ipcReady = true;
|
||||
memset(m_sharedMem->data(), 0, sizeof(DWORD));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -76,17 +77,6 @@ bool IPCThread::initialize(bool *firstInstance)
|
||||
return m_ipcReady;
|
||||
}
|
||||
|
||||
void IPCThread::notifyOtherInstance(void)
|
||||
{
|
||||
if(!m_firstInstance)
|
||||
{
|
||||
m_semaphore_w->acquire();
|
||||
DWORD *pidPtr = reinterpret_cast<DWORD*>(m_sharedMem->data());
|
||||
*pidPtr = GetCurrentProcessId();
|
||||
m_semaphore_r->release();
|
||||
}
|
||||
}
|
||||
|
||||
void IPCThread::start(Priority priority)
|
||||
{
|
||||
m_abort = false;
|
||||
@ -96,12 +86,6 @@ void IPCThread::start(Priority priority)
|
||||
throw "IPC not initialized yet !!!";
|
||||
return;
|
||||
}
|
||||
|
||||
if(!m_firstInstance)
|
||||
{
|
||||
qWarning("This is NOT the first instance!");
|
||||
return;
|
||||
}
|
||||
|
||||
QThread::start(priority);
|
||||
}
|
||||
@ -117,6 +101,15 @@ void IPCThread::setAbort(void)
|
||||
|
||||
void IPCThread::run(void)
|
||||
{
|
||||
if(!m_firstInstance)
|
||||
{
|
||||
m_semaphore_w->acquire();
|
||||
DWORD *pidPtr = reinterpret_cast<DWORD*>(m_sharedMem->data());
|
||||
*pidPtr = GetCurrentProcessId();
|
||||
m_semaphore_r->release();
|
||||
return;
|
||||
}
|
||||
|
||||
forever
|
||||
{
|
||||
if(!m_semaphore_r->acquire())
|
||||
|
@ -37,7 +37,6 @@ public:
|
||||
|
||||
void setAbort(void);
|
||||
bool initialize(bool *firstInstance = NULL);
|
||||
void notifyOtherInstance(void);
|
||||
|
||||
signals:
|
||||
void instanceCreated(DWORD pid);
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 0
|
||||
#define VER_X264_PATCH 2
|
||||
#define VER_X264_BUILD 238
|
||||
#define VER_X264_BUILD 243
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2146
|
||||
#define VER_X264_CURRENT_API 120
|
||||
|
@ -638,12 +638,17 @@ void MainWindow::init(void)
|
||||
bool firstInstance = false;
|
||||
if(m_ipcThread->initialize(&firstInstance))
|
||||
{
|
||||
m_ipcThread->start();
|
||||
if(!firstInstance)
|
||||
{
|
||||
m_ipcThread->notifyOtherInstance();
|
||||
if(!m_ipcThread->wait(5000))
|
||||
{
|
||||
QMessageBox::warning(this, tr("Not Responding"), tr("<nobr>Another instance of this application is already running, but did not respond in time.<br>If the problem persists, please kill the running instance from the task manager!</nobr>"), tr("Quit"));
|
||||
m_ipcThread->terminate();
|
||||
m_ipcThread->wait();
|
||||
}
|
||||
close(); qApp->exit(-1); return;
|
||||
}
|
||||
m_ipcThread->start();
|
||||
}
|
||||
|
||||
//Check all binaries
|
||||
@ -831,7 +836,7 @@ void MainWindow::handleDroppedFiles(void)
|
||||
|
||||
void MainWindow::instanceCreated(DWORD pid)
|
||||
{
|
||||
qDebug("Notification from other instance received!");
|
||||
qDebug("Notification from other instance (PID=0x%X) received!", pid);
|
||||
|
||||
FLASHWINFO flashWinInfo;
|
||||
memset(&flashWinInfo, 0, sizeof(FLASHWINFO));
|
||||
|
Loading…
Reference in New Issue
Block a user