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
pull/1/head
Antti Kervinen 15 years ago
parent c76174414b
commit 79739dae5d

@ -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

@ -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.*

@ -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/)

@ -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)

@ -24,6 +24,7 @@
#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#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;

@ -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;

@ -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/)

@ -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");

@ -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})

Loading…
Cancel
Save