Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / unx / kde4 / main.cxx
blob8c13180e2cef535de91b0d80909be7a3e5072b02
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <QApplication>
22 #include "KDEData.hxx"
23 #include "KDESalInstance.hxx"
25 #include <vclpluginapi.h>
27 #if OSL_DEBUG_LEVEL > 1
28 #include <stdio.h>
29 #endif
31 #include <rtl/string.hxx>
33 /// entry point for the KDE4 VCL plugin
34 extern "C" {
35 VCLPLUG_KDE4_PUBLIC SalInstance* create_SalInstance()
37 /* #i92121# workaround deadlocks in the X11 implementation
39 static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
40 /* #i90094#
41 from now on we know that an X connection will be
42 established, so protect X against itself
44 if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
46 #if QT_VERSION >= 0x040800
47 // let Qt call XInitThreads(), so that also Qt knows it's been used
48 // (otherwise QPixmap may warn about threads not being initialized)
49 QApplication::setAttribute( Qt::AA_X11InitThreads );
50 #else
51 XInitThreads();
52 // just in case somebody builds with old version and then upgrades Qt,
53 // otherwise this is a no-op
54 QApplication::setAttribute( static_cast< Qt::ApplicationAttribute >( 10 ));
55 #endif
58 #if QT_VERSION < 0x050000
59 // Qt 4.x support needs >= 4.1.0
60 OString aVersion( qVersion() );
61 SAL_INFO( "vcl.kde4", "qt version string is " << aVersion );
63 sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0;
64 nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32();
65 if( nIndex > 0 )
66 nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
67 if( nMajor != 4 || nMinor < 1 )
69 #if OSL_DEBUG_LEVEL > 1
70 sal_Int32 nMicro = 0;
71 if( nIndex > 0 )
72 nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
73 SAL_INFO( "vcl.kde4", "unsuitable qt version " << nMajor << "." << nMinor << "." << nMicro );
74 #endif
75 return NULL;
77 #endif
79 KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() );
80 SAL_INFO( "vcl.kde4", "created KDESalInstance " << &pInstance );
82 // initialize SalData
83 KDEData *salData = new KDEData( pInstance );
84 salData->Init();
85 salData->initNWF();
86 pInstance->SetLib(salData->GetLib());
88 return pInstance;
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */