bool Q3DataBrowser::updateCurrent() { if (isReadOnly()) return false; QSqlRecord* buf = d->frm.record(); Q3SqlCursor* cur = d->cur.cursor(); if (!buf || !cur) return false; writeFields(); emit beforeUpdate(buf); int ar = cur->update(); if (!ar || !cur->isActive()) { handleError(cur->lastError()); refresh(); updateBoundary(); } else { refresh(); d->cur.findBuffer(cur->primaryIndex()); updateBoundary(); cur->editBuffer(true); cursorChanged(Q3SqlCursor::Update); readFields(); return true; } return false; }
void Engine::update() { // We're about to start another frame. It's safe to delete our level, and start cleaning up the // old b2World. performLevelChange(); mWorldToDelete.reset(); emit beforeUpdate(); if (isPaused()) { updateCamera(); return; } // If no level has yet to be loaded (which can happen if the queued event // hasn't yet been processed) then we must skip if (!mLevelReady) { return; } setPhase(LOGICS_PHASE); forEach<Logic>([] (Logic* logic) { if (logic->isActive()) { logic->update(); } }); setPhase(BEFORE_PHYSICS_PHASE); forEach<Body>([] (Body* body) { body->updateBeforePhysics(); }); setPhase(PHYSICS_PHASE); mWorldStepCount++; getWorld()->Step(TIME_STEP_S, VELOCITY_ITERATIONS, POSITION_ITERATIONS, PARTICLE_ITERATIONS); setPhase(AFTER_PHYSICS_PHASE); forEach<Body>([] (Body* body) { body->updateAfterPhysics(); }); emit afterUpdate(); setPhase(CAMERA_PHASE); updateCamera(); mTextureManager->processDeletion(); setPhase(RENDERING_PHASE); }
/*! Updates the given \a row in the currently active database table with the specified \a values. Returns \c true if successful; otherwise returns \c false. This is a low-level method that operates directly on the database and should not be called directly. Use setData() to update values. The model will decide depending on its edit strategy when to modify the database. Note that only values that have the generated-flag set are updated. The generated-flag can be set with QSqlRecord::setGenerated() and tested with QSqlRecord::isGenerated(). \sa QSqlRecord::isGenerated(), setData() */ bool QSqlTableModel::updateRowInTable(int row, const QSqlRecord &values) { Q_D(QSqlTableModel); QSqlRecord rec(values); emit beforeUpdate(row, rec); const QSqlRecord whereValues = primaryValues(row); const bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries); const QString stmt = d->db.driver()->sqlStatement(QSqlDriver::UpdateStatement, d->tableName, rec, prepStatement); const QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement, d->tableName, whereValues, prepStatement); if (stmt.isEmpty() || where.isEmpty() || row < 0 || row >= rowCount()) { d->error = QSqlError(QLatin1String("No Fields to update"), QString(), QSqlError::StatementError); return false; } return d->exec(Sql::concat(stmt, where), prepStatement, rec, whereValues); }
/*! Updates the given \a row in the currently active database table with the specified \a values. Returns true if successful; otherwise returns false. This is a low-level method that operates directly on the database and should not be called directly. Use setData() to update values. The model will decide depending on its edit strategy when to modify the database. Note that only values that have the generated-flag set are updated. The generated-flag can be set with QSqlRecord::setGenerated() and tested with QSqlRecord::isGenerated(). \sa QSqlRecord::isGenerated(), setData() */ bool QSqlTableModel::updateRowInTable(int row, const QSqlRecord &values) { Q_D(QSqlTableModel); QSqlRecord rec(values); emit beforeUpdate(row, rec); const QSqlRecord whereValues = d->strategy == OnManualSubmit ? d->cache[row].primaryValues : d->primaryValues(row); bool prepStatement = d->db.driver()->hasFeature(QSqlDriver::PreparedQueries); QString stmt = d->db.driver()->sqlStatement(QSqlDriver::UpdateStatement, d->tableName, rec, prepStatement); QString where = d->db.driver()->sqlStatement(QSqlDriver::WhereStatement, d->tableName, whereValues, prepStatement); if (stmt.isEmpty() || where.isEmpty() || row < 0 || row >= rowCount()) { d->error = QSqlError(QLatin1String("No Fields to update"), QString(), QSqlError::StatementError); return false; } stmt.append(QLatin1Char(' ')).append(where); return d->exec(stmt, prepStatement, rec, whereValues); }
void Drone::runUpdateLoop() { int runTime = 0; int updateInterval = 1000/40; boost::timer::cpu_timer timer; while(!_stop_flag) { timer.start(); // TODO: Think this through really well, find memory leaks! // Check connection status and handle unexpected loss of connection if(!_connected.load()) { notifyConnectionLost(); connectionLost(); return; } // Call any miscellaneous functionality needed by implementation beforeUpdate(); // Process command queue _commandmutex.lock(); if(_commandqueue.empty()) { _connected.store(processNoCommand()); if(!_connected.load()) { continue; } } else { for(drone::command command : _commandqueue) { _connected.store(processCommand(command)); if(!_connected.load()) { _commandqueue.clear(); continue; } } } _commandqueue.clear(); _commandmutex.unlock(); // Retrieve and process navdata std::shared_ptr<drone::navdata> navdata; bool newNavdata = decodeNavdata(navdata); if(newNavdata) { notifyNavdataListeners(navdata); } // Call any miscellaneous functionality needed by implementation updateCycle(); // Run at continuous update rate runTime = timer.elapsed().wall / 1000000; timer.stop(); if(updateInterval - runTime > 0) { boost::this_thread::sleep_for(boost::chrono::milliseconds(updateInterval - runTime)); } } }