Skip to content

Commit d8c611d

Browse files
committed
Merge branch 'avisynth' into feature
2 parents 49fe603 + 858f4ac commit d8c611d

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/avisynth_wrap.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
// Allocate storage for and initialise static members
5454
namespace {
5555
int avs_refcount = 0;
56+
bool failed = false;
5657
#ifdef _WIN32
5758
HINSTANCE hLib = nullptr;
5859
#else
@@ -66,8 +67,8 @@ const AVS_Linkage *AVS_linkage = nullptr;
6667

6768
typedef IScriptEnvironment* __stdcall FUNC(int);
6869

69-
AviSynthWrapper::AviSynthWrapper() {
70-
if (!avs_refcount){
70+
AviSynthWrapper::AviSynthWrapper() try {
71+
if (!avs_refcount++) {
7172
#ifdef _WIN32
7273
#define CONCATENATE(x, y) x ## y
7374
#define _Lstr(x) CONCATENATE(L, x)
@@ -94,15 +95,16 @@ AviSynthWrapper::AviSynthWrapper() {
9495
if (!env)
9596
throw AvisynthError("Failed to create a new avisynth script environment. Avisynth is too old?");
9697

97-
avs_refcount++;
98-
9998
AVS_linkage = env->GetAVSLinkage();
10099

101100
// Set memory limit
102101
const int memoryMax = OPT_GET("Provider/Avisynth/Memory Max")->GetInt();
103102
if (memoryMax)
104103
env->SetMemoryMax(memoryMax);
105104
}
105+
} catch (AvisynthError const&) {
106+
avs_refcount--;
107+
throw;
106108
}
107109

108110
AviSynthWrapper::~AviSynthWrapper() {

0 commit comments

Comments
 (0)