Commit graph

29 commits

Author SHA1 Message Date
Caolán McNamara
30c582a720 make CppunitTest_framework_dispatch reliable
the appearance of 2 interceptions is reproducible for me on linux with

make CppunitTest_framework_dispatch VALGRIND=memcheck

1st time
 #1 (anonymous namespace)::MyInterceptor::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/qa/cppunit/dispatchtest.cxx:139
 #2 non-virtual thunk to (anonymous namespace)::MyInterceptor::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/qa/cppunit/dispatchtest.cxx:0
 #3 framework::InterceptionHelper::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/dispatch/interceptionhelper.cxx:87
 #4 non-virtual thunk to framework::InterceptionHelper::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/dispatch/interceptionhelper.cxx:0
 #5 (anonymous namespace)::XFrameImpl::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/services/frame.cxx:2329
 #6 non-virtual thunk to (anonymous namespace)::XFrameImpl::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/services/frame.cxx:0
 #7 framework::DispatchHelper::executeDispatch(com::sun::uno::Reference<com::sun::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::uno::Sequence<com::sun:🫘:PropertyValue> const&) at core/framework/source/services/dispatchhelper.cxx:110
 #8 non-virtual thunk to framework::DispatchHelper::executeDispatch(com::sun::uno::Reference<com::sun::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::uno::Sequence<com::sun:🫘:PropertyValue> const&) at core/framework/source/services/dispatchhelper.cxx:0
 #9 unotest::MacrosTest::dispatchCommand(com::sun::uno::Reference<com::sun::lang::XComponent> const&, rtl::OUString const&, com::sun::uno::Sequence<com::sun:🫘:PropertyValue> const&) at core/unotest/source/cpp/macros_test.cxx:94
 #10 (anonymous namespace)::testInterception::TestBody() at core/framework/qa/cppunit/dispatchtest.cxx:172

2nd time
 #1 (anonymous namespace)::MyInterceptor::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/qa/cppunit/dispatchtest.cxx:139
 #2 non-virtual thunk to (anonymous namespace)::MyInterceptor::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/qa/cppunit/dispatchtest.cxx:0
 #3 framework::InterceptionHelper::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/dispatch/interceptionhelper.cxx:87
 #4 non-virtual thunk to framework::InterceptionHelper::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/dispatch/interceptionhelper.cxx:0
 #5 (anonymous namespace)::XFrameImpl::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/services/frame.cxx:2329
 #6 non-virtual thunk to (anonymous namespace)::XFrameImpl::queryDispatch(com::sun::util::URL const&, rtl::OUString const&, int) at core/framework/source/services/frame.cxx:0
 #7 SfxStateCache::GetSlotServer(SfxDispatcher&, com::sun::uno::Reference<com::sun::frame::XDispatchProvider> const&) at core/sfx2/source/control/statcach.cxx:263
 #8 SfxBindings::UpdateSlotServer_Impl() at core/sfx2/source/control/bindings.cxx:1083
 #9 SfxBindings::NextJob_Impl(Timer const*) at core/sfx2/source/control/bindings.cxx:1254
 #10 SfxBindings::NextJob(Timer*) at core/sfx2/source/control/bindings.cxx:1222
 #11 SfxBindings::LinkStubNextJob(void*, Timer*) at core/sfx2/source/control/bindings.cxx:1219
 #12 Link<Timer*, void>::Call(Timer*) const at core/include/tools/link.hxx:111
 #13 Timer::Invoke() at core/vcl/source/app/timer.cxx:76
 #14 Scheduler::CallbackTaskScheduling() at core/vcl/source/app/scheduler.cxx:480
 #15 SalTimer::CallCallback() at core/vcl/inc/saltimer.hxx:55
 #16 SvpSalInstance::CheckTimeout(bool) at core/vcl/headless/svpinst.cxx:161
 #17 SvpSalInstance::ImplYield(bool, bool) at core/vcl/headless/svpinst.cxx:399
 #18 SvpSalInstance::DoYield(bool, bool) at core/vcl/headless/svpinst.cxx:471
 #19 ImplYield(bool, bool) at core/vcl/source/app/svapp.cxx:377
 #20 Scheduler::ProcessEventsToIdle() at core/vcl/source/app/svapp.cxx:407
 #21 unotest::MacrosTest::dispatchCommand(com::sun::uno::Reference<com::sun::lang::XComponent> const&, rtl::OUString const&, com::sun::uno::Sequence<com::sun:🫘:PropertyValue> const&) at core/unotest/source/cpp/macros_test.cxx:95
 #22 (anonymous namespace)::testInterception::TestBody() at core/framework/qa/cppunit/dispatchtest.cxx:172

