[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: [kde-runtime] nepomuk/servicestub: Use a QApplication and a
From: Sebastian_Trüg <trueg () kde ! org>
Date: 2011-12-13 16:18:54
Message-ID: 4EE77AEE.2090200 () kde ! org
[Download RAW message or body]
well, it of course crashes if I use QCoreApplication but I am using
QApplication. :)
On 12/13/2011 04:18 PM, Vishesh Handa wrote:
> I don't think you can do this.
>
> I think I'd tried doing this once, but the file indexing service uses
> kidletime, which has this stupid line -
>
> kdelibs/kutils/kidletime/xsyncbasedpoller.cpp
> 117: KApplication::kApplication()->installX11EventFilter(this);
>
> Are you sure this doesn't lead to a run time crash? Cause that's what
> was happening to me.
>
> I tried doing this cause the oxygen skins or whatever are loaded if one
> uses KApplication, which we don't really need and they consume a good
> 2-3mb per service (not shared memory). I was trying to reduce Nepomuk's
> memory footprint.
>
> On Tue, Dec 13, 2011 at 6:42 PM, Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>> wrote:
>
> Git commit 7ae2157d7b95793a3e7396446ad9e741ee504187 by Sebastian Trueg.
> Committed on 13/12/2011 at 14:12.
> Pushed by trueg into branch 'master'.
>
> Use a QApplication and a KComponentData instead of a KApplication.
>
> This removes the KApplication DBus interface which allows us to
> control how the services are shut down, ie. deleting the service itself
> before shutting down the QCoreApplication.
>
> CCBUG: 257176
>
> M +4 -6 nepomuk/servicestub/main.cpp
> M +7 -4 nepomuk/servicestub/servicecontrol.cpp
> M +4 -1 nepomuk/servicestub/servicecontrol.h
>
> http://commits.kde.org/kde-runtime/7ae2157d7b95793a3e7396446ad9e741ee504187
>
> diff --git a/nepomuk/servicestub/main.cpp b/nepomuk/servicestub/main.cpp
> index 40cad5b..5bd446e 100644
> --- a/nepomuk/servicestub/main.cpp
> +++ b/nepomuk/servicestub/main.cpp
> @@ -1,5 +1,5 @@
> /* This file is part of the KDE Project
> - Copyright (c) 2008 Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>>
> + Copyright (c) 2008-2011 Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>>
>
> This library is free software; you can redistribute it and/or
> modify it under the terms of the GNU Library General Public
> @@ -23,7 +23,6 @@
> #include <KService>
> #include <KServiceTypeTrader>
> #include <KDebug>
> -#include <KApplication>
>
> #include <QtCore/QTextStream>
> #include <QtCore/QTimer>
> @@ -74,7 +73,7 @@ int main( int argc, char** argv )
> "0.2",
> ki18n("Nepomuk Service Stub"),
> KAboutData::License_GPL,
> - ki18n("(c) 2008, Sebastian Trüg"),
> + ki18n("(c) 2008-2011, Sebastian Trüg"),
> KLocalizedString(),
> "http://nepomuk.kde.org" );
> aboutData.setProgramIconName( "nepomuk" );
> @@ -102,10 +101,9 @@ int main( int argc, char** argv )
> args->clear();
>
> aboutData.setAppName( serviceName.toLocal8Bit() );
> - KApplication app( true /* The strigi service actually needs a
> GUI at the moment */ );
> - app.disableSessionManagement();
> + KComponentData component(aboutData);
> + QApplication app( argc, argv );
> installSignalHandler();
> - QApplication::setQuitOnLastWindowClosed( false );
> KGlobal::locale()->insertCatalog( serviceName );
>
>
> diff --git a/nepomuk/servicestub/servicecontrol.cpp
> b/nepomuk/servicestub/servicecontrol.cpp
> index 8a5130d..5ed591a 100644
> --- a/nepomuk/servicestub/servicecontrol.cpp
> +++ b/nepomuk/servicestub/servicecontrol.cpp
> @@ -1,5 +1,5 @@
> /* This file is part of the KDE Project
> - Copyright (c) 2008 Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>>
> + Copyright (c) 2008-2011 Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>>
>
> This library is free software; you can redistribute it and/or
> modify it under the terms of the GNU Library General Public
> @@ -29,6 +29,7 @@ Nepomuk::ServiceControl::ServiceControl( const
> QString& serviceName, const KServ
> : QObject( parent ),
> m_serviceName( serviceName ),
> m_service( service ),
> + m_nepomukServiceModule( 0 ),
> m_initialized( false )
> {
> m_description = service->comment();
> @@ -88,8 +89,8 @@ void Nepomuk::ServiceControl::start()
> // start the service
> // ====================================
> QString startErrorDescription;
> - Nepomuk::Service* module =
> m_service->createInstance<Nepomuk::Service>( this, QVariantList(),
> &startErrorDescription);
> - if( !module ) {
> + m_nepomukServiceModule =
> m_service->createInstance<Nepomuk::Service>( this, QVariantList(),
> &startErrorDescription);
> + if( !m_nepomukServiceModule ) {
> s << "Failed to start service " << m_serviceName << " ("<<
> startErrorDescription << ")." << endl;
> qApp->exit( ErrorFailedToStart );
> return;
> @@ -98,7 +99,7 @@ void Nepomuk::ServiceControl::start()
> // register the service
> // ====================================
> QDBusConnection::sessionBus().registerObject( '/' + m_serviceName,
> - module,
> +
> m_nepomukServiceModule,
>
> QDBusConnection::ExportScriptableSlots |
>
> QDBusConnection::ExportScriptableProperties |
>
> QDBusConnection::ExportAdaptors);
> @@ -107,6 +108,8 @@ void Nepomuk::ServiceControl::start()
>
> void Nepomuk::ServiceControl::shutdown()
> {
> + delete m_nepomukServiceModule;
> + m_nepomukServiceModule = 0;
> QCoreApplication::quit();
> }
>
> diff --git a/nepomuk/servicestub/servicecontrol.h
> b/nepomuk/servicestub/servicecontrol.h
> index dfdb6b3..e7b1b47 100644
> --- a/nepomuk/servicestub/servicecontrol.h
> +++ b/nepomuk/servicestub/servicecontrol.h
> @@ -1,5 +1,5 @@
> /* This file is part of the KDE Project
> - Copyright (c) 2008 Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>>
> + Copyright (c) 2008-2011 Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>>
>
> This library is free software; you can redistribute it and/or
> modify it under the terms of the GNU Library General Public
> @@ -24,6 +24,8 @@
> #include <KService>
>
> namespace Nepomuk {
> + class Service;
> +
> class ServiceControl : public QObject
> {
> Q_OBJECT
> @@ -57,6 +59,7 @@ namespace Nepomuk {
> QString m_description;
> QString m_readableName;
> KService::Ptr m_service;
> + Nepomuk::Service* m_nepomukServiceModule;
> bool m_initialized;
> };
> }
>
>
>
>
> --
> Vishesh Handa
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic