This commit is contained in:
Felix Kauselmann 2015-03-20 18:27:20 +01:00
commit 115fcc7afb
4 changed files with 36 additions and 12 deletions

View File

@ -211,6 +211,7 @@ ImportWidget::ImportWidget(QWidget *parent) :
previousWidth = 10; previousWidth = 10;
updatingCovers = false; updatingCovers = false;
elapsedTimer = new QElapsedTimer(); elapsedTimer = new QElapsedTimer();
elapsedTimer->start();
} }
void ImportWidget::newComic(const QString & path, const QString & coverPath) void ImportWidget::newComic(const QString & path, const QString & coverPath)

View File

@ -13,6 +13,22 @@
#include "startup.h" #include "startup.h"
#include "yacreader_global.h" #include "yacreader_global.h"
#include <algorithm>
bool ipComparator(const QString & ip1, const QString & ip2)
{
if(ip1.startsWith("192.168") && ip2.startsWith("192.168"))
return ip1 < ip2;
if(ip1.startsWith("192.168"))
return true;
if(ip2.startsWith("192.168"))
return false;
return ip1 < ip2;
}
#ifndef Q_OS_WIN32 #ifndef Q_OS_WIN32
#include <sys/types.h> #include <sys/types.h>
@ -166,7 +182,7 @@ ServerConfigDialog::ServerConfigDialog(QWidget * parent)
settings->endGroup(); settings->endGroup();
connect(check,SIGNAL(stateChanged(int)),this,SLOT(enableServer(int))); connect(check,SIGNAL(stateChanged(int)),this,SLOT(enableServer(int)));
} }
void ServerConfigDialog::enableServer(int status) void ServerConfigDialog::enableServer(int status)
@ -205,6 +221,7 @@ void ServerConfigDialog::generateQR()
//} //}
ip->clear(); ip->clear();
QString dir; QString dir;
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
QList<QHostAddress> list = QHostInfo::fromName( QHostInfo::localHostName() ).addresses(); QList<QHostAddress> list = QHostInfo::fromName( QHostInfo::localHostName() ).addresses();
@ -214,11 +231,7 @@ void ServerConfigDialog::generateQR()
QString tmp = add.toString(); QString tmp = add.toString();
if(tmp.contains(".") && !tmp.startsWith("127")) if(tmp.contains(".") && !tmp.startsWith("127"))
{ {
if(dir.isEmpty() && tmp.startsWith("192.168.2.")) otherAddresses.push_back(tmp);
dir = tmp;
else
otherAddresses.push_back(tmp);
} }
} }
@ -231,14 +244,19 @@ void ServerConfigDialog::generateQR()
QString tmp = add; QString tmp = add;
if(tmp.contains(".") && !tmp.startsWith("127")) if(tmp.contains(".") && !tmp.startsWith("127"))
{ {
if(dir.isEmpty() && tmp.startsWith("192.168.2.")) otherAddresses.push_back(tmp);
dir = tmp;
else
otherAddresses.push_back(tmp);
} }
} }
#endif #endif
std::sort(otherAddresses.begin(),otherAddresses.end(),ipComparator);
if(!otherAddresses.isEmpty())
{
dir = otherAddresses.first();
otherAddresses.pop_front();
}
if(otherAddresses.length()>0 || !dir.isEmpty()) if(otherAddresses.length()>0 || !dir.isEmpty())
{ {
if(!dir.isEmpty()) if(!dir.isEmpty())

View File

@ -28,6 +28,7 @@ Q_OBJECT
QPixmap * qrCodeImage; QPixmap * qrCodeImage;
QProcess * qrGenerator; QProcess * qrGenerator;
public slots: public slots:
void generateQR(); void generateQR();
void generateQR(const QString & serverAddress); void generateQR(const QString & serverAddress);
@ -41,4 +42,4 @@ signals:
}; };
#endif #endif

View File

@ -178,12 +178,16 @@ CompressedArchive::CompressedArchive(const QString & filePath, QObject *parent)
CompressedArchive::~CompressedArchive() CompressedArchive::~CompressedArchive()
{ {
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
if(isRar) //TODO: fix this!!! Possible memory leak. If AddRef is not used, a crash occurs in "delete szInterface" if(isRar) //TODO: fix this!!! Possible memory leak. If AddRef is not used, a crash occurs in "delete szInterface"
szInterface->archive->AddRef(); szInterface->archive->AddRef();
#endif #endif
if(valid) //TODO: fix this!!! Memory leak. if(valid) //TODO: fix this!!! Memory leak.
{
szInterface->archive->Close();
delete szInterface; delete szInterface;
}
#ifdef Q_OS_UNIX #ifdef Q_OS_UNIX
delete rarLib; delete rarLib;
#endif #endif