mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
ugly fix for crash opening rar files in Unix systems (posible memory leak added...) (7z.so there are issues with special chars in paths: ?????, etc)
This commit is contained in:
parent
254be28189
commit
8ec24a9985
@ -67,16 +67,12 @@ struct SevenZipInterface {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CMyComPtr<IInArchive> archive;
|
CMyComPtr<IInArchive> archive;
|
||||||
|
|
||||||
//---
|
|
||||||
CInFileStream *fileSpec;
|
|
||||||
CMyComPtr<IInStream> file;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//SevenZipInterface * szInterface;
|
//SevenZipInterface * szInterface;
|
||||||
|
|
||||||
CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) :
|
CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent) :
|
||||||
QObject(parent),sevenzLib(0),valid(false),tools(false)
|
QObject(parent),sevenzLib(0),valid(false),tools(false),isRar(false)
|
||||||
{
|
{
|
||||||
szInterface = new SevenZipInterface;
|
szInterface = new SevenZipInterface;
|
||||||
//load functions
|
//load functions
|
||||||
@ -104,10 +100,16 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
|||||||
//GUID uuid = supportedFileFormats[i];
|
//GUID uuid = supportedFileFormats[i];
|
||||||
//qDebug() << "trying : " << uuid << endl;
|
//qDebug() << "trying : " << uuid << endl;
|
||||||
if (szInterface->createObjectFunc(&supportedFileFormats[i], &IID_InArchive, (void **)&szInterface->archive) != S_OK)
|
if (szInterface->createObjectFunc(&supportedFileFormats[i], &IID_InArchive, (void **)&szInterface->archive) != S_OK)
|
||||||
|
{
|
||||||
|
qDebug() << "wrong format";
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!fileSpec->Open((LPCTSTR)filePath.toStdWString().data()))
|
if (!fileSpec->Open((LPCTSTR)filePath.toStdWString().data()))
|
||||||
|
{
|
||||||
|
qDebug() << "unable to load" + filePath;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
//qDebug() << "Can not open archive file : " + filePath << endl;
|
//qDebug() << "Can not open archive file : " + filePath << endl;
|
||||||
|
|
||||||
if (szInterface->archive->Open(file, 0, openCallback) == S_OK)
|
if (szInterface->archive->Open(file, 0, openCallback) == S_OK)
|
||||||
@ -115,6 +117,8 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
|||||||
valid = formatFound = true;
|
valid = formatFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
qDebug() << "Can not open archive file : " + filePath << endl;
|
||||||
}
|
}
|
||||||
if(!formatFound)
|
if(!formatFound)
|
||||||
{
|
{
|
||||||
@ -150,6 +154,7 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
|||||||
if (szInterface->archive->Open(file, 0, openCallback) == S_OK)
|
if (szInterface->archive->Open(file, 0, openCallback) == S_OK)
|
||||||
{
|
{
|
||||||
valid = formatFound = true;
|
valid = formatFound = true;
|
||||||
|
isRar = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
qDebug() << "Error opening rar archive";
|
qDebug() << "Error opening rar archive";
|
||||||
@ -162,7 +167,10 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
|
|||||||
|
|
||||||
CompressedArchive::~CompressedArchive()
|
CompressedArchive::~CompressedArchive()
|
||||||
{
|
{
|
||||||
//szInterface->fileSpec->Release();
|
#ifdef Q_OS_UNIX
|
||||||
|
if(isRar) //TODO: fix this!!! Posible memory leak. If AddRef is not used, a crash occurs in "delete szInterface"
|
||||||
|
szInterface->archive->AddRef();
|
||||||
|
#endif
|
||||||
delete szInterface;
|
delete szInterface;
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
delete rarLib;
|
delete rarLib;
|
||||||
@ -336,7 +344,7 @@ STDMETHODIMP CompressedArchive::CreateDecoder(UInt32 index, const GUID *interfac
|
|||||||
|
|
||||||
STDMETHODIMP CompressedArchive::CreateEncoder(UInt32 index, const GUID *interfaceID, void **coder)
|
STDMETHODIMP CompressedArchive::CreateEncoder(UInt32 index, const GUID *interfaceID, void **coder)
|
||||||
{
|
{
|
||||||
return szInterface->createObjectFuncRar(&CLSID_CFormatRar,interfaceID,coder);
|
return S_OK;//szInterface->createObjectFuncRar(&CLSID_CFormatRar,interfaceID,coder);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,6 +51,8 @@ public:
|
|||||||
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||||
STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder);
|
STDMETHOD(CreateDecoder)(UInt32 index, const GUID *iid, void **coder);
|
||||||
STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder);
|
STDMETHOD(CreateEncoder)(UInt32 index, const GUID *iid, void **coder);
|
||||||
|
|
||||||
|
bool isRar;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user