setting bold/italic will invalidate the slot for the property and timer
starts to update the normal listeners to those properties which might
kick in on a slower run.

Change-Id: Ib37e61c0fbed463f8974d476158e54a0160a2c92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157798
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2023-10-11 15:20:30 +02:00
Miklos Vajna
3a759a0b0c Remove some unused includes
Mostly com/sun/star/frame/Desktop.hpp is unused after inheriting from
UnoApiTest.

Change-Id: I71b75fa5c880337ff294583b96af09c90b5059c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150514
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2023-04-17 19:01:11 +02:00
Noel Grandin
00f73472c1 try to fix CppunitTest_framework_dispatch on windows
I see occasional failures here, possibly they are a threading
issue since we are touching these fields from multiple threads.
Add a mutex to see if it helps.

Change-Id: I7277e96d07d292a6bc1d333dabec7a82fc607465
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150281
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-04-13 07:57:16 +02:00
Xisco Fauli
70a84bc0ee CppunitTest_framework_services: inherit from UnoApiTest
Change-Id: I8963f0dbf5e70347ee98e639dc6eeecc0f43b821
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143099
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2022-11-22 14:52:43 +01:00
Xisco Fauli
8654586816 CppunitTest_framework_loadenv: inherit from UnoApiTest
Change-Id: I9c997691d6b7f0c46089eec86b614bcd1a0d71a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143102
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2022-11-22 14:32:40 +01:00
Xisco Fauli
49cd099df4 CppunitTest_framework_dispatch: inherit from UnoApiTest
Change-Id: I9a839ffe01e1d5da49268bd8ad78dbedd8dadc25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143100
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2022-11-22 13:24:58 +01:00
Miklos Vajna
b6758293e6 Remove some unused includes
See tdf#42949 for motivation.

Change-Id: I157b331195cc8262e6bd1dcc536cb653587fc45f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135775
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-06-14 08:11:28 +02:00
Xisco Fauli
280c505373 CppunitTest_framework_dispatch: remove duplicated dispatchCommand
it's already defined in unotest::MacrosTest

Change-Id: I2abc4bea61f55242b9cf3c7f030f5c74f8a51efe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130402
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2022-02-23 09:06:59 +01:00
Mike Kaganski
6b973753d4 tdf#146754: consider xyz:123 as host:port when parsing URLs smart
... rather than scheme: and path.

Change-Id: I9a48310b585b8fa3e31635f877a91f1560b065f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128457
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-01-15 10:52:56 +01:00
Mike Kaganski
f662ba9536 Prepare for removal of non-const operator[] from Sequence in framework
Change-Id: Ied2683a0b8a1bab1a7594da1e9bdbd3cb753552c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124370
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-30 10:31:26 +02:00
Mike Kaganski
8a017d25a6 Avoid COW overhead using css::uno::Sequence
The scenarios are:

1. Calling sequence's begin() and end() in pairs to pass to algorithms
   (both calls use getArray(), which does the COW checks)
2. In addition to #1, calling end() again when checking result of find
   algorithms, and/or begin() to calculate result's distance
3. Using non-const sequences in range-based for loops, which internally
   do #1
4. Assigning sequence to another sequence variable, and then modifying
   one of them

In many cases, the sequences could be made const, or treated as const
for the purposes of the algorithms (using std::as_const, std::cbegin,
and std::cend). Where algorithm modifies the sequence, it was changed
to only call getArray() once. For that, css::uno::toNonConstRange was
introduced, which returns a struct (sublclass of std::pair) with two
iterators [begin, end], that are calculated using one call to begin()
and one call to getLength().

To handle #4, css::uno::Sequence::swap was introduced, that swaps the
internal pointer to uno_Sequence. So when a local Sequence variable
should be assigned to another variable, and the latter will be modified
further, it's now possible to use swap instead, so the two sequences
are kept independent.

The modified places were found by temporarily removing non-const end().

Change-Id: I8fe2787f200eecb70744e8b77fbdf7a49653f628
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123542
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-10-14 06:00:49 +02:00
Michael Stahl
7cbd6d768d sfx2: try to fix lifecycle of SfxOfficeDispatch
This can be created either from the global SfxApplication, or from a
SfxViewFrame.

Particularly in the latter case, the SfxDispatcher and SfxBindings
members are owned by SfxViewFrame, so in case that is destroyed, the
SfxOfficeDispatch must clear its pointers.

It looks like the member pointers are checked before access already
everywhere, so just listen at the SfxViewFrame.

