コード例 #1
0
ファイル: filesystem.cpp プロジェクト: Iaroslav464/WineWizard
 bool checkFileSum(const QString &filePath, const QString &checksum)
 {
     bool res = false;
     WaitDialog wd;
     QObject *worker = new QObject;
     worker->moveToThread(new QThread);
     wd.connect(worker->thread(), &QThread::started, worker, [worker, &checksum, &res, &filePath]()
     {
         if (QFile::exists(filePath))
         {
             QFile f(filePath);
             f.open(QFile::ReadOnly);
             QByteArray data = f.readAll();
             f.close();
             QString fSum = QCryptographicHash::hash(data, QCryptographicHash::Sha1).toHex();
             res = fSum == checksum;
         }
         else
             res = false;
         worker->deleteLater();
     });
     wd.connect(worker, &QObject::destroyed, worker->thread(), &QThread::quit);
     wd.connect(worker->thread(), &QThread::finished, worker->thread(), &QThread::deleteLater);
     wd.connect(worker->thread(), &QThread::destroyed, &wd, &WaitDialog::accept);
     worker->thread()->start();
     wd.exec();
     return res;
 }
コード例 #2
0
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
    QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.loadAcquire();
    int shutdown = appShutdown.loadAcquire();
    if (!ptr && !shutdown) {
        static QBasicMutex connManager_mutex;
        QMutexLocker locker(&connManager_mutex);
        if (!(ptr = connManager_ptr.loadAcquire())) {
            ptr = new QNetworkConfigurationManagerPrivate;

            if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) {
                // right thread or no main thread yet
                ptr->addPreAndPostRoutine();
                ptr->initialize();
            } else {
                // wrong thread, we need to make the main thread do this
                QObject *obj = new QObject;
                QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPreAndPostRoutine()), Qt::DirectConnection);
                ptr->initialize(); // this moves us to the right thread
                obj->moveToThread(QCoreApplicationPrivate::mainThread());
                obj->deleteLater();
            }

            connManager_ptr.storeRelease(ptr);
        }
    }
    return ptr;
}
コード例 #3
0
ファイル: qnode.cpp プロジェクト: RSATom/Qt
/*!
    \internal
 */
