Skip to content

Commit

Permalink
Merge branch 'v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
palindromiq committed Jan 12, 2022
2 parents ff7322b + 3f57869 commit 1a1cd4b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
4 changes: 2 additions & 2 deletions YATE.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CONFIG += c++11 DISCORD_ENABLED
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
VERSION = 1.0.5
VERSION = 1.0.5.1
SOURCES += \
analysisviewitem.cpp \
analysisviewmodel.cpp \
Expand All @@ -22,7 +22,7 @@ SOURCES += \
livefeedbackoverlay.cpp \
logevent.cpp \
main.cpp \
miniz.c \
miniz.cpp \
settingsdialog.cpp \
updater.cpp \
yatewindow.cpp \
Expand Down
14 changes: 10 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const
QTextStream& qStdErr()
{
static QTextStream ts(stderr);
ts.setAutoDetectUnicode(true);
ts.setEncoding(QStringConverter::Utf16);
return ts;
}
QTextStream& qStdOut()
{
static QTextStream ts(stdout);
ts.setAutoDetectUnicode(true);
ts.setEncoding(QStringConverter::Utf16);
return ts;
}
#endif
Expand All @@ -34,6 +38,8 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);



#ifdef QT_DEBUG
qInstallMessageHandler(logMessageHandler);
qDebug() << "YATE Launched";
Expand All @@ -43,6 +49,7 @@ int main(int argc, char *argv[])
}
qDebug() << "Version: " << QApplication::applicationVersion();
qDebug() << "Arguments: " << args.join(", ");

#endif

if (argc >= 5) {
Expand Down Expand Up @@ -84,7 +91,6 @@ int main(int argc, char *argv[])
#ifdef QT_DEBUG
void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : "";
QString logType = "System";
Expand All @@ -108,11 +114,11 @@ void logMessageHandler(QtMsgType type, const QMessageLogContext &context, const
logType = "Fatal";
break;
}
QString txt = QString("[%1] %2: %3 (%4:%5, %6)").arg(QDateTime::currentDateTime().toString()).arg(logType).arg(localMsg.constData()).arg(file).arg(context.line).arg(function);
QString txt = QString("[%1] %2: %3 (%4:%5, %6)").arg(QDateTime::currentDateTime().toString()).arg(logType).arg(msg).arg(file).arg(context.line).arg(function);
if (isStdOut) {
qStdOut() << txt.toLocal8Bit().data() << Qt::endl;
qStdOut() << txt << Qt::endl;
} else {
qStdErr() << txt.toLocal8Bit().data() << Qt::endl;
qStdErr() << txt << Qt::endl;
}
QFile outFile("yate.log");
outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
Expand Down
17 changes: 13 additions & 4 deletions miniz.c → miniz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
* THE SOFTWARE.
*
**************************************************************************/

#include <QDebug>
#include <QFile>


typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1];
Expand Down Expand Up @@ -2999,9 +3000,17 @@ extern "C" {
#if defined(_MSC_VER) || defined(__MINGW64__)
static FILE *mz_fopen(const char *pFilename, const char *pMode)
{
FILE *pFile = NULL;
fopen_s(&pFile, pFilename, pMode);
return pFile;
QFile qf(pFilename);
qf.open(QIODevice::ReadWrite);
int fd = qf.handle();
FILE* f = fdopen(dup(fd), pMode);

if (!f) {
qCritical() << errno << strerror(errno);
}

return f;

}
static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
{
Expand Down
3 changes: 2 additions & 1 deletion yatewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <QClipboard>
#include <QInputDialog>



#include "globals.h"
#include "settingsdialog.h"
#include "analysiswindow.h"
Expand Down Expand Up @@ -110,7 +112,6 @@ YATEWindow::YATEWindow(QWidget *parent)

qDebug() << "Main window initialized.";


}

void Yate::YATEWindow::initDiscord()
Expand Down
12 changes: 5 additions & 7 deletions zipmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ bool ZipManager::unzip(QString sourceArchive, QString destDir)
mz_zip_archive zipArchive;
memset(&zipArchive, 0, sizeof(zipArchive));
mz_bool status;
auto sourceArchiveBA = sourceArchive.toUtf8 ();
const char *sourceArchiveFileName = sourceArchiveBA.data();
status = mz_zip_reader_init_file(&zipArchive, sourceArchiveFileName, 0);
auto sourceArchiveStd = sourceArchive.toStdString();

status = mz_zip_reader_init_file(&zipArchive, sourceArchiveStd.c_str(), 0);
if (!status)
{
qCritical() << "mz_zip_reader_init_file() failed!";
Expand All @@ -38,14 +38,12 @@ bool ZipManager::unzip(QString sourceArchive, QString destDir)
return false;
}

// qDebug() << file_stat.m_filename << file_stat.m_comment << file_stat.m_uncomp_size << file_stat.m_comp_size << mz_zip_reader_is_file_a_directory(&zipArchive, i);
if (mz_zip_reader_is_file_a_directory(&zipArchive, i)) {
continue;
}
QString strippedFileName = QFileInfo(file_stat.m_filename).fileName();
auto extractionFileNameBA = QString(destDir + QDir::separator() + strippedFileName).toUtf8();
const char * extractionFileName = extractionFileNameBA.data();
status = mz_zip_reader_extract_file_to_file(&zipArchive, file_stat.m_filename, extractionFileName, 0);
auto extractionFileNameStd = QString(destDir + QDir::separator() + strippedFileName).toStdString();
status = mz_zip_reader_extract_file_to_file(&zipArchive, file_stat.m_filename, extractionFileNameStd.c_str(), 0);
if (!status)
{
qCritical() << "mz_zip_reader_extract_file_to_file() failed!";
Expand Down

0 comments on commit 1a1cd4b

Please sign in to comment.