Fix bugs created by shared_ptr

This commit is contained in:
2025-09-29 04:29:52 -05:00
parent d2b2720ecb
commit bbe0a1cefc
6 changed files with 38 additions and 11 deletions

View File

@@ -2023,6 +2023,7 @@ class GC {
Tesses::Framework::Filesystem::VFSPath SystemToVFSPath(std::string path); Tesses::Framework::Filesystem::VFSPath SystemToVFSPath(std::string path);
void GetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime& lastWrite, Tesses::Framework::Date::DateTime& lastAccess); void GetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime& lastWrite, Tesses::Framework::Date::DateTime& lastAccess);
void SetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime lastWrite, Tesses::Framework::Date::DateTime lastAccess); void SetDate(Tesses::Framework::Filesystem::VFSPath path, Tesses::Framework::Date::DateTime lastWrite, Tesses::Framework::Date::DateTime lastAccess);
void Close();
~TObjectVFS(); ~TObjectVFS();
}; };
@@ -2043,6 +2044,7 @@ class GC {
int64_t GetLength(); int64_t GetLength();
void Flush(); void Flush();
void Seek(int64_t pos, Tesses::Framework::Streams::SeekOrigin whence); void Seek(int64_t pos, Tesses::Framework::Streams::SeekOrigin whence);
void Close();
~TObjectStream(); ~TObjectStream();
}; };

View File

@@ -262,7 +262,7 @@ namespace Tesses::CrossLang {
} }
} }
std::cout << std::setw(3) << progress << "%" << std::flush; std::cout << std::setw(3) << (int)(pdbl*100) << "%" << std::flush;
return Undefined(); return Undefined();
} }
TObject Console_getSize(GCList& ls, std::vector<TObject> args) TObject Console_getSize(GCList& ls, std::vector<TObject> args)

View File

@@ -12,23 +12,24 @@ namespace Tesses::CrossLang {
callable->Call(ls,{0.0}); callable->Call(ls,{0.0});
if(len > 0) if(len > 0)
{ {
std::shared_ptr<uint8_t> buff=std::make_shared<uint8_t>(1024); std::vector<uint8_t> buff(1024);
int64_t pos=0; int64_t pos=0;
int curPercent=0; int curPercent=0;
int lastPercent=0; int lastPercent=0;
size_t read = 0; size_t read = 0;
do { do {
read = src->ReadBlock(buff.get(),1024); read = src->ReadBlock(buff.data(),buff.size());
dest->WriteBlock(buff.get(),read); dest->WriteBlock(buff.data(),read);
if(read == 0) break; if(read == 0) break;
pos += (int64_t)read; pos += (int64_t)read;
double percent = (double)(pos / len); double percent = ((double)pos / len);
percent *= 10000; percent *= 10000.0;
curPercent = (int)percent; curPercent = (int)percent;
if(curPercent > lastPercent) if(curPercent > lastPercent)
{ {
lastPercent = curPercent; lastPercent = curPercent;

View File

@@ -200,8 +200,17 @@ namespace Tesses::CrossLang
} }
} }
void TObjectStream::Close()
{
TDictionary* dict;
if(GetObjectHeap(this->obj, dict))
{
dict->CallMethod(*ls,"Close",{});
}
}
TObjectStream::~TObjectStream() TObjectStream::~TObjectStream()
{ {
Close();
delete this->ls; delete this->ls;
} }

View File

@@ -501,15 +501,19 @@ namespace Tesses::CrossLang {
} }
} }
TObjectVFS::~TObjectVFS() void TObjectVFS::Close()
{ {
TDictionary* dict; TDictionary* dict;
if(GetObjectHeap(this->obj, dict)) if(GetObjectHeap(this->obj, dict))
{ {
GCList ls(this->ls->GetGC()); GCList ls(this->ls->GetGC());
dict->CallMethod(ls,"Dispose",{}); dict->CallMethod(ls,"Close",{});
} }
}
TObjectVFS::~TObjectVFS()
{
Close();
delete this->ls; delete this->ls;
} }

View File

@@ -3483,6 +3483,12 @@ namespace Tesses::CrossLang {
cse.back()->Push(gc, nullptr); cse.back()->Push(gc, nullptr);
return false; return false;
} }
if(key == "Close")
{
strm->Close();
cse.back()->Push(gc, nullptr);
return false;
}
if(key == "Seek") if(key == "Seek")
{ {
int64_t pos,whence; int64_t pos,whence;
@@ -3594,7 +3600,12 @@ namespace Tesses::CrossLang {
return false; return false;
} }
} }
if(key == "Close")
{
vfs->Close();
cse.back()->Push(gc,nullptr);
return false;
}
if(key == "EnumeratePaths") if(key == "EnumeratePaths")
{ {
Tesses::Framework::Filesystem::VFSPath dir; Tesses::Framework::Filesystem::VFSPath dir;