Fixed IPC initialization + some code refactoring.
This commit is contained in:
parent
fa9b468f92
commit
3cb8f41b0e
@ -179,6 +179,7 @@ unsigned int x264_version_x264_avs2yuv_ver(void);
|
|||||||
#define _X264_MAKE_STRING_(X) #X
|
#define _X264_MAKE_STRING_(X) #X
|
||||||
#define X264_MAKE_STRING(X) _X264_MAKE_STRING_(X)
|
#define X264_MAKE_STRING(X) _X264_MAKE_STRING_(X)
|
||||||
#define X264_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" X264_MAKE_STRING(__LINE__) ") : warning: " TXT))
|
#define X264_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" X264_MAKE_STRING(__LINE__) ") : warning: " TXT))
|
||||||
|
#define X264_STRCMP(X,Y) ((X).compare((Y), Qt::CaseInsensitive) == 0)
|
||||||
|
|
||||||
//Debug build
|
//Debug build
|
||||||
#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
|
#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@ -78,7 +78,7 @@ static int x264_main(int argc, char* argv[])
|
|||||||
//Initialize the IPC handler class
|
//Initialize the IPC handler class
|
||||||
bool firstInstance = false;
|
bool firstInstance = false;
|
||||||
IPC *ipc = new IPC();
|
IPC *ipc = new IPC();
|
||||||
if(!ipc->initialize(firstInstance))
|
if(ipc->initialize(firstInstance))
|
||||||
{
|
{
|
||||||
if(!firstInstance)
|
if(!firstInstance)
|
||||||
{
|
{
|
||||||
@ -123,7 +123,9 @@ static int x264_main(int argc, char* argv[])
|
|||||||
//Taskbar uninit
|
//Taskbar uninit
|
||||||
WinSevenTaskbar::init();
|
WinSevenTaskbar::init();
|
||||||
|
|
||||||
|
//Clean up
|
||||||
X264_DELETE(mainWin);
|
X264_DELETE(mainWin);
|
||||||
|
X264_DELETE(ipc);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +141,7 @@ void handleMultipleInstances(QStringList args, IPC *ipc)
|
|||||||
while(!args.isEmpty())
|
while(!args.isEmpty())
|
||||||
{
|
{
|
||||||
const QString current = args.takeFirst();
|
const QString current = args.takeFirst();
|
||||||
if((current.compare("--add", Qt::CaseInsensitive) == 0) || (current.compare("--add-file", Qt::CaseInsensitive) == 0))
|
if(X264_STRCMP(current, "--add") || X264_STRCMP(current, "--add-file"))
|
||||||
{
|
{
|
||||||
if(!args.isEmpty())
|
if(!args.isEmpty())
|
||||||
{
|
{
|
||||||
@ -154,7 +156,7 @@ void handleMultipleInstances(QStringList args, IPC *ipc)
|
|||||||
qWarning("Argument for '--add-file' is missing!");
|
qWarning("Argument for '--add-file' is missing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(current.compare("--add-job", Qt::CaseInsensitive) == 0)
|
else if(X264_STRCMP(current, "--add-job"))
|
||||||
{
|
{
|
||||||
if(args.size() >= 3)
|
if(args.size() >= 3)
|
||||||
{
|
{
|
||||||
@ -170,6 +172,14 @@ void handleMultipleInstances(QStringList args, IPC *ipc)
|
|||||||
args.clear();
|
args.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!current.startsWith("--"))
|
||||||
|
{
|
||||||
|
qWarning("Unknown argument: %s", current.toUtf8().constData());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//If no argument has been sent yet, send a ping!
|
//If no argument has been sent yet, send a ping!
|
||||||
|
@ -1372,11 +1372,14 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::parseCommandLineArgs(void)
|
void MainWindow::parseCommandLineArgs(void)
|
||||||
{
|
{
|
||||||
QStringList files, args = x264_arguments();
|
QStringList files;
|
||||||
|
QStringList args = x264_arguments();
|
||||||
|
args.takeFirst(); //Pop argv[0]
|
||||||
|
|
||||||
while(!args.isEmpty())
|
while(!args.isEmpty())
|
||||||
{
|
{
|
||||||
QString current = args.takeFirst();
|
QString current = args.takeFirst();
|
||||||
if((current.compare("--add", Qt::CaseInsensitive) == 0) || (current.compare("--add-file", Qt::CaseInsensitive) == 0))
|
if(X264_STRCMP(current, "--add") || X264_STRCMP(current, "--add-file"))
|
||||||
{
|
{
|
||||||
if(!args.isEmpty())
|
if(!args.isEmpty())
|
||||||
{
|
{
|
||||||
@ -1395,7 +1398,7 @@ void MainWindow::parseCommandLineArgs(void)
|
|||||||
qWarning("Argument for '--add-file' is missing!");
|
qWarning("Argument for '--add-file' is missing!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(current.compare("--add-job", Qt::CaseInsensitive) == 0)
|
else if(X264_STRCMP(current, "--add-job"))
|
||||||
{
|
{
|
||||||
if(args.size() >= 3)
|
if(args.size() >= 3)
|
||||||
{
|
{
|
||||||
@ -1427,7 +1430,11 @@ void MainWindow::parseCommandLineArgs(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qWarning("Unknown argument: %s", current.toUtf8().constData());
|
if(!current.startsWith("--"))
|
||||||
|
{
|
||||||
|
qWarning("Unknown argument: %s", current.toUtf8().constData());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user