Only index the database when a valid uuid is present.
Refresh the database when a PS Vita is connected.
This commit is contained in:
		@@ -106,8 +106,13 @@ void ClientManager::start()
 | 
			
		||||
 | 
			
		||||
void ClientManager::refreshDatabase()
 | 
			
		||||
{
 | 
			
		||||
    if(!db.reload()) {
 | 
			
		||||
        emit messageSent(tr("Cannot refresh the database while is in use"));
 | 
			
		||||
    bool prepared;
 | 
			
		||||
    if(!db.reload(prepared)) {
 | 
			
		||||
        if(prepared) {
 | 
			
		||||
            emit messageSent(tr("Cannot refresh the database while is in use"));
 | 
			
		||||
        } else {
 | 
			
		||||
            emit messageSent(tr("No PS Vita system has been registered"));
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        progress.show();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -174,6 +174,7 @@ void CmaClient::enterEventLoop(vita_device_t *device)
 | 
			
		||||
 | 
			
		||||
    eventLoop.moveToThread(&thread);
 | 
			
		||||
    connect(&thread, SIGNAL(started()), &eventLoop, SLOT(process()));
 | 
			
		||||
    connect(&eventLoop, SIGNAL(refreshDatabase()), this, SIGNAL(refreshDatabase()), Qt::DirectConnection);
 | 
			
		||||
    connect(&eventLoop, SIGNAL(finishedEventLoop()), &thread, SLOT(quit()), Qt::DirectConnection);
 | 
			
		||||
    thread.start();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -58,10 +58,17 @@ void Database::setUUID(const QString uuid)
 | 
			
		||||
    QSettings().setValue("lastAccountId", uuid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Database::reload()
 | 
			
		||||
bool Database::reload(bool &prepared)
 | 
			
		||||
{
 | 
			
		||||
    if(mutex.tryLock()) {
 | 
			
		||||
        timer->start();
 | 
			
		||||
        if(CMARootObject::uuid != "ffffffffffffffff") {
 | 
			
		||||
            timer->start();
 | 
			
		||||
            prepared = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            mutex.unlock();
 | 
			
		||||
            prepared = false;
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    } else {
 | 
			
		||||
        return false;
 | 
			
		||||
@@ -127,7 +134,6 @@ int Database::create()
 | 
			
		||||
        case VITA_OHFI_PSPSAVE:
 | 
			
		||||
        case VITA_OHFI_PSXAPP:
 | 
			
		||||
        case VITA_OHFI_PSMAPP:
 | 
			
		||||
 | 
			
		||||
            obj->initObject(settings.value("appsPath").toString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ public:
 | 
			
		||||
    explicit Database();
 | 
			
		||||
    ~Database();
 | 
			
		||||
 | 
			
		||||
    bool reload();
 | 
			
		||||
    bool reload(bool &prepared);
 | 
			
		||||
    void setUUID(const QString uuid);
 | 
			
		||||
    void addEntries(CMAObject *root);
 | 
			
		||||
    CMAObject *ohfiToObject(int ohfi);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user