summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qjnihelpers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.10' into devLars Knoll2018-01-021-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
| * Fix Android Service thread getting stuck in service startupHeikki Haveri2017-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change allows services using QAndroidService to function properly. A service using a plain QCoreApplication is still affected. The original code uses postfix decrement, causing an off-by-one error in reference counting, which, in turn, fails to properly release a semaphore. Fix by using deref() instead, which is also more readable, and consistent with the use of ref() elsewhere in the code. Task-number: QTBUG-64728 Change-Id: I99b59307638d619506c594f86de6d7d202d755f2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-7/+7
|/ | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Forward Service.onBind notification to QtBogDan Vatra2017-07-041-1/+33
| | | | | | | It is needed to implement Android Binder in Qt. Change-Id: I8f6f8ef778f97a444a1b16d6f62e211e188b65cc Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-191-7/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
| * Android: Fix deadlock when calling requestPermissionBogDan Vatra2017-06-071-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The hang happend when using QtAndroidPrivate::requestPermissions before the QApplication::exec. Android UI calls "sendRequestPermissionsResult" which was blocking until the event is delivered, but the qt main loop is blocked and waits for the main surface to be created by the Android UI thread which is already blocked. With this patch sendRequestPermissionsResult won't block for the result to be delivered. Change-Id: I48ada65fe9ea63471ab46d8a9d839ba1b91d17b3 Reviewed-by: Christian Stromme <christian.stromme@qt.io>
* | Android: Allow timeout to fade out splash screenMathias Hasselmann2017-03-011-3/+3
|/ | | | | | Change-Id: I7b24f4d402da7f74b4c983467008ff4c19fc3b1b Task-number: QTBUG-59200 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-02-161-24/+25
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/plugin/qlibrary_unix.cpp src/plugins/platforms/xcb/qxcbconnection.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp Change-Id: I632c400d909f8c204f55743aadc7886af2f15dfb
| * QJNIHelpers: unbreak runnables counterMarc Mutz2017-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding 0 each time will obviously not produce a new identifier each time... Also use static initialization for QBasicAtomicInt. A default-constructed static QBasicAtomicInt at function scope will be dynamically initialized. It will still be zero-initialized, but at least GCC adds guard variables for such objects. When using aggregate initialization, the guard disappears. Amends 265db5ad9bda9c984393c1e95fd27dcc4633ed1c. Change-Id: Ia71290cf26c486dcbcc74381f12cd0c4712d6019 Reviewed-by: David Faure <david.faure@kdab.com>
| * QJNIHelpers: make mutexes staticMarc Mutz2017-02-151-2/+2
| | | | | | | | | | | | | | Amends 265db5ad9bda9c984393c1e95fd27dcc4633ed1c. Change-Id: I707bb88285531ee9f82efec46901871d53413eb3 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * Fix UB (data race) in QtAndroidPrivate::requestPermissionsSync()Marc Mutz2017-02-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the QSemaphore::tryAcquire() call times out, we mustn't touch *res, because there was no happens-before relation established between *res = result in the lambda and our returning *res; Fix by returning a default-constructed hash in that case. Add a strategic std::move(). The same problem exists in runOnAndroidThreadSync(), but I have no idea how to solve it, because there the shared object is the runnable itself. Change-Id: I9a2c431144c169fbd545763555d96153143a11bf Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * QJNIHelper: fix a potential race in sendRequestPermissionsResult()Marc Mutz2017-02-151-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code obtained an iterator into a QHash under mutex protection, then dropped the lock, dereferenced the iterator several times and only retook the lock to erase the element from the QHash. This is very smelly. QHash provides no official iterator validity guarantees, and the container isn't const, either (which would imply thread-safety). In particular, the dereference into the container outside the critical section is cause for concerns. Simplify the code, removing any doubts about its race-freedom, by taking the payload item out of the hash before dropping the lock, and using only the local strong reference in the remainder of the function. The only other references to g_pendingPermissionRequests are insertions with unique-by-construction keys in QtAndroidPrivate's requestPermissions(), so there was no reason to keep the item in the hash for the whole duration of the sendRequestPermissionsResult() call. Change-Id: I39fe0803b13b3046d1f0fd9c8e96c531406d57da Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * Enable QtAndroid::runOnAndroidThread in a ServiceHeikki Haveri2017-02-151-1/+1
| | | | | | | | | | Change-Id: I214f5dc70c52011a5e1712ea70f97f8b564fb664 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * QJNIHelper: clean up atomic int and mutex handlingMarc Mutz2017-02-141-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | 1. Do not use Q_GLOBAL_STATIC to hold QAtomicInt or QMutex, use file-static QBasicAtomicInt and QBasicMutex instead. They are zero-initialized PODs. 2. Use only QMutexLocker to lock mutexes. Also wrap the atomic counter into a next...() function, as done elsewhere. Change-Id: I4b14ac0de9d4cb6780b1f1372c2b5fc88e918e4c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Android: De-duplicate vtables of exported private classesMarc Mutz2017-02-161-0/+12
|/ | | | | | | | | | | | | | | | | | | | By making the destructor (usually the first non-inline, non-pure, virtual function, and therefore the trigger for most compilers to emit the vtable and type_info structures for the class in that TU) out-of-line, vtables and, more importantly, type_info structures for the class are pinned to a single TU. This prevents false-negative dynamic_cast and catch evaluation. Since the classes are already exported, users of these classes are unaffected by the change, and since it's private API, we don't need to avoid adding code to the out-of-line destructor until Qt 6. While at it, de-inline also the empty default implementations of virtual (non-dtor) functions. Task-number: QTBUG-45582 Change-Id: I3e6f37eab1dee0db445f6c13638a43ca3bf6ac62 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Say hello to Android 6+ permissions modelBogDan Vatra2016-09-161-1/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | This API was introduced by Android v23 and is used in connection with the new permission request system. From Android v23 onwards, some permissions such as Location permissions cannot only be granted via Android's Manifest files. An additional runtime check/request system was introduced which forces applications to prompt the user the first time a privileged function is called. Such user prompt responses are returned to the current application via the Activity.onRequestPermissionsResult(..) callback. This change add Qt API to nicely check & request permissions. For now this is private API which can be used to fix permission problems in other Qt compontents. Later Qt versions will introduce a public API to QtAndroidExtras. [ChangeLog][QtCore][Android] Introduced a mechanism to forward permission related callbacks on Activity objects to interested parties. Task-number: QTBUG-55035 Task-number: QTBUG-50759 Change-Id: I64ee748d741b39e35c4713ed9fdd15dd1d96dc56 Reviewed-by: Christian Stromme <christian.stromme@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add QtAndroidPrivate::context()Alex Blasche2016-08-031-0/+10
| | | | | | | | This simplifies the retrieval of the correct Context object. Task-number: QTBUG-55102 Change-Id: I303bc5393a7900ceb4bde36e711938f3f49075c1 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Perfect (almost) Qt on Android splash screen.BogDan Vatra2016-02-241-1/+7
| | | | | | | | | | | | | There is no need to show the splash image immediately when the application starts, because it will be removed shortly in QtActivityDelegate.java, therefore show the splash in QtActivityDelegate.java. This patch also adds a new option to AndroidManifest.xml which keeps the splash screen visible until user to decides to hide it, by using the QtAndroid::hideSplashScreen() function. Change-Id: I8a29a5a757d626c4c9d6a2748a60ca3091ebf82d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Say hello to Android ServicesBogDan Vatra2016-02-171-2/+53
| | | | | | | | | | | | | | This changeset enables running a QCoreApplication from within an Android Service. The Android Application running can now have a QtActivity or a QtService, but having both in the same process is not supported. This patch was based on Cory Slep's patch [ChangeLog][Android] Qt can now be used to easily create Android Services. Task-number: QTBUG-37221 Change-Id: I0fd693daaa85b991940ffe9cc41c483022677199 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Android: Add runOnAndroidThreadSyncBogDan Vatra2016-02-041-0/+11
| | | | | | | This is a convenient function which waits (timoutMS) for the runnable to be executed. Change-Id: I2c0f262d3795c29961e8182b7ffc35a2c6f8a1f6 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
* Helper function needed to run Runnables on Android UI thread easily.BogDan Vatra2016-01-151-17/+38
| | | | | | | | Add a function to allow the users to easily run asynchronously Runnables for any thread directly on Andoroid UI thread. Change-Id: I631bf8a2c602e038039fec621ec01272af20a400 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QtCore: eradicate all Q_FOREACH loops [kernel]Marc Mutz2016-01-121-2/+2
| | | | | | | | Saves just 168b in text size on optimized GCC 4.9 Linux AMD64 builds, but most for loops are in non-Linux code. Change-Id: I4f20a65c2e4953011308ff831c9e8fa37a25274b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Dispatch all key and all generic motion events java objects to QtCoreBogDan Vatra2015-10-151-1/+62
| | | | | | | | | | These events are needed to enable the usage of all input methods available on Android e.g. gamepads, stylus, etc. In orer to get GenericMotionEvents your application min API version must be at least 12, otherwise the application will receive only key events. Change-Id: I7564fccaf5423aa318ba4f62317eaf101ba6e97e Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Added new private API for Android and onPause/onResumePeter Rustler2015-03-171-0/+39
| | | | | | | | | | | | | | | On Android the foreground activity can get onPause/onResume calls. In Nfc code in android we need to know if we are paused or resumed. And we need to make sure to call disableForegroundDispatch inside the onPause call and in the main Ui thread. The current implementiton of applicationStateChanged was not sufficient to acomplish that. This patch adds a way to receive those onPause/onResume calls in Qt with proper timing. Change-Id: I3a8cec093fc02ec42cc8677dfe2d0d4f8a227f8b Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Added new private API for Android and onNewIntentPeter Rustler2015-01-211-0/+33
| | | | | | | | | | | | | On Android the foreground activity can get intents with onNewIntent. Those intents can not be received in any other way. This is especially true in Android nfc. This patch adds a way to receive those intents in Qt. This patch heavily leans on the implementation of onActivityResult. Change-Id: Ic4dca301f34afe9a528149c3653e545ed3265a3c Reviewed-by: BogDan Vatra <bogdan@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Android: Add runOnUiThread() functionChristian Strømme2014-11-031-0/+38
| | | | | | | | Enables QRunnables to be run on the UI thread. For now this function is only intended for internal consumption. Change-Id: I5e2abb06104219a9dd55b3308113056e4da5fa07 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Android: Use exceptionCheck() function.Christian Strømme2014-06-051-3/+1
| | | | | | | | | This was the only place where we didn't use the exceptionCheck() function. Besides being more consistent, it's also more verbose if an exception occurs. Change-Id: Ib1e3dba82b0730cf189ec725f4da425d7ac85cdc Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Add enablers for listening to activity resultsEskil Abrahamsen Blomfeldt2014-02-151-0/+35
| | | | | | | | | | | | | | | | | | | When you launch an activity through an intent, data can be provided back from the activity when it has finished using onActivityResult() in the activity which launched it. This is okay for applications, since they can easily create their own activities, but does not work for libraries that need to use intents. There is no listener API for activity results which allow external classes to eavesdrop. In order to support launching intents from third-party or add-on libraries, we provide a low-level way to hook into the activity result event. The corresponding public API will be added to QtAndroidExtras. Change-Id: I89417f485e2c0e69028dcccc7c155788346a7417 Reviewed-by: Christian Stromme <christian.stromme@digia.com>
* Android: Add convenience function to get the API level.Christian Strømme2014-01-161-0/+21
| | | | | | | | | It's common to check the Android API level at runtime to determine what functionality is available. This change provides a convenient way to get the Android SDK version (API level) from c++. Change-Id: I88f65ae87e0fa8ac0affefffbd1b1bba855c9f46 Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Android: Fix problem with leaking local refs.Christian Strømme2013-10-301-0/+2
| | | | | | | | | In some cases we where not releasing the local references and since we no longer disconnect from the VM on each call, the number of local refs. would accumulating until it hit the hard-limit of 512. Change-Id: I6826620e4cb61a37af26d276667489e876080076 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Use the application's class loader when loading Java classes.Christian Strømme2013-09-251-0/+20
| | | | | | | | | Previously the system class loader was used, which meant only system Java classes where available. With this change it's no longer necessary to add a JNI_OnLoad() to get a handle to application specific classes. Change-Id: Ic8fe35b4e525bfeb1d317d5ba6b496e39bf9bb30 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
* Android: Added JNI_OnLoad to QtCoreChristian Strømme2013-09-201-0/+99
JNI_OnLoad is called for each library during the start-up of a Qt application on Android. When the JNI_OnLoad is called we can get a handle to the Java VM and necessary classes which enables us to access Java API's in QtCore. Change-Id: I64c1f1106cc0d5ab5a7bc9b22c752c09162fe813 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>