if(m_sharedMem->create(sizeof(DWORD), QSharedMemory::ReadWrite))
{
m_firstInstance = m_ipcReady = true;
+ memset(m_sharedMem->data(), 0, sizeof(DWORD));
}
else
{
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;
throw "IPC not initialized yet !!!";
return;
}
-
- if(!m_firstInstance)
- {
- qWarning("This is NOT the first instance!");
- return;
- }
QThread::start(priority);
}
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())
void setAbort(void);
bool initialize(bool *firstInstance = NULL);
- void notifyOtherInstance(void);
signals:
void instanceCreated(DWORD pid);
#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
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
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));