mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-18 20:34:39 +01:00
Postpone the database check & backup to a little while after startup.
This commit is contained in:
parent
eed3a57af8
commit
133c2e1640
@ -18,6 +18,7 @@
|
||||
#include "closure.h"
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/timeconstants.h"
|
||||
|
||||
namespace _detail {
|
||||
|
||||
@ -89,3 +90,12 @@ _detail::Closure* NewClosure(
|
||||
QObject* receiver, const char* slot) {
|
||||
return new _detail::Closure(sender, signal, receiver, slot);
|
||||
}
|
||||
|
||||
void DoAfter(QObject* receiver, const char* slot, int msec) {
|
||||
QTimer::singleShot(msec, receiver, slot);
|
||||
}
|
||||
|
||||
void DoInAMinuteOrSo(QObject* receiver, const char* slot) {
|
||||
int msec = (60 + (qrand() % 60)) * kMsecPerSec;
|
||||
DoAfter(receiver, slot, msec);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <QMetaMethod>
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
@ -224,4 +225,7 @@ _detail::Closure* NewClosure(
|
||||
C_ARG(T0, val0), C_ARG(T1, val1));
|
||||
}
|
||||
|
||||
void DoAfter(QObject* receiver, const char* slot, int msec);
|
||||
void DoInAMinuteOrSo(QObject* receiver, const char* slot);
|
||||
|
||||
#endif // CLOSURE_H
|
||||
|
@ -90,7 +90,7 @@ Application::Application(QObject* parent)
|
||||
library_->Init();
|
||||
library_->StartThreads();
|
||||
|
||||
QMetaObject::invokeMethod(database_, "DoBackup", Qt::QueuedConnection);
|
||||
DoInAMinuteOrSo(database_, SLOT(DoBackup()));
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
|
@ -685,6 +685,7 @@ bool Database::CheckErrors(const QSqlQuery& query) {
|
||||
}
|
||||
|
||||
bool Database::IntegrityCheck(QSqlDatabase db) {
|
||||
qLog(Debug) << "Starting database integrity check";
|
||||
int task_id = app_->task_manager()->StartTask(tr("Integrity check"));
|
||||
|
||||
bool ok = false;
|
||||
@ -743,6 +744,7 @@ bool Database::OpenDatabase(const QString& filename, sqlite3** connection) const
|
||||
}
|
||||
|
||||
void Database::BackupFile(const QString& filename) {
|
||||
qLog(Debug) << "Starting database backup";
|
||||
QString dest_filename = QString("%1.bak").arg(filename);
|
||||
const int task_id = app_->task_manager()->StartTask(tr("Backing up database"));
|
||||
|
||||
|
@ -64,7 +64,7 @@ class Database : public QObject {
|
||||
signals:
|
||||
void Error(const QString& message);
|
||||
|
||||
private slots:
|
||||
public slots:
|
||||
void DoBackup();
|
||||
|
||||
private:
|
||||
|
@ -303,6 +303,12 @@ int main(int argc, char *argv[]) {
|
||||
logging::SetLevels(options.log_levels());
|
||||
g_log_set_default_handler(reinterpret_cast<GLogFunc>(&logging::GLog), NULL);
|
||||
|
||||
// Seed the random number generator
|
||||
time_t t = time(NULL);
|
||||
srand(time(NULL));
|
||||
qDebug() << "Seeding with:" << t;
|
||||
qsrand(t);
|
||||
|
||||
IncreaseFDLimit();
|
||||
|
||||
QtSingleApplication a(argc, argv);
|
||||
@ -387,9 +393,6 @@ int main(int argc, char *argv[]) {
|
||||
QNetworkProxyFactory::setApplicationProxyFactory(
|
||||
NetworkProxyFactory::Instance());
|
||||
|
||||
// Seed the random number generator
|
||||
srand(time(NULL));
|
||||
|
||||
// Initialize the repository of cover providers. Last.fm registers itself
|
||||
// when its service is created.
|
||||
app.cover_providers()->AddProvider(new AmazonCoverProvider);
|
||||
|
Loading…
Reference in New Issue
Block a user