void QNodePrivate::nodePtrDeleter(QNode *q)
{
    QObject *p = q->parent();
    if (p == nullptr)
        p = q;
    p->deleteLater();
}
コード例 #4
0
ファイル: uvision.cpp プロジェクト: githubcjl/uVision_cjl
void uVision::deleteThread()
{
	QObject* obj = sender();
	thumbnailthread * th = qobject_cast<thumbnailthread*>(obj);
	qDebug() << "delete thread..." << th->waitseconds();
	obj->deleteLater();
}
コード例 #5
0
ファイル: qfappdispatcher.cpp プロジェクト: SunRain/quickflux
QObject *QFAppDispatcher::singletonObject(QQmlEngine *engine, QString package, int versionMajor, int versionMinor, QString typeName)
{
    QString pattern  = "import QtQuick 2.0\nimport %1 %2.%3;QtObject { property var object : %4 }";

    QString qml = pattern.arg(package).arg(versionMajor).arg(versionMinor).arg(typeName);

    QObject* holder = 0;

    QQmlComponent comp (engine);
    comp.setData(qml.toUtf8(),QUrl());
    holder = comp.create();

    if (!holder) {
        qWarning() << QString("QuickFlux: Failed to gain singleton object: %1").arg(typeName);
        qWarning() << QString("Error: ") << comp.errorString();
        return 0;
    }

    QObject*object = holder->property("object").value<QObject*>();
    holder->deleteLater();

    if (!object) {
        qWarning() << QString("QuickFlux: Failed to gain singleton object: %1").arg(typeName);
        qWarning() << QString("Error: Unknown");
    }

    return object;
}
コード例 #6
0
ファイル: recursive.cpp プロジェクト: lyarbean/silk
QString Recursive::out()
{
    QString ret;

//    qDebug() << Q_FUNC_INFO << __LINE__ << m_target << m_child;
    QVariant child = m_child;
    static int qjsType = qRegisterMetaType<QJSValue>();
    if (child.type() == qjsType) {
        child = child.value<QJSValue>().toVariant();
    }


    if (m_target && child.type() == QVariant::List) {
        QObject *object = m_target->create(m_target->creationContext());
        SilkAbstractHttpObject *http = qobject_cast<SilkAbstractHttpObject *>(object);
        if (http) {
            http->setProperty("model", child);
            ret.append(http->out());
        }
        object->deleteLater();
    } else {
        qDebug() << Q_FUNC_INFO << __LINE__ << child.type() << (int)child.type() << child;
    }

//    qDebug() << Q_FUNC_INFO << __LINE__ << ret;
    return ret;
}
コード例 #7
0
ファイル: mediaview.cpp プロジェクト: flaviotordini/minitube
void MediaView::reloadCurrentVideo() {
    Video *video = playlistModel->activeVideo();
    if (!video) return;

    int oldFormat = video->getDefinitionCode();

    QObject *context = new QObject();
    connect(video, &Video::gotStreamUrl, context,
            [this, oldFormat, video, context](const QString &videoUrl, const QString &audioUrl) {
                context->deleteLater();
                if (oldFormat == video->getDefinitionCode()) return;
                QObject *context2 = new QObject();
                const qint64 position = media->position();
                connect(media, &Media::stateChanged, context2,
                        [position, this, context2](Media::State state) {
                            if (state == Media::PlayingState) {
                                media->seek(position);
                                context2->deleteLater();
                                Video *video = playlistModel->activeVideo();
                                QString msg = tr("Switched to %1")
                                                      .arg(VideoDefinition::forCode(
                                                                   video->getDefinitionCode())
                                                                   .getName());
                                MainWindow::instance()->showMessage(msg);
                            }
                        });

                if (audioUrl.isEmpty()) {
                    media->play(videoUrl);
                } else {
                    media->playSeparateAudioAndVideo(videoUrl, audioUrl);
                }
            });
    video->loadStreamUrl();
}
コード例 #8
0
void DBusFileDialogManager::destroyDialog(const QDBusObjectPath &path)
{
    QObject *object = m_dialogObjectMap.value(path);

    if (object)
        object->deleteLater();
}
コード例 #9
0
void BuildingComponentDialogCentralWidget::measureDownloadComplete(const std::string& uid, const boost::optional<BCLMeasure>& measure)
{
  QObject* sender = this->sender();
  if (sender){
    sender->deleteLater();
  }

  if (measure){
    // good
    // remove old measure
    boost::optional<BCLMeasure> oldMeasure = LocalBCL::instance().getMeasure(measure->uid());
    if (oldMeasure && oldMeasure->versionId() != measure->versionId()){
      LocalBCL::instance().removeMeasure(*oldMeasure);
    }
  }else{
    // error downloading measure
    // find measure in list by uid and re-enable
    for (Component* component : m_collapsibleComponentList->components()) {
      if (component->uid() == uid){
        component->checkBox()->setEnabled(true);
        break;
      }
    }
  }

  m_pendingDownloads.erase(uid);
  if (m_pendingDownloads.empty()){
    // show not busy
    m_progressBar->setValue(0);
    m_progressBar->setMinimum(0);
    m_progressBar->setMaximum(0);
    m_progressBar->setVisible(false);
    m_showNewComponents = true;
  }
}
コード例 #10
0
QScriptValue QDeclarativeObjectScriptClass::destroy(QScriptContext *context, QScriptEngine *engine)
{
    QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
    QScriptValue that = context->thisObject();

    if (scriptClass(that) != p->objectClass)
        return engine->undefinedValue();

    ObjectData *data = (ObjectData *)p->objectClass->object(that);
    if (!data->object)
        return engine->undefinedValue();

    QDeclarativeData *ddata = QDeclarativeData::get(data->object, false);
    if (!ddata || ddata->indestructible)
        return engine->currentContext()->throwError(QLatin1String("Invalid attempt  to destroy() an indestructible object"));

    QObject *obj = data->object;
    int delay = 0;
    if (context->argumentCount() > 0)
        delay = context->argument(0).toInt32();
    if (delay > 0)
        QTimer::singleShot(delay, obj, SLOT(deleteLater()));
    else
        obj->deleteLater();

    return engine->undefinedValue();
}
コード例 #11
0
ファイル: graph.cpp プロジェクト: higginsrty/RoutingApp
void Graph::destroy_dialog()
{
    if (started && paused)
        this->resume_animation();
    QObject *dialog = panel->findChild<QObject*>("nodeDialog");
    dialog->deleteLater();
}
コード例 #12
0
ファイル: MainWindow.cpp プロジェクト: YAYPony/MultiMC5
void MainWindow::taskEnd()
{
	QObject *sender = QObject::sender();
	if (sender == m_versionLoadTask)
		m_versionLoadTask = NULL;

	sender->deleteLater();
}
コード例 #13
0
void ExportPrimersDialog::sl_connectionCompleted() {
    QObject *connectionDialog = sender();
    if (Q_LIKELY(NULL != connectionDialog)) {
        connectionDialog->deleteLater();
    }
    initDatabases();
    sl_updateState();
}
コード例 #14
0
void QJnextMainLoop::deleteObject(uint id, QByteArray* result) {
	QObject *object = objects.take(id);
	if (object != bb::Application::instance())
		object->deleteLater();
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tObject" << id << "destroyed";
#endif
	*result = "";
}
コード例 #15
0
ファイル: quetzalrequest.cpp プロジェクト: euroelessar/qutim
void quetzal_close_request(PurpleRequestType type, void *ui_handle)
{
    qDebug() << Q_FUNC_INFO;
    Q_UNUSED(type);
    QObject *obj = quetzal_request_guard_value(ui_handle);
    if (QWidget *widget = qobject_cast<QWidget *>(obj))
        widget->close();
    if (obj) {
        obj->setProperty("quetzal_closed", true);
        obj->deleteLater();
    }
}
コード例 #16
0
void NewsFeed::removeAll()
{
#ifdef NEWS_DEBUG
	std::cerr << "NewsFeed::removeAll()" << std::endl;
#endif
	while (widgetList.count()) {
		QObject *item = widgetList.first();
		widgetList.pop_front();

		if (item) {
			item->deleteLater();
		}
	}
}
コード例 #17
0
void MachinetalkService::updateComplexRepeatedField(QObject *object, const google::protobuf::Message &message, const google::protobuf::FieldDescriptor *field, const QString &tempDir)
{
    const auto &name = QByteArray::fromStdString(field->camelcase_name());
    const gpb::Reflection *reflection = message.GetReflection();
    auto list = qvariant_cast<QVariant>(object->property(name)).toList();

    QList<int> removeList; // store index of items to remove
    bool lengthChanged = false;
    for (int i = 0; i < reflection->FieldSize(message, field); ++i)
    {
        const gpb::Message &subMessage = reflection->GetRepeatedMessage(message, field, i);
        const gpb::Descriptor *subDescriptor = subMessage.GetDescriptor();
        const gpb::FieldDescriptor *subField = subDescriptor->FindFieldByName("index");
        const gpb::Reflection *subReflection = subMessage.GetReflection();
        const int index = subReflection->GetInt32(subMessage, subField);

        while (list.size() < (index + 1))
        {
            QObject *newObject = recurseDescriptor(subDescriptor, object);
            list.append(QVariant::fromValue(newObject));
            lengthChanged = true;
        }

        QObject *item = qvariant_cast<QObject*>(list.at(index));
        Q_ASSERT(item != nullptr);
        if (recurseMessage(subMessage, item, tempDir) <= 1) // only index -> remove object
        {
            removeList.append(index);
        }
    }

    // remove marked items
    if (removeList.length() > 0)
    {
        std::sort(removeList.begin(), removeList.end());
        for (int k = (removeList.length() - 1); k >= 0; k--)
        {
            QObject *item = qvariant_cast<QObject*>(list.takeAt(removeList[k]));
            Q_ASSERT(item != nullptr);
            item->deleteLater();
        }
        lengthChanged = true;
    }

    if (lengthChanged) // we need to notify property bindings about changes in length
    {
        object->setProperty(name, QVariant::fromValue(list));
    }
}
コード例 #18
0
ファイル: filesystem.cpp プロジェクト: Iaroslav464/WineWizard
 void removePrefix(const QString &prefixHash, QWidget *parent)
 {
     WaitDialog wd(parent);
     QObject *worker = new QObject;
     worker->moveToThread(new QThread);
     wd.connect(worker->thread(), &QThread::started, worker, [worker, prefixHash]()
     {
         prefix(prefixHash).removeRecursively();
         worker->deleteLater();
     });
     wd.connect(worker, &QObject::destroyed, worker->thread(), &QThread::quit);
     wd.connect(worker->thread(), &QThread::finished, worker->thread(), &QThread::deleteLater);
     wd.connect(worker->thread(), &QThread::destroyed, &wd, &WaitDialog::accept);
     worker->thread()->start();
     wd.exec();
 }
