void CBCommand::ProcessFinished ( const JBoolean success, const JBoolean cancelled ) { if (!itsInQueueFlag) { itsSuccessFlag = JI2B(itsSuccessFlag && success); itsCancelledFlag = cancelled; } if (success || itsInQueueFlag) { if (!itsCmdList->IsEmpty() && (itsCmdList->GetElement(1)).isMakeDepend) { assert( !itsInQueueFlag ); CmdInfo info = itsCmdList->GetElement(1); info.Free(kJFalse); // don't delete CBCommand because it is deleting itself itsCmdList->RemoveElement(1); } StartProcess(); // may delete us } else if (!itsCmdList->IsEmpty() && (itsCmdList->GetElement(1)).isMakeDepend) { CmdInfo info = itsCmdList->GetElement(1); info.Free(kJFalse); // don't delete CBCommand because it is deleting itself itsCmdList->RemoveElement(1); DeleteThis(); } else if (!cancelled) { while (!itsCmdList->IsEmpty() && !(itsCmdList->GetElement(1)).IsEndOfSequence()) { CmdInfo info = itsCmdList->GetElement(1); info.Free(kJTrue); itsCmdList->RemoveElement(1); } StartProcess(); // may delete us } else { DeleteThis(); } }
/// \brief /// Decreases the reference counter, should be called when objects remove their reference to /// this object. /// /// Checks that the counter isn't already zero. If this was the last reference, the /// object is deleted. /// /// \returns /// The new ref count. inline unsigned long Release() { int iRefCount = ReleaseNoDelete(); if (iRefCount == 0) { DeleteThis(); } return iRefCount; }
void CGroupObject::OnObjectRemove(const CCustomObject* object) { if (IsOpened()){ m_Objects.remove((CCustomObject*)object); if (m_Objects.empty()){ ELog.Msg (mtInformation,"Group '%s' has no objects and will be removed.",Name); DeleteThis (); } } }
void CGroupObject::OnSceneUpdate() { inherited::OnSceneUpdate(); if (IsOpened()&&(0!=m_PObjects)){ for (SStringVecIt it=m_PObjects->begin(); it!=m_PObjects->end(); it++){ CCustomObject* obj = Scene->FindObjectByName(it->c_str(),(CCustomObject*)0); if (0==obj){ ELog.Msg (mtError,"Group '%s' has invalid reference to object '%s'.",Name,it->c_str()); }else{ m_Objects.push_back (obj); } } xr_delete (m_PObjects); if (m_Objects.empty()){ ELog.Msg (mtInformation,"Group '%s' has no objects and will be removed.",Name); DeleteThis (); } } }
void CGroupObject::OnSceneUpdate() { inherited::OnSceneUpdate(); for (ObjectsInGroup::iterator it=m_ObjectsInGroup.begin(); it!=m_ObjectsInGroup.end(); ++it) { if(it->pObject==NULL) { R_ASSERT(0); /* R_ASSERT(it->ObjectName.size()); CCustomObject* CO = Scene->FindObjectByName(it->ObjectName.c_str(), (CCustomObject*)0); R_ASSERT2 (!CO->m_CO_Flags.test(flObjectInGroup), it->ObjectName.c_str()); it->pObject = CO; string256 buf; Scene->GenObjectName(CO->ClassID, buf, CO->Name); if (CO->Name!=buf) { Msg("OG name changed from[%s] to[%s]",CO->Name, buf); CO->Name = buf; it->ObjectName = buf; } it->pObject->m_CO_Flags.set(flObjectInGroup, TRUE); it->pObject->m_CO_Flags.set(flObjectInGroupUnique, TRUE); if(it->pObject==NULL) ELog.Msg (mtError,"Gr%s' has invalid roup 'eference to object '%s'.", Name, it->ObjectName.c_str()); */ } } if (m_ObjectsInGroup.empty()) { ELog.Msg (mtInformation,"Group '%s' has no objects and will be removed.",Name); DeleteThis (); } }
void NiRefObject::DecRefCount(void) { if (Release()) DeleteThis(); }
JBoolean CBCommand::StartProcess() { // check if we are finished while (!itsCmdList->IsEmpty() && (itsCmdList->GetElement(1)).IsEndOfSequence()) { CmdInfo info = itsCmdList->GetElement(1); info.Free(kJTrue); itsCmdList->RemoveElement(1); } if (itsCmdList->IsEmpty()) { if (itsBeepFlag && itsParent == NULL) { ((JXGetApplication())->GetCurrentDisplay())->Beep(); } DeleteThis(); return kJFalse; } // check if we can use the window itsInQueueFlag = kJFalse; if (itsOutputDoc != NULL && itsOutputDoc->ProcessRunning()) { itsInQueueFlag = kJTrue; ListenTo(itsOutputDoc); return kJTrue; // wait for message from itsOutputDoc } // check if need to run a subroutine CmdInfo info = itsCmdList->GetElement(1); if (info.cmdObj != NULL) { StopListening(itsOutputDoc); // wait for CBCommand to notify us const JBoolean result = (info.cmdObj)->Start(*(info.cmdInfo)); info.Free(kJFalse); itsCmdList->RemoveElement(1); return result; } // start process assert( info.cmd != NULL ); JShouldIncludeCWDOnPath(kJTrue); JProcess* p; int toFD, fromFD; JError execErr = JNoError(); if (itsOutputDoc != NULL) { execErr = JProcess::Create(&p, itsCmdPath, *(info.cmd), kJCreatePipe, &toFD, kJCreatePipe, &fromFD, kJAttachToFromFD, NULL); } else { JSimpleProcess* p1; execErr = JSimpleProcess::Create(&p1, itsCmdPath, *(info.cmd), kJTrue); p = p1; } JShouldIncludeCWDOnPath(kJFalse); if (!execErr.OK()) { execErr.ReportIfError(); DeleteThis(); return kJFalse; } if (itsOutputDoc != NULL) { const JSize count = info.cmd->GetElementCount(); JString cmd; for (JIndex i=1; i<=count; i++) { cmd += JPrepArgForExec(*info.cmd->NthElement(i)); cmd += " "; } itsOutputDoc->SetConnection(p, fromFD, toFD, itsWindowTitle, itsDontCloseMsg, itsCmdPath, cmd, kJTrue); // We can't do this in Start() because we might be waiting for // itsMakeDependCmd. We must not listen to both at the same time. ListenTo(itsOutputDoc); } else { ListenTo(p); JThisProcess::Ignore(p); } info.Free(kJTrue); itsCmdList->RemoveElement(1); return kJTrue; }
JBoolean CBCommand::Start ( const CBCommandManager::CmdInfo& info ) { CBCommandManager* mgr = (itsProjDoc != NULL ? itsProjDoc->GetCommandManager() : CBGetCommandManager()); if (info.isMake) { itsUpdateSymbolDatabaseFlag = kJTrue; CBCommand* p = itsParent; while (p != NULL) { if (p->itsBuildOutputDoc != NULL) { itsOutputDoc = p->itsBuildOutputDoc; break; } p = p->itsParent; } if (itsOutputDoc == NULL) { itsOutputDoc = mgr->GetCompileDoc(itsProjDoc); itsOutputDoc->IncrementUseCount(); } SetCompileDocStrings(); itsBuildOutputDoc = itsOutputDoc; } else if (info.useWindow) { CBCommand* p = itsParent; while (p != NULL) { if (p->itsRunOutputDoc != NULL) { itsOutputDoc = p->itsRunOutputDoc; break; } p = p->itsParent; } if (itsOutputDoc == NULL) { itsOutputDoc = mgr->GetOutputDoc(); itsOutputDoc->IncrementUseCount(); } itsDontCloseMsg = JGetString("RunCloseMsg::CBCommand"); itsWindowTitle = JGetString("RunWindowTitlePrefix::CBCommand"); if (!(info.menuText)->IsEmpty()) { itsWindowTitle += *(info.menuText); } else { itsWindowTitle += *(info.cmd); } itsRunOutputDoc = itsOutputDoc; } if (info.saveAll) // ok, now that we have decided that command can be executed { (CBGetDocumentManager())->SaveTextDocuments(kJFalse); } if (info.isVCS) { itsUpdateSymbolDatabaseFlag = kJTrue; } if (itsUpdateSymbolDatabaseFlag) { (CBGetDocumentManager())->CancelUpdateSymbolDatabases(); } // after saving all files, update Makefile JBoolean waitForMakeDepend = kJFalse; if (info.isMake && itsProjDoc != NULL) { waitForMakeDepend = (itsProjDoc->GetBuildManager())->UpdateMakefile(itsOutputDoc, &itsMakeDependCmd); } if (waitForMakeDepend) { if (itsMakeDependCmd != NULL) { itsCmdList->PrependElement(CmdInfo(NULL, itsMakeDependCmd, NULL, kJTrue)); ListenTo(itsMakeDependCmd); // many may need to hear; can't use SetParent() return kJTrue; } else { DeleteThis(); return kJFalse; } } else if (StartProcess()) { if (itsOutputDoc != NULL && info.raiseWindowWhenStart) { itsOutputDoc->Activate(); } return kJTrue; } else // we have been deleted { return kJFalse; } }
void BSHandleRefObject::DecRefCount(void) { if ((InterlockedDecrement(&m_uiRefCount) & kMask_RefCount) == 0) DeleteThis(); }