void FlyEmBodySplitProjectDialog::connectSignalSlot() { connect(ui->bookmarkView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(locateBookmark(QModelIndex))); /* connect(ui->bookmarkView, SIGNAL(pressed(QModelIndex)), this, SLOT(showBookmarkContextMenu(QModelIndex))); */ //Progress signal-slot connect(this, SIGNAL(progressDone()), getMainWindow(), SIGNAL(progressDone())); connect(this, SIGNAL(messageDumped(QString,bool)), this, SLOT(dump(QString,bool))); connect(this, SIGNAL(sideViewCanceled()), this, SLOT(resetSideView())); connect(&m_project, SIGNAL(messageGenerated(QString, bool)), this, SIGNAL(messageDumped(QString, bool))); connect(&m_project, SIGNAL(progressStarted(QString,int)), this, SIGNAL(progressStarted(QString,int))); connect(&m_project, SIGNAL(progressAdvanced(double)), this, SIGNAL(progressAdvanced(double))); connect(&m_project, SIGNAL(progressDone()), this, SIGNAL(progressDone())); // connect(&m_project, SIGNAL(messageGenerated(QString)), // this, SLOT(dump(QString))); connect(&m_project, SIGNAL(errorGenerated(QString)), this, SLOT(dumpError(QString))); connect(this, SIGNAL(progressStarted(QString, int)), getMainWindow(), SLOT(startProgress(QString, int))); connect(this, SIGNAL(progressAdvanced(double)), getMainWindow(), SLOT(advanceProgress(double))); connect(this, SIGNAL(progressDone()), getMainWindow(), SLOT(endProgress())); }
bool SQLiteCommand::execute() { ZLLogger::Instance().println("sqlite", "execute: " + commandString()); SQLiteConnection &con = (SQLiteConnection &) connection(); if (!con.isOpened()) { myStatements.clear(); return false; } if (!prepareStatements(con)) { return false; } std::vector<sqlite3_stmt *>::iterator it = myStatements.begin(); std::vector<sqlite3_stmt *>::iterator end = myStatements.end(); while (true) { int res = sqlite3_step(*it); switch (res) { case SQLITE_DONE: if (++it == end) { resetStatements(); return true; } break; case SQLITE_OK: case SQLITE_ROW: break; default: dumpError(); finalizeStatements(); return false; } } }
void SQLiteConnection::finalizeOpenedStatements() { std::size_t size = myStatements.size(); for (std::size_t i = 0; i < size; ++i) { const int res = sqlite3_finalize(myStatements[i]); if (res != SQLITE_OK) { dumpError(); } } myStatements.clear(); }
Weibo::Weibo(QObject *parent) :QObject(parent) { mPut = new QPut(this); //connect(mPut, SIGNAL(ok(QString)), this, SIGNAL(ok())); connect(mPut, SIGNAL(fail(QString)), this, SIGNAL(error(QString))); connect(mPut, SIGNAL(fail(QString)), this, SLOT(dumpError(QString))); connect(mPut, SIGNAL(ok(QString)), this, SIGNAL(ok(QString))); connect(mPut, SIGNAL(ok(QString)), this, SLOT(dumpOk(QString))); connect(this, SIGNAL(loginOk()), SLOT(processNextRequest()), Qt::DirectConnection); }
void SQLiteCommand::finalizeStatements() { SQLiteConnection &con = (SQLiteConnection &) connection(); const size_t size = myStatements.size(); for (size_t i = 0; i < size; ++i) { sqlite3_stmt *statement = myStatements[i]; con.removeStatement(statement); const int res = sqlite3_finalize(statement); if (res != SQLITE_OK) { dumpError(); } } myStatements.clear(); }
bool SQLiteConnection::close() { if (myDatabase == 0) { return true; } finalizeOpenedStatements(); int res = sqlite3_close(myDatabase); if (res == SQLITE_OK) { myDatabase = 0; return true; } dumpError(); return false; }
bool SQLiteConnection::open() { if (myDatabase != 0) { return true; } int res = sqlite3_open(myName.c_str(), &myDatabase); if (res == SQLITE_OK) { return true; } dumpError(); if (myDatabase != 0) { sqlite3_close(myDatabase); myDatabase = 0; } return false; }
bool SQLiteCommand::resetStatements() { if (myStatements.size() == 0) { return true; } const size_t size = myStatements.size(); int res = SQLITE_OK; for (size_t i = 0; i < size && res == SQLITE_OK; ++i) { res = sqlite3_reset(myStatements[i]); } if (res == SQLITE_OK) { return true; } dumpError(); finalizeStatements(); return false; }
bool SQLiteCommand::bindParameterByName(const std::string &name, shared_ptr<DBValue> value) { const size_t size = myStatements.size(); bool res = true; bool binded = false; for (size_t i = 0; i < size; ++i) { sqlite3_stmt *statement = myStatements[i]; const int index = sqlite3_bind_parameter_index(statement, name.c_str()); if (index == 0) { continue; } binded = true; if (!bindParameter(statement, index, value)) { res = false; } } if (!binded) { dumpError("parameter \"" + name + "\" is not found"); } return res; }
bool SQLiteCommand::prepareStatements(SQLiteConnection &conn) { sqlite3 *db = conn.database(); if (myLocked) { return false; } if (myStatements.size() != 0) { const size_t size = myStatements.size(); int res = SQLITE_OK; for (size_t i = 0; i < size && res == SQLITE_OK; ++i) { res = sqlite3_reset(myStatements[i]); } if (res == SQLITE_OK) { bindParameters(); return true; } finalizeStatements(); } const std::string sql = commandString(); const int length = -1; const char *tail = sql.c_str(); while (true) { sqlite3_stmt *statement; int res = sqlite3_prepare_v2(db, tail, length, &statement, &tail); if (res != SQLITE_OK) { dumpError(); finalizeStatements(); return false; } if (statement == 0) { break; } myStatements.push_back(statement); conn.addStatement(statement); } if (!bindParameters()) { finalizeStatements(); return false; } return true; }
shared_ptr<DBValue> SQLiteCommand::executeScalar() { ZLLogger::Instance().println("sqlite", "executeScalar: " + commandString()); SQLiteConnection &con = (SQLiteConnection &) connection(); if (!con.isOpened()) { myStatements.clear(); return 0; } if (!prepareStatements(con)) { return 0; } std::vector<sqlite3_stmt *>::iterator it = myStatements.begin(); std::vector<sqlite3_stmt *>::iterator end = myStatements.end(); while (true) { int res = sqlite3_step(*it); switch (res) { case SQLITE_DONE: if (++it == end) { resetStatements(); return 0; } break; case SQLITE_OK: break; case SQLITE_ROW: { shared_ptr<DBValue> val = SQLiteDataReader::makeDBValue(*it, /* column = */ 0); resetStatements(); return val; } default: dumpError(); finalizeStatements(); return 0; } } }
bool SQLiteCommand::bindParameter(sqlite3_stmt *statement, int number, shared_ptr<DBValue> value) { DBValue::ValueType type = (value.isNull()) ? (DBValue::DBNULL) : (value->type()); int res; switch (type) { case DBValue::DBNULL: res = sqlite3_bind_null(statement, number); break; case DBValue::DBINT: res = sqlite3_bind_int(statement, number, ((DBIntValue &) *value).value()); break; case DBValue::DBREAL: res = sqlite3_bind_double(statement, number, ((DBRealValue &) *value).value()); break; case DBValue::DBTEXT: res = sqlite3_bind_text(statement, number, ((DBTextValue &) *value).value().c_str(), -1 /* zero-terminated string */, SQLITE_TRANSIENT); break; default: return false; } if (res != SQLITE_OK) { dumpError(); } return res == SQLITE_OK; }
void ValgrindMemcheckParserTest::testMemcheckSample1() { initTest("memcheck-output-sample1.xml"); QList<Error> expectedErrors; { Error error; error.setKind(InvalidRead); error.setWhat("Invalid read of size 4"); error.setUnique(0x9); error.setTid(1); Frame f1; f1.setInstructionPointer(0x6E47964); f1.setObject("/usr/lib/libQtGui.so.4.7.0"); f1.setFunctionName("QFrame::frameStyle() const"); f1.setDirectory("/build/buildd/qt4-x11-4.7.0/src/gui/widgets"); f1.setFileName("qframe.cpp"); f1.setLine(252); Frame f2; f2.setInstructionPointer(0x118F2AF7); f2.setObject("/usr/lib/kde4/plugins/styles/oxygen.so"); Frame f3; f3.setInstructionPointer(0x6A81671); f3.setObject("/usr/lib/libQtGui.so.4.7.0"); f3.setFunctionName("QWidget::event(QEvent*)"); f3.setDirectory("/build/buildd/qt4-x11-4.7.0/src/gui/kernel"); f3.setFileName("qwidget.cpp"); f3.setLine(8273); Frame f4; f4.setInstructionPointer(0x6A2B6EB); f4.setObject("/usr/lib/libQtGui.so.4.7.0"); f4.setDirectory("/build/buildd/qt4-x11-4.7.0/src/gui/kernel"); f4.setFileName("qapplication.cpp"); f4.setFunctionName("QApplicationPrivate::notify_helper(QObject*, QEvent*)"); f4.setLine(4396); Stack s1; s1.setAuxWhat("Address 0x11527cb8 is not stack'd, malloc'd or (recently) free'd"); s1.setFrames(QVector<Frame>() << f1 << f2 << f3 << f4); error.setStacks( QVector<Stack>() << s1 ); expectedErrors << error; } QVector<QPair<qint64,qint64> > expectedErrorCounts; expectedErrorCounts.push_back(QPair<qint64,qint64>(9, 2)); QVector<QPair<QString,qint64> > expectedSuppCounts; expectedSuppCounts.push_back(qMakePair(QString("X on SUSE11 writev uninit padding"), static_cast<qint64>(12))); expectedSuppCounts.push_back(qMakePair(QString("dl-hack3-cond-1"), static_cast<qint64>(2))); expectedSuppCounts.push_back(qMakePair(QString("glibc-2.5.x-on-SUSE-10.2-(PPC)-2a"), static_cast<qint64>(2))); Parser parser; Recorder rec(&parser); parser.parse(m_socket); m_process->waitForFinished(); QCOMPARE(m_process->exitStatus(), QProcess::NormalExit); QCOMPARE(m_process->state(), QProcess::NotRunning); QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString())); const QList<Error> actualErrors = rec.errors; if (actualErrors.first() != expectedErrors.first()) { dumpError(actualErrors.first()); dumpError(expectedErrors.first()); } QCOMPARE(actualErrors.first(), expectedErrors.first()); QCOMPARE(actualErrors.size(), 3); QCOMPARE(rec.errorcounts, expectedErrorCounts); QCOMPARE(rec.suppcounts, expectedSuppCounts); }
void ValgrindMemcheckParserTest::testHelgrindSample1() { QSKIP("testfile does not exist"); initTest("helgrind-output-sample1.xml"); QList<Error> expectedErrors; { Error error1; error1.setUnique(0x0); error1.setTid(1); error1.setKind(LockOrder); error1.setWhat("Thread #1: lock order \"0xA39C270 before 0xA3AC010\" violated"); error1.setHelgrindThreadId(1); Stack stack1; Frame frame11; frame11.setInstructionPointer(0x4C2B806); frame11.setObject("/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so"); frame11.setFunctionName("QMutex::lock()"); frame11.setDirectory("/build/buildd/valgrind-3.6.0~svn20100212/helgrind"); frame11.setFileName("hg_intercepts.c"); frame11.setLine(1988); Frame frame12; frame12.setInstructionPointer(0x72E57EE); frame12.setObject("/home/frank/local/qt4-4.6.3-shared-debug/lib/libQtCore.so.4.6.3"); frame12.setFunctionName("QMutexLocker::relock()"); frame12.setDirectory("/home/frank/source/tarballs/qt-4.6.3-build/src/corelib/../../include/QtCore/../../src/corelib/thread"); frame12.setFileName("qmutex.h"); frame12.setLine(120); stack1.setFrames(QVector<Frame>() << frame11 << frame12); Stack stack2; stack2.setAuxWhat("Required order was established by acquisition of lock at 0xA39C270"); Frame frame21; frame21.setInstructionPointer(0x4C2B806); frame21.setObject("/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so"); frame21.setFunctionName("QMutex::lock()"); frame21.setDirectory("/build/buildd/valgrind-3.6.0~svn20100212/helgrind"); frame21.setFileName("hg_intercepts.c"); frame21.setLine(1989); Frame frame22; frame22.setInstructionPointer(0x72E57EE); frame22.setObject("/home/frank/local/qt4-4.6.3-shared-debug/lib/libQtCore.so.4.6.3"); frame22.setFunctionName("QMutexLocker::relock()"); frame22.setDirectory("/home/frank/source/tarballs/qt-4.6.3-build/src/corelib/../../include/QtCore/../../src/corelib/thread"); frame22.setFileName("qmutex.h"); frame22.setLine(121); stack2.setFrames(QVector<Frame>() << frame21 << frame22); Stack stack3; stack3.setAuxWhat("followed by a later acquisition of lock at 0xA3AC010"); Frame frame31; frame31.setInstructionPointer(0x4C2B806); frame31.setObject("/usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so"); frame31.setFunctionName("QMutex::lock()"); frame31.setDirectory("/build/buildd/valgrind-3.6.0~svn20100212/helgrind"); frame31.setFileName("hg_intercepts.c"); frame31.setLine(1990); Frame frame32; frame32.setInstructionPointer(0x72E57EE); frame32.setObject("/home/frank/local/qt4-4.6.3-shared-debug/lib/libQtCore.so.4.6.3"); frame32.setFunctionName("QMutexLocker::relock()"); frame32.setDirectory("/home/frank/source/tarballs/qt-4.6.3-build/src/corelib/../../include/QtCore/../../src/corelib/thread"); frame32.setFileName("qmutex.h"); frame32.setLine(122); stack3.setFrames(QVector<Frame>() << frame31 << frame32); error1.setStacks(QVector<Stack>() << stack1 << stack2 << stack3); expectedErrors.append(error1); } Parser parser; Recorder rec(&parser); parser.parse(m_socket); m_process->waitForFinished(); QCOMPARE(m_process->exitStatus(), QProcess::NormalExit); QCOMPARE(m_process->state(), QProcess::NotRunning); QVERIFY2(parser.errorString().isEmpty(), qPrintable(parser.errorString())); const QList<Error> actualErrors = rec.errors; if (actualErrors.first() != expectedErrors.first()) { dumpError(actualErrors.first()); dumpError(expectedErrors.first()); } QCOMPARE(actualErrors.first(), expectedErrors.first()); QCOMPARE(actualErrors.size(), 1); // QCOMPARE(rec.errorcounts, expectedErrorCounts); // QCOMPARE(rec.suppcounts, expectedSuppCounts); }
void ImageDownloadTest::error(const WFAPI::AsynchronousStatus& status) { dumpError(status); setTestFailed(status.getStatusMessage()); }
void SettingsTest::error(const WFAPI::AsynchronousStatus& status) { dumpError(status); setTestFailed(status.getStatusMessage()); }