From 79739dae5dfd1f5263c22fda31f8430432910bcf Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Wed, 26 Jan 2011 14:41:11 +0200 Subject: [PATCH] Changes: according to code review Details: - qdeclarativeboostercache linked to X11 and QtGui - install in CMakeLists fixed to use TARGETS instead of FILES in boosters - removed qapplication parameter checking in booster cache --- debian/applauncherd-dev.install | 2 +- debian/applauncherd-launcher.install | 1 + src/mbooster/CMakeLists.txt | 3 +- src/qdeclarativebooster/CMakeLists.txt | 26 ++-- .../qdeclarativeboostercache.cpp | 124 ++++++------------ .../qdeclarativeboostercache_p.h | 3 - src/qtbooster/CMakeLists.txt | 7 +- .../TestApps/fala_qml_helloworld/main.cpp | 5 - .../unittests/ut_dbooster/CMakeLists.txt | 2 +- 9 files changed, 60 insertions(+), 113 deletions(-) diff --git a/debian/applauncherd-dev.install b/debian/applauncherd-dev.install index c181cfa..3192613 100644 --- a/debian/applauncherd-dev.install +++ b/debian/applauncherd-dev.install @@ -1,5 +1,5 @@ usr/lib/pkgconfig/qt-boostable.pc usr/share/qt4/mkspecs/features/qt-boostable.prf -usr/include/qdeclarativeboostercache.h +usr/include/applauncherd/qdeclarativeboostercache.h usr/lib/pkgconfig/qdeclarative-boostable.pc usr/share/qt4/mkspecs/features/qdeclarative-boostable.prf diff --git a/debian/applauncherd-launcher.install b/debian/applauncherd-launcher.install index a3ef49d..201134d 100644 --- a/debian/applauncherd-launcher.install +++ b/debian/applauncherd-launcher.install @@ -5,3 +5,4 @@ usr/lib/applauncherd/libmbooster.so usr/lib/applauncherd/libqtbooster.so usr/lib/applauncherd/libqdeclarativebooster.so usr/lib/libqdeclarativeboostercache.so +usr/lib/libqdeclarativeboostercache.so.* diff --git a/src/mbooster/CMakeLists.txt b/src/mbooster/CMakeLists.txt index 3a1d006..4ad246c 100644 --- a/src/mbooster/CMakeLists.txt +++ b/src/mbooster/CMakeLists.txt @@ -23,5 +23,4 @@ link_libraries(${MEEGOTOUCH_LIBRARIES} ${LIBDL} ${QT_QTCORE_LIBRARY}) add_library(mbooster MODULE ${SRC} ${MOC_SRC}) # Add install rule -install(FILES libmbooster.so DESTINATION /usr/lib/applauncherd/) - +install(TARGETS mbooster DESTINATION /usr/lib/applauncherd/) diff --git a/src/qdeclarativebooster/CMakeLists.txt b/src/qdeclarativebooster/CMakeLists.txt index 5521da4..492f66d 100644 --- a/src/qdeclarativebooster/CMakeLists.txt +++ b/src/qdeclarativebooster/CMakeLists.txt @@ -1,3 +1,5 @@ +include(FindX11) + # Qt support include(${QT_USE_FILE}) @@ -5,26 +7,26 @@ set(LAUNCHER "${CMAKE_HOME_DIRECTORY}/src/launcherlib") include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common ${LAUNCHER}) -# Hide all symbols except the ones explicitly exported in the code (like main()) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") - # Set sources set(PLUGINSRC qdeclarativebooster.cpp pluginfactory.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/booster.cpp ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp) set(LIBSRC qdeclarativeboostercache.cpp qdeclarativeboostercache.h qdeclarativeboostercache_p.h) -set(MOC_HDRS qdeclarativebooster.h) -qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) # Set executables add_library(qdeclarativeboostercache SHARED ${LIBSRC}) -target_link_libraries(qdeclarativeboostercache ${LIBDL} ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY}) +set_target_properties(qdeclarativeboostercache PROPERTIES + VERSION 0.1 SOVERSION 0) +target_link_libraries(qdeclarativeboostercache ${LIBDL} ${QT_QTCORE_LIBRARY} ${QT_QTDECLARATIVE_LIBRARY} ${QT_QTGUI_LIBRARY} ${X11_LIBRARIES}) -add_library(qdeclarativebooster MODULE ${PLUGINSRC} ${MOC_SRC}) -target_link_libraries(qdeclarativebooster ${LIBDL} ${QT_QTCORE_LIBRARY} "-L. -lqdeclarativeboostercache") -add_dependencies(qdeclarativebooster qdeclarativeboostercache) +add_library(qdeclarativebooster MODULE ${PLUGINSRC}) +set_target_properties(qdeclarativebooster PROPERTIES + COMPILE_FLAGS -fvisibility=hidden) +target_link_libraries(qdeclarativebooster ${LIBDL} "-L. -lqdeclarativeboostercache") +add_dependencies(qdeclarativebooster qdeclarativeboostercache) # Add install rule -install(FILES libqdeclarativebooster.so DESTINATION /usr/lib/applauncherd/) -install(FILES libqdeclarativeboostercache.so DESTINATION /usr/lib/) -install(FILES qdeclarativeboostercache.h DESTINATION /usr/include) +install(TARGETS qdeclarativebooster DESTINATION /usr/lib/applauncherd/) +install(TARGETS qdeclarativeboostercache DESTINATION /usr/lib) +install(FILES qdeclarativeboostercache.h DESTINATION /usr/include/applauncherd + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ) diff --git a/src/qdeclarativebooster/qdeclarativeboostercache.cpp b/src/qdeclarativebooster/qdeclarativeboostercache.cpp index 1c4a2c0..ebaeb66 100644 --- a/src/qdeclarativebooster/qdeclarativeboostercache.cpp +++ b/src/qdeclarativebooster/qdeclarativeboostercache.cpp @@ -24,6 +24,7 @@ #ifdef Q_WS_X11 #include +#include #endif QDeclarativeBoosterCachePrivate * const QDeclarativeBoosterCache::d_ptr = new QDeclarativeBoosterCachePrivate; @@ -63,6 +64,11 @@ void QDeclarativeBoosterCachePrivate::populate() } if (qApplicationInstance == 0) { +#ifdef __arm__ + QApplication::setGraphicsSystem("meego"); +#else + QApplication::setGraphicsSystem("raster"); +#endif qApplicationInstance = new QApplication(initialArgc, initialArgv); } @@ -74,97 +80,47 @@ QApplication* QDeclarativeBoosterCachePrivate::qApplication(int &argc, char **ar if (qApplicationInstance == 0) { qApplicationInstance = new QApplication(argc, argv); } else { - if (canUseCachedApp(argc, argv)) { - if(argc > ARGV_LIMIT) { - qWarning("MComponentCache: QCoreApplication::arguments() will not contain all arguments."); - } - - // Copy arguments to QCoreApplication - for (int i = 0; i < qMin(argc, ARGV_LIMIT); i++) { - qApp->argv()[i] = argv[i]; - } - - // This changes argc in QCoreApplication - initialArgc = qMin(argc, ARGV_LIMIT); - + if (argc > ARGV_LIMIT) { + qWarning("MComponentCache: QCoreApplication::arguments() will not contain all arguments."); + } + + // Copy arguments to QCoreApplication + for (int i = 0; i < qMin(argc, ARGV_LIMIT); i++) { + qApp->argv()[i] = argv[i]; + } + + // This changes argc in QCoreApplication + initialArgc = qMin(argc, ARGV_LIMIT); + #ifdef Q_WS_X11 - // reinit WM_COMMAND X11 property - if (qDeclarativeViewInstance) { - Display *display = QX11Info::display(); - if (display) { - XSetCommand(display, qDeclarativeViewInstance->effectiveWinId(), argv, argc); - } - } -#endif - } else { - // Clean up cache. - if (qDeclarativeViewInstance) { - delete qDeclarativeViewInstance; - qDeclarativeViewInstance = 0; + // reinit WM_COMMAND X11 property + if (qDeclarativeViewInstance) { + Display *display = QX11Info::display(); + if (display) { + XSetCommand(display, qDeclarativeViewInstance->effectiveWinId(), argv, argc); + + // set correct WM_CLASS properties + QString appName = QFileInfo(argv[0]).fileName(); + QString appClass = appName.left(1).toUpper(); + if (appName.length() > 1) + appClass += appName.right(appName.length() - 1); + + // reserve memory for C strings + QByteArray arrName(appName.toLatin1()); + QByteArray arrClass(appClass.toLatin1()); + + XClassHint class_hint; + class_hint.res_name = arrName.data(); + class_hint.res_class = arrClass.data(); + + XSetClassHint(display, qDeclarativeViewInstance->effectiveWinId(), &class_hint); } - - delete qApplicationInstance; - qApplicationInstance = new QApplication(argc, argv); } +#endif } return qApplicationInstance; } -bool QDeclarativeBoosterCachePrivate::canUseCachedApp(int &argc, char **argv) -{ - if ( hasExtraParams(argc, argv) ) - return false; - - return true; -} - -bool QDeclarativeBoosterCachePrivate::hasExtraParams(int &argc, char **argv) -{ - for (int i = 1; i < argc; ++i) - { - QString s(argv[i]); - - if ( - /* QApplication command options */ - (s == "-style") || - (s == "-stylesheet") || - (s == "-session") || - (s == "-widgetcount") || - (s == "-reverse") || - (s == "-graphicssystem") || - - /* X11 options */ - (s == "-display") || - (s == "-geometry" ) || - (s == "-fn" ) || - (s == "-font") || - (s == "-bg") || - (s == "-background") || - (s == "-fg") || - (s == "-foreground") || - (s == "-btn") || - (s == "-button") || - (s == "-name" ) || - (s == "-title" ) || - (s == "-visual" ) || - (s == "-ncols") || - (s == "-cmap") || - (s == "-im") || - (s == "-inputstyle" ) || - - /* help options, application will not be started */ - (s == "-v") || - (s.startsWith("-version")) || - (s.startsWith("--version")) || - (s == "-h") || - (s.startsWith("-help")) || - (s.startsWith("--help")) - ) - return true; - } - return false; -} - QDeclarativeView* QDeclarativeBoosterCachePrivate::qDeclarativeView() { QDeclarativeView *returnValue; diff --git a/src/qdeclarativebooster/qdeclarativeboostercache_p.h b/src/qdeclarativebooster/qdeclarativeboostercache_p.h index f48ef0c..0b5474c 100644 --- a/src/qdeclarativebooster/qdeclarativeboostercache_p.h +++ b/src/qdeclarativebooster/qdeclarativeboostercache_p.h @@ -33,9 +33,6 @@ public: QApplication* qApplication(int &argc, char **argv); QDeclarativeView* qDeclarativeView(); - bool canUseCachedApp(int &argc, char **argv); - bool hasExtraParams(int &argc, char **argv); - static const int ARGV_LIMIT; QApplication *qApplicationInstance; QDeclarativeView *qDeclarativeViewInstance; diff --git a/src/qtbooster/CMakeLists.txt b/src/qtbooster/CMakeLists.txt index c9da20a..de6e183 100644 --- a/src/qtbooster/CMakeLists.txt +++ b/src/qtbooster/CMakeLists.txt @@ -13,15 +13,12 @@ set(SRC qtbooster.cpp pluginfactory.cpp ${LAUNCHER}/appdata.cpp ${LAUNCHER}/boos ${LAUNCHER}/connection.cpp ${LAUNCHER}/logger.cpp ${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp) -set(MOC_HDRS qtbooster.h) -qt4_wrap_cpp(MOC_SRC ${MOC_HDRS}) - # Set libraries to be linked. link_libraries(${MEEGOTOUCH_LIBRARIES} ${LIBDL} ${QT_QTCORE_LIBRARY}) # Set executable -add_library(qtbooster MODULE ${SRC} ${MOC_SRC}) +add_library(qtbooster MODULE ${SRC}) # Add install rule -install(FILES libqtbooster.so DESTINATION /usr/lib/applauncherd/) +install(TARGETS qtbooster DESTINATION /usr/lib/applauncherd/) diff --git a/tests/Common/TestApps/fala_qml_helloworld/main.cpp b/tests/Common/TestApps/fala_qml_helloworld/main.cpp index 4590c80..76fe6a4 100644 --- a/tests/Common/TestApps/fala_qml_helloworld/main.cpp +++ b/tests/Common/TestApps/fala_qml_helloworld/main.cpp @@ -44,11 +44,6 @@ void timestamp(const char *s) Q_DECL_EXPORT int main(int argc, char **argv) { timestamp("application main"); -#ifdef __arm__ - QApplication::setGraphicsSystem("meego"); -#else - QApplication::setGraphicsSystem("raster"); -#endif QApplication *app = QDeclarativeBoosterCache::qApplication(argc, argv); timestamp("QApplication from cache"); diff --git a/tests/Common/unittests/ut_dbooster/CMakeLists.txt b/tests/Common/unittests/ut_dbooster/CMakeLists.txt index ad594ba..99011bb 100644 --- a/tests/Common/unittests/ut_dbooster/CMakeLists.txt +++ b/tests/Common/unittests/ut_dbooster/CMakeLists.txt @@ -8,7 +8,7 @@ ${LAUNCHER}/logger.cpp ${DBOOSTER}/qdeclarativebooster.cpp ${LAUNCHER}/singleinstance.cpp ${LAUNCHER}/socketmanager.cpp) # Set moc headers -set(MOC_HDRS ut_dbooster.h ${DBOOSTER}/qdeclarativebooster.h) +set(MOC_HDRS ut_dbooster.h) # Run moc qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})