This commit is contained in:
DavidXanatos 2023-07-22 10:10:22 +02:00
parent da71c6c69a
commit d1b41c2d9b
4 changed files with 37 additions and 11 deletions

View File

@ -27,6 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- fixed asynchroniusly assigned PCA job not being properly detected [#1919](https://github.com/sandboxie-plus/Sandboxie/issues/1919)
- fixed incompatybility with first windows 10 release [#3117](https://github.com/sandboxie-plus/Sandboxie/issues/3117)
- fixed Remove Sandbox only deletes the contents of the sandbox when an application is running in the sandbox [#3118](https://github.com/sandboxie-plus/Sandboxie/issues/3118)
- fixed crash issue with not peroeprly termianted script engine [#3120](https://github.com/sandboxie-plus/Sandboxie/issues/3120)

View File

@ -22,11 +22,11 @@
#include <private/qv4script_p.h>
#include <private/qv4qobjectwrapper_p.h>
int CBoxEngine::m_InstanceCount = 0;
QSet<CBoxEngine*> CBoxEngine::m_Instances;
CBoxEngine::CBoxEngine(QObject* parent) : QThread(parent)
{
m_InstanceCount++;
m_Instances.insert(this);
m_State = eUnknown;
m_pEngine = NULL;
@ -37,6 +37,13 @@ CBoxEngine::CBoxEngine(QObject* parent) : QThread(parent)
}
CBoxEngine::~CBoxEngine()
{
m_Instances.remove(this);
Stop();
}
void CBoxEngine::Stop()
{
m_Mutex.lock();
if (m_State == eQuery || m_State == eReady)
@ -48,11 +55,16 @@ CBoxEngine::~CBoxEngine()
}
if (!wait(30 * 1000)) {
qDebug() << "Failed to terminate Box Engine";
return;
qDebug() << "Failed to stop Box Engine";
terminate();
m_State = eCanceled;
}
}
m_InstanceCount--;
void CBoxEngine::StopAll()
{
foreach(CBoxEngine* pEngine, m_Instances)
pEngine->Stop();
}
QV4::ReturnedValue method_translate(const QV4::FunctionObject *b, const QV4::Value *v, const QV4::Value *argv, int argc)
@ -288,9 +300,13 @@ QObject* CBoxEngine::GetDebuggerBackend()
// CWizardEngine
//
int CWizardEngine::m_InstanceCount = 0;
CWizardEngine::CWizardEngine(QObject* parent)
: CBoxEngine(parent)
{
m_InstanceCount++;
}
CWizardEngine::~CWizardEngine()
@ -305,6 +321,8 @@ CWizardEngine::~CWizardEngine()
}
}
theAPI->ReloadBoxes(true);
m_InstanceCount--;
}
bool CWizardEngine::ApplyShadowChanges()
@ -376,7 +394,7 @@ QSharedPointer<CSbieIni> CWizardEngine::MakeShadow(const QSharedPointer<CSbieIni
SBoxShadow& pShadow = m_Shadows[pIni->GetName().toLower()];
if (!pShadow.pShadow) {
QString ShadowName = pIni->GetName();
QString Suffix = tr("_Shadow");
QString Suffix = "_Shadow"; // do not translate must be a valid sandbox name suffix
ShadowName.truncate(32 - (Suffix.length() + 3)); // BOXNAME_COUNT
ShadowName = theAPI->MkNewName(ShadowName.append(Suffix));
@ -455,4 +473,4 @@ void CWizardEngine::OpenOptions(const QString& box, const QString& page)
});
//theGUI->SafeExec(pOptionsWnd);
pOptionsWnd->showTab(page);
}
}

View File

@ -14,6 +14,8 @@ public:
bool RunScript(const QString& Script, const QString& Name, const QVariantMap& Params = QVariantMap());
static void StopAll();
enum EState {
eUnknown,
@ -47,8 +49,6 @@ public:
Q_INVOKABLE void AppendLog(const QString& Line);
//QString GetLog() const { QMutexLocker Locker(&m_Mutex); return m_Log; }
static int GetInstanceCount() { return m_InstanceCount; }
CJSEngineExt* GetEngine() { return m_pEngine; }
QObject* GetDebuggerBackend();
@ -71,6 +71,7 @@ protected:
virtual void init();
virtual void run();
virtual void Stop();
//virtual bool Wait();
virtual bool Continue(bool bLocked, EState State = eRunning);
@ -92,7 +93,7 @@ protected:
//QString m_Log;
static int m_InstanceCount;
static QSet<CBoxEngine*> m_Instances;
};
//////////////////////////////////////////////////////////////////////////////////////////
@ -115,6 +116,7 @@ public:
void SetApplyShadow(const QString& OriginalName, bool bApply = true);
bool IsNoAppliedShadow(const QString& OriginalName);
static int GetInstanceCount() { return m_InstanceCount; }
Q_INVOKABLE void OpenSettings(const QString& page);
Q_INVOKABLE void OpenOptions(const QString& box, const QString& page);
@ -136,5 +138,7 @@ protected:
};
QMap<QString, SBoxShadow> m_Shadows;
static int m_InstanceCount;
};

View File

@ -258,6 +258,7 @@ CSandMan::CSandMan(QWidget *parent)
LoadState();
m_pProgressDialog = new CProgressDialog("");
m_pProgressDialog->setWindowTitle("Sandboxie-Plus");
m_pProgressDialog->setWindowModality(Qt::ApplicationModal);
connect(m_pProgressDialog, SIGNAL(Cancel()), this, SLOT(OnCancelAsync()));
m_pProgressModal = false;
@ -313,6 +314,8 @@ CSandMan::~CSandMan()
StoreState();
CBoxEngine::StopAll();
theAPI = NULL;
theGUI = NULL;
@ -1501,7 +1504,7 @@ bool CSandMan::IsFullyPortable()
bool CSandMan::KeepTerminated()
{
if (CBoxEngine::GetInstanceCount() > 0)
if (CWizardEngine::GetInstanceCount() > 0)
return true;
return m_pKeepTerminated && m_pKeepTerminated->isChecked();
}