Change-Id: If08825734e94dd54e32cb77546684fd583c336ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118162
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2021-06-30 18:40:27 +02:00
Noel Grandin
25a648541a fix leak in CppunitTest_framework_services
Change-Id: I522e3e9b57668d7a8d1df10f4520045a3a3553dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116524
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-06-01 12:57:37 +02:00
Moaz
a9a350c13d tdf#139734 Remove redundant asserts after MacrosTest::loadFromDesktop
MacrosTest::loadFromDesktop itself asserts on its return value.
Thus, the additional checks in unit tests are redundant, and only create
noise unrelated to the tested functionality.

Change-Id: If616001b296afdde38f5a23ececee3d44b4a395d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111290
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-02-25 07:50:29 +01:00
Noel
7767ff7b52 loplugin:referencecasting in editeng..framework
Change-Id: Ia3375011ecd0a65afed0f131f477fc1542603fde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110948
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-02-16 07:52:37 +01:00
Caolán McNamara
117ecc9870 fix coverity parse errors
Change-Id: I4884bfb67a061b865e8cf38b2fea6de0cb1bc3d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109057
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-01-10 21:01:05 +01:00
Stephan Bergmann
a3d0091d18 New loplugin:stringliteralvar
See the comment at the top of compilerplugins/clang/stringliteralvar.cxx for
details.

(Turned some affected variables in included files into inline variables, to
avoid GCC warnings about unused variables.)

Change-Id: Ie77219e6adfdaaceaa8b4e590b08971f2f04c83a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-26 14:51:15 +01:00
Miklos Vajna
85467e7cb9 tdf#137356 framework: fix opening the same document twice for long loads
If the document loading is long enough that the statusbar is updated,
then we can have this situation that we start loading the document, then
spin the main loop during load and do a second load of the same document
as part of the main loop spinning:

	#0  SwDoc::SwDoc() (this=0x1c6a180) at sw/source/core/doc/docnew.cxx:194
	...
	#6  0x00007ffff359a6dd in SfxBaseModel::load(com::sun::uno::Sequence<com::sun:🫘:PropertyValue> const&) (this=0x1c5c260, seqArguments=uno::Sequence of length 15 = {...})
	...
	#33 0x00007fffeeb81ecd in Application::Reschedule(bool) (i_bAllEvents=true) at vcl/source/app/svapp.cxx:460
	...
	#36 0x00007ffff4265251 in framework::StatusIndicator::start(rtl::OUString const&, int) (this=0x1aace80, sText="Loading document...", nRange=1000000) at framework/source/helper/statusindicator.cxx:51
	#37 0x00007fffd026dfd3 in XMLReader::Read(SwDoc&, rtl::OUString const&, SwPaM&, rtl::OUString const&) (this=0x1bb7d20, rDoc=..., rBaseURL="file:///.../test.odt", rPaM=SwPaM = {...}, rName="") at sw/source/filter/xml/swxml.cxx:630
	...
	#42 0x00007ffff359a6dd in SfxBaseModel::load(com::sun::uno::Sequence<com::sun:🫘:PropertyValue> const&) (this=0x1bce4d0, seqArguments=uno::Sequence of length 15 = {...}) at sfx2/source/doc/sfxbasemodel.cxx:1883

The reason for this is is that by the time
LoadEnv::impl_searchAlreadyLoaded() searches for frames which already
have this doc open, the first load is still in progress, and we
assiciate the frame with its controller (which has the URL) only once
the load finishes.

Fix the problem by setting the URL on the frame directly for the
duration of the load: this way an in-progress load also counts as a
duplicate and we'll have just one document open at the end.

Regression from commit 74ac65c49c
(#i114963# Enable IPC before OpenClients to allow client connections
when printing., 2016-09-06), we just didn't process incoming requests on
the socket before, so the problem was less visible.

Change-Id: Ib138c4c264e2508c20104ab268501bcca31e2790
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104310
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-10-14 18:41:26 +02:00
Miklos Vajna
07b399eb91 framework: lock the solar mutex in loadComponentFromURL() with OnMainThread
Regression from commit 2dc3a6c273
(framework: allow loading a component on the main thread, 2018-12-19),
which was a forward-port from a 5.4-based vendor branch, where this was
(it turns out) just working by accident, but never on master.

It can happen that loadComponentFromURL() is invoked on a thread, which
does not own the solar mutex. Then once
vcl::SolarThreadExecutor::execute() is called, it'll try to release the
solar mutex. But SolarMutexReleaser is unsafe: it'll release the mutex
even if it is owned by an other thread.

To make this a bit more safer, it'll abort in
comphelper::SolarMutex::doRelease(), in case the current thread doesn't
have the mutex already.

Fix the problem by taking the solar mutex in loadComponentFromURL():
this is meant to cause no performance problems, since the actual
importers typically start with taking the solar mutex anyway. Taking it
earlier would be problematic, since this can be invoked by UNO clients
directly. Taking it later in vcl/ would be also unusual: typically vcl
just asserts that the solar mutex is locked, doesn't take it itself.

