Exemplo n.º 1
0
void Q3SocketDevice::init()
{
#if !defined(QT_NO_IPV6)
    if ( !initialized ) {
	WSAData wsadata;
	// IPv6 requires Winsock v2.0 or better.
	if ( WSAStartup( MAKEWORD(2,0), &wsadata ) != 0 ) {
#  if defined(QSOCKETDEVICE_DEBUG)
	    qDebug( "Q3SocketDevice: WinSock v2.0 initialization failed, disabling IPv6 support." );
#  endif
	} else {
	    qAddPostRoutine( cleanupWinSock );
	    initialized = 0x20;
	    return;
	}
    }
#endif

    if (!initialized) {
	WSAData wsadata;
	if ( WSAStartup( MAKEWORD(1,1), &wsadata ) != 0 ) {
#if defined(QT_CHECK_NULL)
	    qWarning( "Q3SocketDevice: WinSock initialization failed" );
#endif
#if defined(QSOCKETDEVICE_DEBUG)
	    qDebug( "Q3SocketDevice: WinSock initialization failed"  );
#endif
	    return;
	}
	qAddPostRoutine( cleanupWinSock );
	initialized = 0x11;
    }
}
Exemplo n.º 2
0
void qt_xdnd_setup() {
    // set up protocol atoms
    qt_x11_intern_atom( "XdndEnter", &qt_xdnd_enter );
    qt_x11_intern_atom( "XdndPosition", &qt_xdnd_position );
    qt_x11_intern_atom( "XdndStatus", &qt_xdnd_status );
    qt_x11_intern_atom( "XdndLeave", &qt_xdnd_leave );
    qt_x11_intern_atom( "XdndDrop", &qt_xdnd_drop );
    qt_x11_intern_atom( "XdndFinished", &qt_xdnd_finished );
    qt_x11_intern_atom( "XdndTypeList", &qt_xdnd_type_list );

    qt_x11_intern_atom( "XdndSelection", &qt_xdnd_selection );

    qt_x11_intern_atom( "XdndAware", &qt_xdnd_aware );
    qt_x11_intern_atom( "XdndProxy", &qt_xdnd_proxy );


    qt_x11_intern_atom( "XdndActionCopy", &qt_xdnd_action_copy );
    qt_x11_intern_atom( "XdndActionLink", &qt_xdnd_action_link );
    qt_x11_intern_atom( "XdndActionMove", &qt_xdnd_action_move );
    qt_x11_intern_atom( "XdndActionPrivate", &qt_xdnd_action_private );

    qt_x11_intern_atom( "QT_SELECTION", &qt_selection_property );
    qt_x11_intern_atom( "INCR", &qt_incr_atom );

    qAddPostRoutine( qt_xdnd_cleanup );
}
Exemplo n.º 3
0
static const NavEventUPP make_navProcUPP()
{
    if(mac_navProcUPP)
        return mac_navProcUPP;
    qAddPostRoutine(cleanup_navProcUPP);
    return mac_navProcUPP = NewNavEventUPP(qt_mac_filedialog_event_proc);
}
Exemplo n.º 4
0
void TSessionStoreFactory::loadPlugins()
{
    if (!ssifs) {
        ssifs = new QList<TSessionStoreInterface *>();
        qAddPostRoutine(cleanup);
        
        // Init hash
        hash.insert(TSessionSqlObjectStore().key().toLower(), SqlObject);
        hash.insert(TSessionCookieStore().key().toLower(), Cookie);
        hash.insert(TSessionFileStore().key().toLower(), File);

        QDir dir(Tf::app()->pluginPath());
        QStringList list = dir.entryList(QDir::Files);
        for (QStringListIterator i(list); i.hasNext(); ) {
            QPluginLoader loader(dir.absoluteFilePath(i.next()));
            TSessionStoreInterface *iface = qobject_cast<TSessionStoreInterface *>(loader.instance());
            if ( iface ) {
                ssifs->append(iface);
                QStringList keys = iface->keys();
                for (QStringListIterator j(keys); j.hasNext(); ) {
                    hash.insert(j.next(), Plugin);
                }
            }   
        }
    }
}
Exemplo n.º 5
0
    // Sets up the settings private instance. Should only be run once at startup
    void init() {
        // read the ApplicationInfo.ini file for Name/Version/Domain information
        QSettings::setDefaultFormat(QSettings::IniFormat);
        QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
        // set the associated application properties
        applicationInfo.beginGroup("INFO");
        QCoreApplication::setApplicationName(applicationInfo.value("name").toString());
        QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
        QCoreApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
        
        // Let's set up the settings Private instance on it's own thread
        QThread* thread = new QThread();
        Q_CHECK_PTR(thread);
        thread->setObjectName("Settings Thread");
        
        privateInstance = new Manager();
        Q_CHECK_PTR(privateInstance);
        
        QObject::connect(privateInstance, SIGNAL(destroyed()), thread, SLOT(quit()));
        QObject::connect(thread, SIGNAL(started()), privateInstance, SLOT(startTimer()));
        QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
        privateInstance->moveToThread(thread);
        thread->start();
        qCDebug(shared) << "Settings thread started.";    

        // Register cleanupPrivateInstance to run inside QCoreApplication's destructor.
        qAddPostRoutine(cleanupPrivateInstance);
    }    
