This reverts commit1289d3c42a
, plus follow-ups762e90ffa0
"vcl: loplugin:pointertobool" and863e5685dd
"Fix funny line-ends," as it causes memory corruption, see valgrind "make CppunitTest_sw_ooxmlexport4" output: > Invalid write of size 1 > Scheduler::ImplInvoke(unsigned long) (/vcl/source/app/scheduler.cxx:40) > Scheduler::ProcessTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:128) > Scheduler::CallbackTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:112) > SalTimer::CallCallback(bool) (/vcl/inc/saltimer.hxx:53) > SvpSalInstance::CheckTimeout(bool) (/vcl/headless/svpinst.cxx:191) > SvpSalInstance::Yield(bool, bool) (/vcl/headless/svpinst.cxx:307) > ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:353) > Application::Reschedule(bool) (/vcl/source/app/svapp.cxx:377) > framework::StatusIndicatorFactory::impl_reschedule(bool) (/framework/source/helper/statusindicatorfactory.cxx:528) > framework::StatusIndicatorFactory::end(com::sun:⭐:uno::Reference<com::sun:⭐:task::XStatusIndicator> const&) (/framework/source/helper/statusindicatorfactory.cxx:229) > framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:70) > non-virtual thunk to framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:57) > writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) (/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:531) > WriterFilter::filter(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:191) > non-virtual thunk to WriterFilter::filter(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:126) > SfxObjectShell::ImportFrom(SfxMedium&, com::sun:⭐:uno::Reference<com::sun:⭐:text::XTextRange> const&) (/sfx2/source/doc/objstor.cxx:2271) > SfxObjectShell::DoLoad(SfxMedium*) (/sfx2/source/doc/objstor.cxx:767) > SfxBaseModel::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1859) > non-virtual thunk to SfxBaseModel::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1810) > (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&, com::sun:⭐:uno::Reference<com::sun:⭐:frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:703) > non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&, com::sun:⭐:uno::Reference<com::sun:⭐:frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:615) > framework::LoadEnv::impl_loadContent() (/framework/source/loadenv/loadenv.cxx:1122) > framework::LoadEnv::startLoading() (/framework/source/loadenv/loadenv.cxx:383) > framework::LoadEnv::loadComponentFromURL(com::sun:⭐:uno::Reference<com::sun:⭐:frame::XComponentLoader> const&, com::sun:⭐:uno::Reference<com::sun:⭐:uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/framework/source/loadenv/loadenv.cxx:164) > framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/framework/source/services/desktop.cxx:566) > non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/framework/source/services/desktop.cxx:552) > unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/unotest/source/cpp/macros_test.cxx:50) > SwModelTestBase::load(char const*, char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:580) > SwModelTestBase::executeImportExportImportTest(char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:219) > testTrackChangesDeletedParagraphMark::Import_Export_Import() (/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx:132) > CppUnit::TestCaller<testTrackChangesDeletedParagraphMark>::runTest() (/workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166) > CppUnit::TestCaseMethodFunctor::operator()() const (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32) > (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/test/source/vclbootstrapprotector.cxx:57) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (in /home/sbergman/lo/core/workdir/LinkTarget/Library/unobootstrapprotector.so) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77) > CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181) > CppUnit::TestCase::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91) > CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64) > CppUnit::TestComposite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23) > CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64) > CppUnit::TestComposite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23) > CppUnit::TestRunner::WrappingSuite::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:47) > CppUnit::TestResult::runTest(CppUnit::Test*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:148) > CppUnit::TestRunner::run(CppUnit::TestResult&, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:96) > Address 0x2c9ece48 is 40 bytes inside a block of size 104 free'd > operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) > (anonymous namespace)::ImpTimedRefDev::~ImpTimedRefDev() (/drawinglayer/source/primitive2d/textlayoutdevice.cxx:84) > std::default_delete<(anonymous namespace)::ImpTimedRefDev>::operator()((anonymous namespace)::ImpTimedRefDev*) const (/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/unique_ptr.h:76) > std::unique_ptr<(anonymous namespace)::ImpTimedRefDev, std::default_delete<(anonymous namespace)::ImpTimedRefDev> >::reset((anonymous namespace)::ImpTimedRefDev*) (/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/unique_ptr.h:344) > comphelper::unique_disposing_ptr<(anonymous namespace)::ImpTimedRefDev>::reset((anonymous namespace)::ImpTimedRefDev*) (/include/comphelper/unique_disposing_ptr.hxx:41) > (anonymous namespace)::ImpTimedRefDev::Invoke() (/drawinglayer/source/primitive2d/textlayoutdevice.cxx:93) > Scheduler::ImplInvoke(unsigned long) (/vcl/source/app/scheduler.cxx:39) > Scheduler::ProcessTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:128) > Scheduler::CallbackTaskScheduling(bool) (/vcl/source/app/scheduler.cxx:112) > SalTimer::CallCallback(bool) (/vcl/inc/saltimer.hxx:53) > SvpSalInstance::CheckTimeout(bool) (/vcl/headless/svpinst.cxx:191) > SvpSalInstance::Yield(bool, bool) (/vcl/headless/svpinst.cxx:307) > ImplYield(bool, bool) (/vcl/source/app/svapp.cxx:353) > Application::Reschedule(bool) (/vcl/source/app/svapp.cxx:377) > framework::StatusIndicatorFactory::impl_reschedule(bool) (/framework/source/helper/statusindicatorfactory.cxx:528) > framework::StatusIndicatorFactory::end(com::sun:⭐:uno::Reference<com::sun:⭐:task::XStatusIndicator> const&) (/framework/source/helper/statusindicatorfactory.cxx:229) > framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:70) > non-virtual thunk to framework::StatusIndicator::end() (/framework/source/helper/statusindicator.cxx:57) > writerfilter::ooxml::OOXMLDocumentImpl::resolve(writerfilter::Stream&) (/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx:531) > WriterFilter::filter(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:191) > non-virtual thunk to WriterFilter::filter(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/writerfilter/source/filter/WriterFilter.cxx:126) > SfxObjectShell::ImportFrom(SfxMedium&, com::sun:⭐:uno::Reference<com::sun:⭐:text::XTextRange> const&) (/sfx2/source/doc/objstor.cxx:2271) > SfxObjectShell::DoLoad(SfxMedium*) (/sfx2/source/doc/objstor.cxx:767) > SfxBaseModel::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1859) > non-virtual thunk to SfxBaseModel::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/sfx2/source/doc/sfxbasemodel.cxx:1810) > (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&, com::sun:⭐:uno::Reference<com::sun:⭐:frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:703) > non-virtual thunk to (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&, com::sun:⭐:uno::Reference<com::sun:⭐:frame::XFrame> const&) (/sfx2/source/view/frmload.cxx:615) > framework::LoadEnv::impl_loadContent() (/framework/source/loadenv/loadenv.cxx:1122) > framework::LoadEnv::startLoading() (/framework/source/loadenv/loadenv.cxx:383) > framework::LoadEnv::loadComponentFromURL(com::sun:⭐:uno::Reference<com::sun:⭐:frame::XComponentLoader> const&, com::sun:⭐:uno::Reference<com::sun:⭐:uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/framework/source/loadenv/loadenv.cxx:164) > framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/framework/source/services/desktop.cxx:566) > non-virtual thunk to framework::Desktop::loadComponentFromURL(rtl::OUString const&, rtl::OUString const&, int, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/framework/source/services/desktop.cxx:552) > unotest::MacrosTest::loadFromDesktop(rtl::OUString const&, rtl::OUString const&, com::sun:⭐:uno::Sequence<com::sun:⭐🫘:PropertyValue> const&) (/unotest/source/cpp/macros_test.cxx:50) > SwModelTestBase::load(char const*, char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:580) > SwModelTestBase::executeImportExportImportTest(char const*) (/sw/qa/extras/inc/swmodeltestbase.hxx:219) > testTrackChangesDeletedParagraphMark::Import_Export_Import() (/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx:132) > CppUnit::TestCaller<testTrackChangesDeletedParagraphMark>::runTest() (/workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166) > CppUnit::TestCaseMethodFunctor::operator()() const (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32) > (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/test/source/vclbootstrapprotector.cxx:57) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (in /home/sbergman/lo/core/workdir/LinkTarget/Library/unobootstrapprotector.so) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15) > CppUnit::ProtectorChain::ProtectFunctor::operator()() const (in /home/sbergman/lo/core/workdir/UnpackedTarball/cppunit/src/cppunit/.libs/libcppunit-1.13.so.0.0.2) > CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77) > CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::string const&) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181) > CppUnit::TestCase::run(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91) > CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) (/workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64)
260 lines
7.5 KiB
C++
260 lines
7.5 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#include <svdata.hxx>
|
|
#include <tools/time.hxx>
|
|
#include <vcl/scheduler.hxx>
|
|
#include <vcl/timer.hxx>
|
|
#include <saltimer.hxx>
|
|
|
|
#define MAX_TIMER_PERIOD SAL_MAX_UINT64
|
|
|
|
void ImplSchedulerData::Invoke()
|
|
{
|
|
if (mbDelete || mbInScheduler )
|
|
return;
|
|
|
|
// prepare Scheduler Object for deletion after handling
|
|
mpScheduler->SetDeletionFlags();
|
|
|
|
// invoke it
|
|
mbInScheduler = true;
|
|
mpScheduler->Invoke();
|
|
mbInScheduler = false;
|
|
}
|
|
|
|
ImplSchedulerData *ImplSchedulerData::GetMostImportantTask( bool bTimer )
|
|
{
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
ImplSchedulerData *pMostUrgent = NULL;
|
|
|
|
for ( ImplSchedulerData *pSchedulerData = pSVData->mpFirstSchedulerData; pSchedulerData; pSchedulerData = pSchedulerData->mpNext )
|
|
{
|
|
if ( !pSchedulerData->mpScheduler || pSchedulerData->mbDelete || pSchedulerData->mnUpdateStack >= pSVData->mnUpdateStack
|
|
|| !pSchedulerData->mpScheduler->ReadyForSchedule( bTimer ) || !pSchedulerData->mpScheduler->IsActive())
|
|
continue;
|
|
if (!pMostUrgent)
|
|
pMostUrgent = pSchedulerData;
|
|
else
|
|
{
|
|
// Find the highest priority.
|
|
// If the priority of the current task is higher (numerical value is lower) than
|
|
// the priority of the most urgent, the current task gets the new most urgent.
|
|
if ( pSchedulerData->mpScheduler->GetPriority() < pMostUrgent->mpScheduler->GetPriority() )
|
|
pMostUrgent = pSchedulerData;
|
|
}
|
|
}
|
|
|
|
return pMostUrgent;
|
|
}
|
|
|
|
void Scheduler::SetDeletionFlags()
|
|
{
|
|
mpSchedulerData->mbDelete = true;
|
|
mbActive = false;
|
|
}
|
|
|
|
void Scheduler::ImplDeInitScheduler()
|
|
{
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
ImplSchedulerData* pSchedulerData = pSVData->mpFirstSchedulerData;
|
|
if (pSVData->mpSalTimer)
|
|
{
|
|
pSVData->mpSalTimer->Stop();
|
|
}
|
|
|
|
if ( pSchedulerData )
|
|
{
|
|
do
|
|
{
|
|
ImplSchedulerData* pTempSchedulerData = pSchedulerData;
|
|
if ( pSchedulerData->mpScheduler )
|
|
{
|
|
pSchedulerData->mpScheduler->mbActive = false;
|
|
pSchedulerData->mpScheduler->mpSchedulerData = NULL;
|
|
}
|
|
pSchedulerData = pSchedulerData->mpNext;
|
|
delete pTempSchedulerData;
|
|
}
|
|
while ( pSchedulerData );
|
|
|
|
pSVData->mpFirstSchedulerData = NULL;
|
|
pSVData->mnTimerPeriod = 0;
|
|
}
|
|
|
|
delete pSVData->mpSalTimer;
|
|
pSVData->mpSalTimer = 0;
|
|
}
|
|
|
|
void Scheduler::CallbackTaskScheduling(bool ignore)
|
|
{
|
|
// this function is for the saltimer callback
|
|
(void)ignore;
|
|
Scheduler::ProcessTaskScheduling( true );
|
|
}
|
|
|
|
void Scheduler::ProcessTaskScheduling( bool bTimer )
|
|
{
|
|
// process all pending Tasks
|
|
// if bTimer True, only handle timer
|
|
ImplSchedulerData* pSchedulerData = NULL;
|
|
ImplSchedulerData* pPrevSchedulerData = NULL;
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
sal_uInt64 nTime = tools::Time::GetSystemTicks();
|
|
sal_uInt64 nMinPeriod = MAX_TIMER_PERIOD;
|
|
pSVData->mnUpdateStack++;
|
|
|
|
// tdf#91727 - NB. bTimer is ultimately not used
|
|
if ((pSchedulerData = ImplSchedulerData::GetMostImportantTask(bTimer)))
|
|
{
|
|
pSchedulerData->mnUpdateTime = nTime;
|
|
pSchedulerData->Invoke();
|
|
}
|
|
|
|
pSchedulerData = pSVData->mpFirstSchedulerData;
|
|
while ( pSchedulerData )
|
|
{
|
|
if( pSchedulerData->mbInScheduler )
|
|
{
|
|
pPrevSchedulerData = pSchedulerData;
|
|
pSchedulerData = pSchedulerData->mpNext;
|
|
}
|
|
// Should Task be released from scheduling?
|
|
else if ( pSchedulerData->mbDelete )
|
|
{
|
|
if ( pPrevSchedulerData )
|
|
pPrevSchedulerData->mpNext = pSchedulerData->mpNext;
|
|
else
|
|
pSVData->mpFirstSchedulerData = pSchedulerData->mpNext;
|
|
if ( pSchedulerData->mpScheduler )
|
|
pSchedulerData->mpScheduler->mpSchedulerData = NULL;
|
|
ImplSchedulerData* pTempSchedulerData = pSchedulerData;
|
|
pSchedulerData = pSchedulerData->mpNext;
|
|
delete pTempSchedulerData;
|
|
}
|
|
else
|
|
{
|
|
pSchedulerData->mnUpdateStack = 0;
|
|
nMinPeriod = pSchedulerData->mpScheduler->UpdateMinPeriod( nMinPeriod, nTime );
|
|
pPrevSchedulerData = pSchedulerData;
|
|
pSchedulerData = pSchedulerData->mpNext;
|
|
}
|
|
}
|
|
|
|
// delete clock if no more timers available
|
|
if ( !pSVData->mpFirstSchedulerData )
|
|
{
|
|
if ( pSVData->mpSalTimer )
|
|
pSVData->mpSalTimer->Stop();
|
|
pSVData->mnTimerPeriod = MAX_TIMER_PERIOD;
|
|
}
|
|
else
|
|
{
|
|
Timer::ImplStartTimer( pSVData, nMinPeriod );
|
|
}
|
|
pSVData->mnUpdateStack--;
|
|
}
|
|
|
|
void Scheduler::SetPriority( SchedulerPriority ePriority )
|
|
{
|
|
mePriority = ePriority;
|
|
}
|
|
|
|
void Scheduler::Start()
|
|
{
|
|
// Mark timer active
|
|
mbActive = true;
|
|
|
|
ImplSVData* pSVData = ImplGetSVData();
|
|
if ( !mpSchedulerData )
|
|
{
|
|
// insert Scheduler
|
|
mpSchedulerData = new ImplSchedulerData;
|
|
mpSchedulerData->mpScheduler = this;
|
|
mpSchedulerData->mbInScheduler = false;
|
|
|
|
// insert last due to SFX!
|
|
ImplSchedulerData* pPrev = NULL;
|
|
ImplSchedulerData* pData = pSVData->mpFirstSchedulerData;
|
|
while ( pData )
|
|
{
|
|
pPrev = pData;
|
|
pData = pData->mpNext;
|
|
}
|
|
mpSchedulerData->mpNext = NULL;
|
|
if ( pPrev )
|
|
pPrev->mpNext = mpSchedulerData;
|
|
else
|
|
pSVData->mpFirstSchedulerData = mpSchedulerData;
|
|
}
|
|
mpSchedulerData->mbDelete = false;
|
|
mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
|
|
mpSchedulerData->mnUpdateStack = pSVData->mnUpdateStack;
|
|
}
|
|
|
|
void Scheduler::Stop()
|
|
{
|
|
mbActive = false;
|
|
|
|
if ( mpSchedulerData )
|
|
mpSchedulerData->mbDelete = true;
|
|
}
|
|
|
|
Scheduler& Scheduler::operator=( const Scheduler& rScheduler )
|
|
{
|
|
if ( IsActive() )
|
|
Stop();
|
|
|
|
mbActive = false;
|
|
mePriority = rScheduler.mePriority;
|
|
|
|
if ( rScheduler.IsActive() )
|
|
Start();
|
|
|
|
return *this;
|
|
}
|
|
|
|
Scheduler::Scheduler(const sal_Char *pDebugName):
|
|
mpSchedulerData(NULL),
|
|
mpDebugName(pDebugName),
|
|
mePriority(SchedulerPriority::HIGH),
|
|
mbActive(false)
|
|
{
|
|
}
|
|
|
|
Scheduler::Scheduler( const Scheduler& rScheduler ):
|
|
mpSchedulerData(NULL),
|
|
mpDebugName(rScheduler.mpDebugName),
|
|
mePriority(rScheduler.mePriority),
|
|
mbActive(false)
|
|
{
|
|
if ( rScheduler.IsActive() )
|
|
Start();
|
|
}
|
|
|
|
Scheduler::~Scheduler()
|
|
{
|
|
if ( mpSchedulerData )
|
|
{
|
|
mpSchedulerData->mbDelete = true;
|
|
mpSchedulerData->mpScheduler = NULL;
|
|
}
|
|
}
|
|
|