Index: plasmaapp.cpp =================================================================== --- plasmaapp.cpp (revision 738849) +++ plasmaapp.cpp (working copy) @@ -50,12 +50,12 @@ Colormap colormap = 0; Visual *visual = 0; -void checkComposite() +bool checkComposite() { dpy = XOpenDisplay(0); // open default display if (!dpy) { kError() << "Cannot connect to the X server" << endl; - return; + return true; } int screen = DefaultScreen(dpy); @@ -83,20 +83,16 @@ kDebug() << (colormap ? "Plasma has an argb visual" : "Plasma lacks an argb visual") << visual << colormap; kDebug() << ((KWindowSystem::compositingActive() && colormap) ? "Plasma can use COMPOSITE for effects" : "Plasma is COMPOSITE-less") << "on" << dpy; + return true; } PlasmaApp* PlasmaApp::self() { - if (!kapp) { - checkComposite(); - return new PlasmaApp(dpy, visual ? Qt::HANDLE(visual) : 0, colormap ? Qt::HANDLE(colormap) : 0); - } - return qobject_cast(kapp); } -PlasmaApp::PlasmaApp(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) - : KUniqueApplication(display, visual, colormap), +PlasmaApp::PlasmaApp() + : KUniqueApplication(checkComposite() ? dpy : dpy, visual ? Qt::HANDLE(visual) : 0, colormap ? Qt::HANDLE(colormap) : 0), m_root(0), m_corona(0) { Index: plasmaapp.h =================================================================== --- plasmaapp.h (revision 738849) +++ plasmaapp.h (working copy) @@ -37,6 +37,7 @@ { Q_OBJECT public: + PlasmaApp(); ~PlasmaApp(); static PlasmaApp* self(); @@ -54,7 +55,6 @@ void setCrashHandler(); private: - PlasmaApp(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap); static void crashHandler(int signal); void createPanels(); Index: main.cpp =================================================================== --- main.cpp (revision 738849) +++ main.cpp (working copy) @@ -46,9 +46,7 @@ options.add("nodesktop",ki18n("Starts plasma as an ordinary window rather than as the desktop.")); KCmdLineArgs::addCmdLineOptions(options); - PlasmaApp *app = PlasmaApp::self(); - app->disableSessionManagement(); // autostarted - int rc = app->exec(); - delete app; - return rc; + PlasmaApp app; + app.disableSessionManagement(); // autostarted + return app.exec(); }