Exemplo n.º 6
0
void TAppSettings::instantiate(const QString &path)
{
    if (!appSettings) {
        appSettings = new TAppSettings(path);
        qAddPostRoutine(::cleanup);
    }
}
Exemplo n.º 7
0
static WebGraphicHash* graphics()
{
    WebGraphicHash* hash = _graphics();

    if (hash->isEmpty()) {

        // prevent ~QPixmap running after ~QApplication (leaks native pixmaps)
        qAddPostRoutine(earlyClearGraphics);

        // QWebSettings::MissingImageGraphic
        hash->insert("missingImage", QPixmap(QLatin1String(":webkit/resources/missingImage.png")));
        // QWebSettings::MissingPluginGraphic
        hash->insert("nullPlugin", QPixmap(QLatin1String(":webkit/resources/nullPlugin.png")));
        // QWebSettings::DefaultFrameIconGraphic
        hash->insert("urlIcon", QPixmap(QLatin1String(":webkit/resources/urlIcon.png")));
        // QWebSettings::TextAreaSizeGripCornerGraphic
        hash->insert("textAreaResizeCorner", QPixmap(QLatin1String(":webkit/resources/textAreaResizeCorner.png")));
        // QWebSettings::DeleteButtonGraphic
        hash->insert("deleteButton", QPixmap(QLatin1String(":webkit/resources/deleteButton.png")));
        // QWebSettings::InputSpeechButtonGraphic
        hash->insert("inputSpeech", QPixmap(QLatin1String(":webkit/resources/inputSpeech.png")));
    }

    return hash;
}
Exemplo n.º 8
0
ApplicationSettings *ApplicationSettings::self() {
  if (!settings_self) {
    settings_self = new ApplicationSettings;
    qAddPostRoutine(cleanup);
  }
  return settings_self;
}
Exemplo n.º 9
0
 static FunctorCallConsumer * forThread(QThread * thread) {
    QMutexLocker lock(&m_threadObjectMutex);
    Map map = m_threadObjects;
    lock.unlock();
    Map::const_iterator it = map.find(thread);
    if (it != map.end()) return *it;
    FunctorCallConsumer * consumer = new FunctorCallConsumer;
    consumer->moveToThread(thread);
    if (thread != qApp->thread())
       QObject::connect(thread, SIGNAL(finished()), consumer, SLOT(deleteLater()));
    lock.relock();
    it = m_threadObjects.find(thread);
    if (it == m_threadObjects.end()) {
       if (thread == qApp->thread()) {
          Q_ASSERT(! m_appThreadObject);
          m_appThreadObject = consumer;
          qAddPostRoutine(&deleteAppThreadObject);
       }
       m_threadObjects.insert(thread, consumer);
       return consumer;
    } else {
       delete consumer;
       return *it;
    }
 }
Exemplo n.º 10
0
/*!
  \internal
  */
void QTouchDevicePrivate::registerDevice(QTouchDevice *dev)
{
    QMutexLocker lock(&devicesMutex);
    if (deviceList()->isEmpty())
        qAddPostRoutine(cleanupDevicesList);
    deviceList()->append(dev);
}
Exemplo n.º 11
0
/// Returns the actual singleton instance, creates it on first access. Mutex-protected.
/// ContextRegistryInfo and ContextPropertyInfo use this method to access the backend.
/// The optional \a backendName specifies the backend to force, ie: 'xml' or 'cdb'.
InfoBackend* InfoBackend::instance(const QString &backendName)
{
    static QMutex mutex;
    QMutexLocker locker(&mutex);
    if (!backendInstance)
    {
        // Backend instance doesn't exist -> create it
        if (backendName == "xml")
            backendInstance = new InfoXmlBackend;
        else if (backendName == "cdb")
            backendInstance = new InfoCdbBackend;
        else {
            if (InfoCdbBackend::databaseExists())
                backendInstance = new InfoCdbBackend;
            else
                backendInstance = new InfoXmlBackend;
        }

        // Move the backend to the main thread
        backendInstance->moveToThread(QCoreApplication::instance()->thread());

        // We must ensure that:
        // 1) QFileSystemWatcher is deleted before QCoreApplication.
        // 2) libcontextsubscriber can be unloaded successfully
        // (QCoreApplication cannot have a post routine that is inside a library
        // that has been unloaded.)

        // For 1), we add a post routine to QCoreApplication for deleting the
        // QFileSystemWathcer, for 2) we remove the post routine and delete the
        // QFileSystemWatcher when the library is unloaded.
        qAddPostRoutine(destroyInstance);
    }

    return backendInstance;
}
ViewItemManager *ViewItemManager::self() {
  if (!_vim_self) {
    _vim_self = new ViewItemManager;
    qAddPostRoutine(cleanup);
  }
  return _vim_self;
}
Exemplo n.º 13
0
OpenCVItem::OpenCVItem(QGraphicsItem *parent)
    :P(parent,Qt::Window) {

    static OpenCVStyle * style_=nullptr;
    if (style_==nullptr) {
        style_=new __private::OpenCVItemStyle/*construct by default style*/;
        qAddPostRoutine([]() {delete style_; style_=nullptr; });
    }

    this->setStyle(style_);

    {
        QPalette pal=this->palette();
        pal.setBrush(QPalette::Background,Qt::transparent);
        this->setPalette(pal);
    }

    this->resize(128,128);
    this->setMinimumWidth(128);
    this->setMinimumHeight(128);
    this->setPos(std::rand()&63,(std::rand()&63)+36);
    this->setAttribute(Qt::WA_DeleteOnClose);

    connect(this,&OpenCVItem::yChanged,this,[this]() {_onYChanged(); });
    connect(this,&OpenCVItem::xChanged,this,[this]() {_onXChanged(); });
}
void ObjectFactory::registerFactory(const QString& node, ObjectFactory *factory) {
  if (!factories) {
    factories = new QMap<QString,ObjectFactory*>;
    qAddPostRoutine(cleanupObjects);
  }
  factories->insert(node, factory);
}
void TMultiplexingServer::instantiate(int listeningSocket)
{
    if (!multiplexingServer) {
        multiplexingServer = new TMultiplexingServer(listeningSocket);
        qAddPostRoutine(::cleanup);
    }
}
Exemplo n.º 16
0
static const NavObjectFilterUPP make_navFilterUPP()
{
    if(mac_navFilterUPP)
        return mac_navFilterUPP;
    qAddPostRoutine(cleanup_navFilterUPP);
    return mac_navFilterUPP = NewNavObjectFilterUPP(qt_mac_nav_filter);
}
PlotItemManager *PlotItemManager::self() {
  if (!_self) {
    _self = new PlotItemManager;
    qAddPostRoutine(cleanup);
  }
  return _self;
}
Exemplo n.º 18
0
/*!
    Creates a service instance called \a name. The \a argc and \a argv
    parameters are parsed after the exec() function has been
    called. Then they are passed to the application's constructor.
    The application type is determined by the QtService subclass.

    The service is neither installed nor started. The name must not
    contain any backslashes or be longer than 255 characters. In
    addition, the name must be unique in the system's service
    database.

    \sa exec(), start(), QtServiceController::install()
*/
QtService::QtService(const std::map<QString, QVariant>& args, const QString &name)
{
#if defined(QtService_DEBUG)
    qInstallMsgHandler(QtServiceLogDebug);
    qAddPostRoutine(QtServiceCloseDebugLog);
#endif

    Q_ASSERT(!QtServiceBasePrivate::instance);
    QtServiceBasePrivate::instance = this;

    QString nm(name);
    if (nm.length() > 255) {
    qWarning("QtService: 'name' is longer than 255 characters.");
	nm.truncate(255);
    }
    if (nm.contains('\\')) {
    qWarning("QtService: 'name' contains backslashes '\\'.");
	nm.replace((QChar)'\\', (QChar)'\0');
    }

    d_ptr = new QtServiceBasePrivate(nm);
    d_ptr->q_ptr = this;

    d_ptr->serviceFlags = 0;
    d_ptr->sysd = 0;
    d_ptr->args = args;
}
void GraphicsFactory::registerFactory(const QString& node, GraphicsFactory *factory) {
  if (!factories) {
    factories = new QMap<QString,GraphicsFactory*>;
    qAddPostRoutine(cleanupGraphics);
  }
  factories->insert(node, factory);
}
void RelationFactory::registerFactory(const QString& node, RelationFactory *factory) {
  if (!factories) {
    factories = new QMap<QString,RelationFactory*>;
    qAddPostRoutine(cleanupRelations);
  }
  factories->insert(node, factory);
}
Exemplo n.º 21
0
/*!
    Sets \a iface to point to the implementation of the
    QAccessibleInterface for \a object, and returns \c QS_OK if
    successfull, or sets \a iface to 0 and returns \c QE_NOCOMPONENT if
    no accessibility implementation for \a object exists.

    The function uses the \link QObject::className() classname
    \endlink of \a object to find a suitable implementation. If no
    implementation for the object's class is available the function
    tries to find an implementation for the object's parent class.

    This function is called to answer an accessibility client's
    request for object information. You should never need to call this
    function yourself.
*/
QRESULT QAccessible::queryAccessibleInterface( QObject *object, QAccessibleInterface **iface )
{
    *iface = 0;
    if ( !object )
	return QE_INVALIDARG;

    if ( qAccessibleInterface ) {
	*iface = qAccessibleInterface->find( object );
	if ( *iface ) {
	    (*iface)->addRef();
	    return QS_OK;
	}
    }

    if ( !qAccessibleManager ) {
	qAccessibleManager = new QPluginManager<QAccessibleFactoryInterface>( IID_QAccessibleFactory, QApplication::libraryPaths(), "/accessible" );
	if ( !cleanupAdded ) {
	    qAddPostRoutine( qAccessibleCleanup );
	    cleanupAdded = TRUE;
	}
    }

    QInterfacePtr<QAccessibleFactoryInterface> factory = 0;
    QMetaObject *mo = object->metaObject();
    while ( mo ) {
	qAccessibleManager->queryInterface( mo->className(), &factory );
	if ( factory )
	    break;
	mo = mo->superClass();
    }
    if ( factory )
	return factory->createAccessibleInterface( mo->className(), object, iface );

    return QE_NOCOMPONENT;
}
Exemplo n.º 22
0
Settings::Settings() :
    settings_(QSettings::IniFormat, 
              QSettings::UserScope, 
              ".GlobiData/GomTVLeacher", "GomTVLeacher")
{
    qAddPostRoutine(clean);
}
Exemplo n.º 23
0
OxygenClient::OxygenClient(KDecorationBridge *b, KDecorationFactory *f)
    : KCommonDecorationUnstable(b, f)
    , colorCacheInvalid_(true)
    , helper_(*globalHelper)
{
    qAddPostRoutine(oxkwincleanupBefore);
}
Exemplo n.º 24
0
KstDialogs *KstDialogs::self() {
  if (!_self) {
    _self = new KstDialogs();
    qAddPostRoutine(KstDialogs::cleanup);
  }

  return _self;
}
Exemplo n.º 25
0
static QClipboardData *clipboardData()
{
    if (internalCbData == 0) {
        internalCbData = new QClipboardData;
        qAddPostRoutine(cleanupClipboardData);
    }
    return internalCbData;
}
Exemplo n.º 26
0
/*!
  Returns the application-wide default style sheet.This style sheet is
  used by rich text rendering classes such as QSimpleRichText,
  QWhatsThis and also QMessageBox to define the rendering style and
  available tags within rich text documents. It serves also as initial
  style sheet for the more complex render widgets QTextView and
  QTextBrowser.

  \sa setDefaultSheet()
*/
QStyleSheet* QStyleSheet::defaultSheet()
{
    if (!defaultsheet) {
	defaultsheet = new QStyleSheet();
	qAddPostRoutine( qt_cleanup_defaultsheet );
    }
    return defaultsheet;
}
Exemplo n.º 27
0
void QCursor::initialize()
{
    int shape;
    for( shape = 0; shape <= LastCursor; shape++ )
	cursorTable[shape].data = new QCursorData( shape );
    initialized = TRUE;
    qAddPostRoutine( cleanup );
}
Exemplo n.º 28
0
NetworkAccessManager *NetworkAccessManager::instance()
{
    if (!namInstance) {
        namInstance = new NetworkAccessManager;
        qAddPostRoutine(cleanupNetworkAccessManager);
    }
    return namInstance;
}
Exemplo n.º 29
0
static void sst_init()
{
    if ( !sst_list ) {
	sst_list = new QObjectList;
	Q_CHECK_PTR( sst_list );
	qAddPostRoutine( sst_cleanup );
    }
}
Exemplo n.º 30
0
static inline void makeDrawingPixmap()
{
    if ( !drawpm ) {
	qAddPostRoutine( cleanupButtonPm );
	drawpm = new QPixmap( drawingPixWidth, drawingPixHeight );
	CHECK_PTR( drawpm );
    }
}