/*! \internal \a sourceSignal MUST be in the signal index range (see QObjectPrivate::signalIndex()). This is different from QMetaMethod::methodIndex(). */ void QQmlNotifierEndpoint::connect(QObject *source, int sourceSignal, QQmlEngine *engine) { disconnect(); Q_ASSERT(engine); if (QObjectPrivate::get(source)->threadData->threadId != QObjectPrivate::get(engine)->threadData->threadId) { QString sourceName; QDebug(&sourceName) << source; sourceName = sourceName.left(sourceName.length() - 1); QString engineName; QDebug(&engineName).nospace() << engine; engineName = engineName.left(engineName.length() - 1); qFatal("QQmlEngine: Illegal attempt to connect to %s that is in" " a different thread than the QML engine %s.", qPrintable(sourceName), qPrintable(engineName)); } senderPtr = qintptr(source); this->sourceSignal = sourceSignal; QQmlPropertyPrivate::flushSignal(source, sourceSignal); QQmlData *ddata = QQmlData::get(source, true); ddata->addNotify(sourceSignal, this); QObjectPrivate * const priv = QObjectPrivate::get(source); priv->connectNotify(QMetaObjectPrivate::signal(source->metaObject(), sourceSignal)); }
QList<GameItem*>* GlobalData::loadItemData(const char* fileName) { QList<GameItem*> *list = new QList<GameItem*>(); FILE *fp = openFile(fileName); if(!fp){ QDebug(QtWarningMsg) << "读取物品出错"; return list; } skipBytes(fp, readInt(fp)); int count = readInt(fp); for( int i = 0; i < count; i++){ GameItem *gameItem = new GameItem(); list->append(gameItem); gameItem->idx = readInt(fp); gameItem->name = readUTF(fp); gameItem->describe = readUTF(fp); gameItem->level = readInt(fp); gameItem->rank = readInt(fp); gameItem->buyPrice = readInt(fp); gameItem->salePrice = readInt(fp); gameItem->limitLevel = readInt(fp); gameItem->addHP = readInt(fp); gameItem->addAF = readInt(fp); gameItem->addDEF = readInt(fp); } closeFile(fp); QDebug(QtDebugMsg) << fileName << "加载"<<list->count()<<"个物品"; return list; }
QDebug debug_helper(quint64 ptr, DebugLevel level, QtMsgType type) { Q_UNUSED(ptr); DebugData *d = debugData(); if (!d->inited && ObjectGenerator::isInited()) { d->inited = true; Config cfg; cfg.beginGroup(QLatin1String("debug")); d->level = cfg.value(QLatin1String("level"), DebugInfo); } if (d->level > level) return QDebug(devnull()); return QDebug(type) << qPrintable(QTime::currentTime().toString(QLatin1String("[hh:mm:ss]"))); // const QMetaObject *meta = reinterpret_cast<const QMetaObject*>(ptr); // const DebugAreaData *data = meta ? debugAreaMap()->value(meta, 0) : coreData(); // if (!data) { // DebugAreaData *d = new DebugAreaData(); // Config cfg; // cfg.beginGroup("debug"); // QString nameStr = QLatin1String(meta->className()); // cfg.beginGroup(nameStr); // d->name = "[" + cfg.value("name", nameStr).toLocal8Bit() + "]:"; // d->level = cfg.value("level", DebugInfo); // data = d; // } // if (data->level <= level) // return (QDebug(type) << data->name); // else // return QDebug(devnull()); }
void pf_mcontroller::run() { QByteArray tr_message; retval_t rv = RV_OK; QDebug(QtDebugMsg) << "Starting a thread"; // while (!QThread::currentThread()->isInterruptionRequested()) // { // if( RV_OK == requests_buf.acquire(tr_message, 100)) // { // QDebug(QtDebugMsg) << "Acquired a new message"; // rv = transmit(tr_message); // } // QDebug(QtDebugMsg) << "New cycle"; // } while (!QThread::currentThread()->isInterruptionRequested()) { tx_mutex.lock(); if(tx_requested) { QDebug(QtDebugMsg) << "Acquired a new message"; tx_requested = false; rv = transmit(tx_data); } tx_mutex.unlock(); } QDebug(QtDebugMsg) << "Exiting thread"; }
pf_mcontroller:: pf_mcontroller(QString out, QString in): m_tx_port(new QSerialPort(out)), m_rx_port(out == in ? m_tx_port : new QSerialPort(in)), m_proc(), m_buf(), requests_buf(), tx_requested(false) { setup(*m_tx_port); m_tx_port->moveToThread(this); if(m_tx_port != m_rx_port) { setup(*m_rx_port); m_rx_port->moveToThread(this); } QDebug(QtDebugMsg) << "Opening port:"; if(RV_OK == open()) { QDebug(QtDebugMsg) << "Port is opened!!!"; connect(m_rx_port, SIGNAL(readyRead()), this, SLOT(rxEvent())); connect(&m_proc, SIGNAL(messageReceived(QByteArray)), this, SLOT(telegramReceived(QByteArray))); start(); } else { QDebug(QtWarningMsg) << "Can't open a port"; } }
retval_t pf_mcontroller::transmit (const QByteArray& data) { retval_t rv = RV_OK; QByteArray mdata(data); mdata.append(pf_crc::get(mdata)); mdata.prepend(START_CHAR); mdata.append(END_CHAR); QDebug(QtDebugMsg) << "Writing data:" << mdata; m_tx_port->write(mdata); QByteArray echodata; if(RV_OK == m_buf.acquire(echodata, 100)) { if(mdata != echodata) { rv = RV_NO_ECHO; QDebug(QtWarningMsg) << "Echo isn't received. Wrong data:" << echodata; } } else { rv = RV_NO_ECHO; QDebug(QtWarningMsg) << "Echo isn't received. Timeout"; } return rv; }
void Account::slotHandleErrors(QNetworkReply *reply , QList<QSslError> errors) { NetworkJobTimeoutPauser pauser(reply); QString out; QDebug(&out) << "SSL-Errors happened for url " << reply->url().toString(); foreach(const QSslError &error, errors) { QDebug(&out) << "\tError in " << error.certificate() << ":" << error.errorString() << "("<< error.error() << ")" << "\n"; }
RepositoryParser::Packages RepositoryParser::getPackages() const { Packages packages; QDirIterator dirIter(m_Dir); while(dirIter.hasNext()) { dirIter.next(); QDebug(QtDebugMsg) << dirIter.filePath(); QDebug(QtDebugMsg) << dirIter.fileName(); packages.unite(getPackages(dirIter.fileName())); } return packages; }
/** * This is the overloaded function provided for the convinience. It behaves similar to the above function. * * This function doesn't accept any log message as argument. It returns the \c QDebug object that can be written * using the stream functions. For example, you may like to write: * \code * LOG_DEBUG() << "This is the size" << size << "of the element" << elementName; * \endcode * instead of writing * \code * LOG_DEBUG(QString(QLatin1String("This is the size %1x%2 of the element %3")) * .arg(size.x()).arg(size.y()).arg(elementName)); * \endcode * * Please consider reading the Qt Reference Documentation for the description of the QDebug class usage syntax. * * \note This overload is definitely more pleasant to use than the first write() overload, but it behaves definitely * slower than all the above overloads. * * \sa write() */ QDebug Logger::write(LogLevel logLevel, const char* file, int line, const char* function, const char* category) { Q_D(Logger); d->logDevice->lock(logLevel, file, line, function, category); return QDebug(d->logDevice); }
void MainWindow::equal(){ if(labelStr.contains("=")){ first += total.toFloat(); } second = value.toFloat(); if(addBool){ total = QString::number(first+second); addBool = false; } if(substractbool){ total = QString::number(first-second); substractbool = false; } if(multyply){ total = QString::number(first*second); multyply = false; } if(dividebool){ total = QString::number(first/second); dividebool = false; } if(convert8){ QString str = QString::number(first); QRegExp rxlen("."); QDebug() << rxlen; } labelStr += "=" + total; ui->label->setText(labelStr); value = ""; first = 0; second = 0; }
// internal, see doc/src/tools/debug-qtopia.qdoc QTOPIABASE_EXPORT QDebug QLogBase::log(const char* category) { QDebug r = QDebug(QtDebugMsg); if ( category ) r << category << ": "; return r; }
QDebug CreateLogger(Level level, const QString& class_name, int line) { // Map the level to a string const char* level_name = NULL; switch (level) { case Level_Debug: level_name = " DEBUG "; break; case Level_Info: level_name = " INFO "; break; case Level_Warning: level_name = " WARN "; break; case Level_Error: level_name = " ERROR "; break; } // Check the settings to see if we're meant to show or hide this message. Level threshold_level = sDefaultLevel; if (sClassLevels && sClassLevels->contains(class_name)) { threshold_level = sClassLevels->value(class_name); } if (level > threshold_level) { return QDebug(sNullDevice); } QString function_line = class_name; if (line != -1) { function_line += ":" + QString::number(line); } QDebug ret(QtDebugMsg); ret.nospace() << kMessageHandlerMagic << QDateTime::currentDateTime().toString("hh:mm:ss.zzz").toAscii().constData() << level_name << function_line.leftJustified(32).toAscii().constData(); return ret.space(); }
void PrintTo(const ProjectFile &projectFile, std::ostream *os) { *os << "ProjectFile("; QString output; QDebug(&output) << projectFile; *os << qPrintable(output); *os << ")"; }
QString Process::errorInfo() const { if (isRunning_ || !rc()) return QString(); QString res; QDebug(&res) << errorNames[ps->error()] << ps->exitStatus(); return res; }
void FontDialogPanel::accepted() { const QFontDialog *d = qobject_cast<const QFontDialog *>(sender()); Q_ASSERT(d); m_result.clear(); QDebug(&m_result).nospace() << "Current font: " << d->currentFont() << "\nSelected font: " << d->selectedFont(); QTimer::singleShot(0, this, SLOT(showAcceptedResult())); // Avoid problems with the closing (modal) dialog as parent. }
bool ClientHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message) { // Check the message name. const std::string& message_name = message->GetName(); if (message_name == "MethodCall") { const auto arguments = message->GetArgumentList(); const auto methodName = arguments.get()->GetString(0).ToString(); const auto json = arguments.get()->GetString(1).ToString(); const auto callId = arguments.get()->GetInt(2); std::cout << "MethodCall id " << callId << " " << methodName << " " << json << std::endl; // Handle the message here... QJsonParseError parseError; QJsonDocument jsonDoc = QJsonDocument::fromJson(QByteArray::fromStdString(json), &parseError); if (parseError.error != QJsonParseError::NoError) { qDebug() << "JSON Error:" << parseError.errorString(); return false; } const auto argsArray = jsonDoc.array(); const auto bridge = static_cast<Shell*>(qApp)->bridge; std::vector<std::string> attempts; #include "cg/ClientSlot.cppf" if (!attempts.empty()) { const char* const delim = "\n"; std::ostringstream imploded; std::copy(attempts.begin(), attempts.end(), std::ostream_iterator<std::string>(imploded, delim)); CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("CallFailed"); CefRefPtr<CefListValue> args = msg->GetArgumentList(); args->SetInt(0, callId); // To keep the string version of the JSON value escaped // here to use the functionality provided by QDebug QString tmpStr; QDebug(&tmpStr) << QString::fromStdString(imploded.str()); // Have to cast to QString first, otherwise mojibake args->SetString(1, tmpStr.toStdString()); browser->SendProcessMessage(PID_RENDERER, msg); return true; } return false; } return false; }
bool Client::start(bool _server) { if (profile.debug()) { if (!headerTest()) { QDebug(QtMsgType::QtCriticalMsg) << "Header test failed."; return false; } } if (!profile.isValid()) { qCritical() << "The profile is invalid. Improper setup?"; return false; } controller.reset(new QSS::Controller(profile, !_server, autoBan)); if (!_server) { QSS::Address server(profile.serverAddress(), profile.serverPort()); server.blockingLookUp(); tester.reset(new QSS::AddressTester(server.getFirstIP(), server.getPort())); QObject::connect(tester.get(), &QSS::AddressTester::connectivityTestFinished, [] (bool c) { if (c) { QDebug(QtMsgType::QtInfoMsg) << "The shadowsocks connection is okay."; } else { QDebug(QtMsgType::QtWarningMsg) << "Destination is not reachable. " "Please check your network and firewall settings. " "And make sure the profile is correct."; } }); QObject::connect(tester.get(), &QSS::AddressTester::testErrorString, [] (const QString& error) { QDebug(QtMsgType::QtWarningMsg).noquote() << "Connectivity testing error:" << error; }); tester->startConnectivityTest(profile.method(), profile.password()); } return controller->start(); }
pf_mcontroller::~pf_mcontroller() { //finish the thread requestInterruption(); if(!wait(3000)) { QDebug(QtWarningMsg) << "Can't quit thread, terminate"; terminate(); wait(); } QDebug(QtDebugMsg) << "THread is terminated"; //delete serial ports instances if(m_tx_port == m_rx_port) { delete m_tx_port; } else { delete m_tx_port; delete m_rx_port; } }
pf_adaptor::~pf_adaptor() { QDebug(QtDebugMsg) << "~pf_adaptor()"; emit(this->stop_cyclic()); emit(this->close_serial()); delete(tx_p); delete(controller_p); QThread * tr_cc = tr_cc_p->thread(); tr_cc_p->terminate(); QThread * tr = tr_tx_p->thread(); tr_tx_p->terminate(); tr_cc_p->wait(1000); if(tr_cc_p->isRunning()) { QDebug(QtWarningMsg) << "Can't stop thread"; } else { QDebug(QtDebugMsg) << "Thread stopped" << (void*)tr_cc; } tr_tx_p->wait(1000); if(tr_tx_p->isRunning()) { QDebug(QtWarningMsg) << "Can't stop thread"; } else { QDebug(QtDebugMsg) << "Thread stopped" << (void*)tr; } delete(tr_tx_p); delete(tr_cc_p); }
QDebug & getSVDebug() { static QFile *logFile = 0; static QDebug *debug = 0; static QMutex mutex; static char *prefix; mutex.lock(); if (!debug) { prefix = new char[20]; sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid()); QString pfx = ResourceFinder().getUserResourcePrefix(); QDir logdir(QString("%1/%2").arg(pfx).arg("log")); if (!logdir.exists()) logdir.mkpath(logdir.path()); logFile = new QFile(logdir.path() + "/debug.log"); if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) { QDebug(QtDebugMsg) << (const char *)prefix << "Opened debug log file " << logFile->fileName(); debug = new QDebug(logFile); } else { QDebug(QtWarningMsg) << (const char *)prefix << "Failed to open debug log file " << logFile->fileName() << " for writing, using console debug instead"; debug = new QDebug(QtDebugMsg); delete logFile; logFile = 0; } *debug << endl << (const char *)prefix << "Log started at " << QDateTime::currentDateTime().toString(); } mutex.unlock(); QDebug &dref = *debug; return dref << endl << (const char *)prefix; }
void Window::setPlanetConnectionError(const Planet &planet, QAbstractSocket::SocketError socketError) { QString errorEnum; QDebug(&errorEnum).nospace() << socketError; QString error = QString("Error: [%1]").arg(errorEnum); QStandardItem* planetItem = getPlanetTreeWidgetItem(planet); QStandardItem* errorItem = planetTreeModel->item(planetItem->row(), 1); //no need to reset the error and resize the treeview if the error is the same if (errorItem->text().compare(error)) { errorItem->setText(error); if (!Settings::getInstance().getResizeOnRefreshDisabled()) { planetTreeView->resizeColumnToContents(1); } } }
bool Client::readConfig(const QString &file) { QFile c(file); if (!c.open(QIODevice::ReadOnly | QIODevice::Text)) { QDebug(QtMsgType::QtCriticalMsg).noquote() << "Can't open configuration file" << file; return false; } if (!c.isReadable()) { QDebug(QtMsgType::QtCriticalMsg).noquote() << "Configuration file" << file << "is not readable!"; return false; } QJsonParseError error; QJsonDocument confJson = QJsonDocument::fromJson(c.readAll(), &error); c.close(); QJsonObject confObj = confJson.object(); if (error.error != QJsonParseError::NoError) { qCritical() << "Failed to parse configuration file:" << error.errorString(); return false; } profile.setLocalAddress(confObj["local_address"].toString().toStdString()); profile.setLocalPort(confObj["local_port"].toInt()); profile.setMethod(confObj["method"].toString().toStdString()); profile.setPassword(confObj["password"].toString().toStdString()); profile.setServerAddress(confObj["server"].toString().toStdString()); profile.setServerPort(confObj["server_port"].toInt()); profile.setTimeout(confObj["timeout"].toInt()); profile.setHttpProxy(confObj["http_proxy"].toBool()); if (confObj["auth"].toBool()) { QDebug(QtMsgType::QtCriticalMsg) << "OTA is deprecated, please remove OTA from the configuration file."; } return true; }
retval_t pf_mcontroller::broadcast(const QByteArray &request) { // QDebug(QtDebugMsg) << "New broadcast"; // // TODO request and broadcast messages should be distinguished // //reserv buffer for echo; // m_buf.reserv(); // return requests_buf.add(request); QMutexLocker locker(&tx_mutex); QDebug(QtDebugMsg) << "New broadcast"; tx_data = request; tx_requested = true; return RV_OK; }
bool Client::headerTest() { int length; QHostAddress test_addr("1.2.3.4"); QHostAddress test_addr_v6("2001:0db8:85a3:0000:0000:8a2e:1010:2020"); uint16_t test_port = 56; QSS::Address test_res, test_v6(test_addr_v6, test_port); std::string packed = QSS::Common::packAddress(test_v6); QSS::Common::parseHeader(packed, test_res, length); bool success = (test_v6 == test_res); if (!success) { qWarning("%s --> %s", test_v6.toString().data(), test_res.toString().data()); } packed = QSS::Common::packAddress(test_addr, test_port); QSS::Common::parseHeader(packed, test_res, length); bool success2 = ((test_res.getFirstIP() == test_addr) && (test_res.getPort() == test_port)); if (!success2) { QDebug(QtMsgType::QtWarningMsg).noquote().nospace() << test_addr.toString() << ":" << test_port << " --> " << test_res.toString().data(); } return success & success2; }
QDebug outputHeader(QIODevice *out_device, const char *op) { //while(out_device->bytesToWrite()) // out_device->waitForBytesWritten(1); return QDebug(out_device).nospace() << "VZR\t" << op << "\t"; }
/*! \brief Writes a message to the logger. and returs a QDebug object with the current logdevice to stream additional data to. */ QDebug write(Logger::LogLevel logLevel, const char* file, int line, const char* function, unsigned int source) { LogDevice* d = logDevice(); d->lock(logLevel, file, line, function, source); return QDebug(d).nospace(); }
char *toString(const QModelIndex &index) { QString buf; QDebug(&buf) << index; return qstrdup(buf.toUtf8().constData()); }
QDebug write(Logger::LogLevel logLevel, const char* file, int line, const char* function) { LogDevice* d = logDevice(); d->lock(logLevel, file, line, function); return QDebug(d); }
void pf_mcontroller::telegramReceived(QByteArray telegram) { QDebug(QtDebugMsg) << "Telegram received:" << telegram; m_buf.add(telegram); }