コード例 #19
0
ファイル: mediaview.cpp プロジェクト: flaviotordini/minitube
void MediaView::snapshot() {
    qint64 currentTime = media->position() / 1000;

    QObject *context = new QObject();
    connect(media, &Media::snapshotReady, context,
            [this, currentTime, context](const QImage &image) {
                context->deleteLater();

                if (image.isNull()) {
                    qWarning() << "Null snapshot";
                    return;
                }

                QPixmap pixmap = QPixmap::fromImage(image.scaled(
                        videoWidget->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
                videoAreaWidget->showSnapshotPreview(pixmap);

                Video *video = playlistModel->activeVideo();
                if (!video) return;

                QString location = SnapshotSettings::getCurrentLocation();
                QDir dir(location);
                if (!dir.exists()) dir.mkpath(location);
                QString basename = video->getTitle();
                QString format = video->getDuration() > 3600 ? "h_mm_ss" : "m_ss";
                basename += " (" + QTime(0, 0, 0).addSecs(currentTime).toString(format) + ")";
                basename = DataUtils::stringToFilename(basename);
                QString filename = location + "/" + basename + ".png";
                qDebug() << filename;
                image.save(filename, "PNG");

                if (snapshotSettings) delete snapshotSettings;
                snapshotSettings = new SnapshotSettings(videoWidget);
                snapshotSettings->setSnapshot(pixmap, filename);
                QStatusBar *statusBar = MainWindow::instance()->statusBar();
#ifdef APP_EXTRA
                Extra::fadeInWidget(statusBar, statusBar);
#endif
                statusBar->insertPermanentWidget(0, snapshotSettings);
                snapshotSettings->show();
                MainWindow::instance()->setStatusBarVisibility(true);
            }
#endif
    );

    media->snapshot();
}
コード例 #20
0
void NetmusicWidget::netmusicThreadFinished()
{
    QObject* obj = sender();
    TipThread * th = qobject_cast<TipThread*>(obj);
    obj->deleteLater();
}
コード例 #21
0
ファイル: globalprivate.cpp プロジェクト: bigfug/Fugio
void GlobalPrivate::initialisePlugins()
{
	bool	LastChance = false;
	int		ResCnt = mPluginInitList.size();

	while( ResCnt > 0 )
	{
		ResCnt = 0;

		for( int i = 0 ; i < mPluginInitList.size() ; )
		{
			QObject							*PlgObj = mPluginInitList.at( i );
			fugio::PluginInterface			*PlgInt = qobject_cast<fugio::PluginInterface *>( PlgObj );

			if( !LastChance )
			{
				qDebug() << "Initialising plugin" << PlgObj->metaObject()->className();
			}
			else
			{
				qDebug() << "Initialising plugin" << PlgObj->metaObject()->className() << "(Last Chance)";
			}

			qApp->processEvents();

			fugio::PluginInterface::InitResult		 PlgRes = PlgInt->initialise( this, LastChance );

			if( PlgRes == fugio::PluginInterface::INIT_OK )
			{
				mPluginInstances.append( PlgObj );

				mPluginInitList.removeAt( i );

				ResCnt++;

				LastChance = false;

				continue;
			}

			if( PlgRes == fugio::PluginInterface::INIT_FAILED )
			{
				qWarning() << "Can't initialise plugin" << PlgObj->metaObject()->className();

				PlgObj->deleteLater();

				mPluginInitList.removeAt( i );

				ResCnt++;

				continue;
			}

			i++;
		}

		if( !ResCnt && !LastChance )
		{
			ResCnt++;

			LastChance = true;
		}
	}

	qDeleteAll( mPluginInitList );

	mPluginInitList.clear();

	qDebug() << tr( "Plugins loaded: %1" ).arg( mPluginInstances.size() );

	qDebug() << tr( "Nodes registered: %1" ).arg( mNodeMap.size() );
}