Change-Id: I752006a91f16a02254d1b5ac6301100ab282630b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103264
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-09-24 17:45:29 +02:00
Miklos Vajna
6cc4aa93ba comphelper, drawinglayer, framework, starmath: clang-format these files
I added these files more or less recently and they have long lines. Use
clang-format to break at a sane column limit.

Change-Id: Id608fffbbc0673c9bc350dd696cb0a31906840d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94423
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2020-05-18 22:51:45 +02:00
Miklos Vajna
75a7932bb4 test: move component context from subclasses to BootstrapFixture
To avoid duplication.

Change-Id: I0ee7c26d5d55bd868ead04c77e7f4ef2582f90e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88138
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2020-02-07 09:13:50 +01:00
Noel Grandin
b1cfdb7bee new loplugin:unoquery
look for places we are doing code like:

    Reference<XProperty>(model, css::uno::UNO_QUERY)->getAsProperty()

which might result in a SIGSEGV is the query fails

Change-Id: I5cbdbc9e64bd0bed588297c512bf60cbacb9442e
Reviewed-on: https://gerrit.libreoffice.org/69044
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-25 07:19:13 +01:00
Miklos Vajna
47ce4b87d8 CppunitTest_framework_dispatch: use CPPUNIT_TEST_FIXTURE()
Change-Id: I2de32f700125fc8306c16fe4963ef76f87b0034c
Reviewed-on: https://gerrit.libreoffice.org/68435
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
2019-02-27 16:33:43 +01:00
Gabor Kelemen
8067be0721 tdf#42949 Fix IWYU warnings in include/vcl/[f-h]*
Found with bin/find-unneeded-includes
Only removal proposals are dealt with here.

Change-Id: Ice2eb8c5994bf2ccb88972332ca4a1d3ed41752a
Reviewed-on: https://gerrit.libreoffice.org/63826
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2018-11-27 10:35:30 +01:00
Miklos Vajna
feb463e93f xmlsecurity: fix inconsistent param naming in interface/implementation
Don't talk about enumeration when it's a number.

Change-Id: I756063534b38478c382eaf72829091a4e27a6c4f
Reviewed-on: https://gerrit.libreoffice.org/41779
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2017-09-01 10:33:33 +02:00
Noel Grandin
841e1a6f36 remove some old MSVC workarounds
Change-Id: I6abd8aaffb27b3c85df7c0518f7f576be4e32222
Reviewed-on: https://gerrit.libreoffice.org/36660
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-21 09:14:45 +02:00
Caolán McNamara
b2af27abaf update test to pass now that .ui files are found
with 506cab1a01

"take the .ui files from $BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR"

in place .ui files are found and the count here changes,

reverting the above makes it pass, but also reverting
08cf2fd010 (framework: last dispatchInterceptor
gets asked first, 2016-05-20) that this test wants to test also passes

Change-Id: I01f5b77065e9562619412824bf69494b7b672b68
2017-04-12 17:04:41 +01:00
Stephan Bergmann
e57ca02849 Remove dynamic exception specifications
...(for now, from LIBO_INTERNAL_CODE only).  See the mail thread starting at
<https://lists.freedesktop.org/archives/libreoffice/2017-January/076665.html>
"Dynamic Exception Specifications" for details.

Most changes have been done automatically by the rewriting loplugin:dynexcspec
(after enabling the rewriting mode, to be committed shortly).  The way it only
removes exception specs from declarations if it also sees a definition, it
identified some dead declarations-w/o-definitions (that have been removed
manually) and some cases where a definition appeared in multiple include files
(which have also been cleaned up manually).  There's also been cases of macro
paramters (that were used to abstract over exception specs) that have become
unused now (and been removed).

Furthermore, some code needed to be cleaned up manually
(avmedia/source/quicktime/ and connectivity/source/drivers/kab/), as I had no
configurations available that would actually build that code.  Missing @throws
documentation has not been applied in such manual clean-up.

Change-Id: I3408691256c9b0c12bc5332de976743626e13960
Reviewed-on: https://gerrit.libreoffice.org/33574
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-01-26 12:54:43 +00:00
Miklos Vajna
f8f0f834a1 Add initial CppunitTest_framework_dispatch
Fails with commit 08cf2fd010 (framework:
last dispatchInterceptor gets asked first, 2016-05-20) reverted.

Change-Id: I0e025a5d8996ecafa6b2fef753d6134079936b00
Reviewed-on: https://gerrit.libreoffice.org/25808
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-06-03 07:03:19 +00:00