Re-implemented reference counting for JobObject.

This commit is contained in:
LoRd_MuldeR 2014-12-06 01:10:27 +01:00
parent 1da760139a
commit f602bfa6c9
4 changed files with 17 additions and 5 deletions

View File

@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 12.0.31101.0 VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LameXP", "LameXP_VS2013.vcxproj", "{00FE736A-8DB1-41B3-B915-4CD8DB09EF48}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LameXP", "LameXP_VS2013.vcxproj", "{00FE736A-8DB1-41B3-B915-4CD8DB09EF48}"
ProjectSection(ProjectDependencies) = postProject
{55405FE1-149F-434C-9D72-4B64348D2A08} = {55405FE1-149F-434C-9D72-4B64348D2A08}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MUtilities", "..\MUtilities\MUtilities_VS2013.vcxproj", "{55405FE1-149F-434C-9D72-4B64348D2A08}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MUtilities", "..\MUtilities\MUtilities_VS2013.vcxproj", "{55405FE1-149F-434C-9D72-4B64348D2A08}"
EndProject EndProject

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 1 #define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 5 #define VER_LAMEXP_PATCH 5
#define VER_LAMEXP_BUILD 1616 #define VER_LAMEXP_BUILD 1617
#define VER_LAMEXP_CONFG 1558 #define VER_LAMEXP_CONFG 1558
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -43,6 +43,7 @@
*/ */
QScopedPointer<JobObject> AbstractTool::s_jobObject; QScopedPointer<JobObject> AbstractTool::s_jobObject;
QMutex AbstractTool::s_jobObjMtx; QMutex AbstractTool::s_jobObjMtx;
quint64 AbstractTool::s_jobObjCnt = 0ui64;
/* /*
* Process Timer * Process Timer
@ -60,15 +61,16 @@ static const quint64 START_DELAY_NANO = quint64(START_DELAY) * 10000ui64; //in 1
* Constructor * Constructor
*/ */
AbstractTool::AbstractTool(void) AbstractTool::AbstractTool(void)
:
m_firstLaunch(true)
{ {
QMutexLocker lock(&s_jobObjMtx); QMutexLocker lock(&s_jobObjMtx);
if(s_jobObject.isNull()) if(s_jobObjCnt++ == 0)
{ {
s_jobObject.reset(new JobObject()); s_jobObject.reset(new JobObject());
} }
m_firstLaunch = true;
} }
/* /*
@ -76,6 +78,12 @@ AbstractTool::AbstractTool(void)
*/ */
AbstractTool::~AbstractTool(void) AbstractTool::~AbstractTool(void)
{ {
QMutexLocker lock(&s_jobObjMtx);
if(--s_jobObjCnt == 0)
{
s_jobObject.reset(NULL);
}
} }
/* /*
@ -102,7 +110,7 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
if(process.waitForStarted()) if(process.waitForStarted())
{ {
if(s_jobObject) if(!s_jobObject.isNull())
{ {
if(!s_jobObject->addProcessToJob(&process)) if(!s_jobObject->addProcessToJob(&process))
{ {

View File

@ -52,6 +52,7 @@ private:
static QScopedPointer<JobObject> s_jobObject; static QScopedPointer<JobObject> s_jobObject;
static QMutex s_jobObjMtx; static QMutex s_jobObjMtx;
static quint64 s_jobObjCnt;
bool m_firstLaunch; bool m_firstLaunch;
}; };