diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-10-20 12:19:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-10-20 21:18:31 +0100 |
commit | b6b8ef2508335604f56325f696f1c1791d892305 (patch) | |
tree | 2ae345514b93605670267b84ed22d1f483456801 /vcl | |
parent | e9fc41292be2e2f9a29fbb6092e182f6bee9639d (diff) |
afl-eventtesting: shutdown cleaner to allow things to deregister
Change-Id: I2dc7c90f1f5a776bb0e6772d2b381116d28dd46f
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/svdata.hxx | 1 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 48 |
2 files changed, 36 insertions, 13 deletions
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 48749ea71233..10fda4952fc4 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -162,6 +162,7 @@ struct ImplSVAppData int mnEventTestLimit; DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplQuitMsg, void*, void); + DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplPrepareExitMsg, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplEndAllDialogsMsg, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplEndAllPopupsMsg, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplVclEventTestingHdl, void*, void); diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 7a474de52303..81ab92a34c0d 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -65,7 +65,9 @@ #include "com/sun/star/uno/Reference.h" #include "com/sun/star/awt/XToolkit.hpp" +#include <com/sun/star/frame/Desktop.hpp> #include "com/sun/star/uno/XNamingService.hpp" +#include <com/sun/star/util/XModifiable.hpp> #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "comphelper/solarmutex.hxx" #include "osl/process.h" @@ -359,7 +361,7 @@ void Application::EndAllPopups() namespace { - bool InjectKeyEvent(SvStream& rStream) + VclPtr<vcl::Window> GetEventWindow() { VclPtr<vcl::Window> xWin(Application::GetFirstTopLevelWindow()); while (xWin) @@ -368,6 +370,12 @@ namespace break; xWin.reset(Application::GetNextTopLevelWindow(xWin)); } + return xWin; + } + + bool InjectKeyEvent(SvStream& rStream) + { + VclPtr<vcl::Window> xWin(GetEventWindow()); if (!xWin) return false; @@ -398,6 +406,7 @@ namespace { Application::EndAllPopups(); Application::EndAllDialogs(); + Application::PostUserEvent( LINK( NULL, ImplSVAppData, ImplPrepareExitMsg ) ); Application::Quit(); } } @@ -437,25 +446,26 @@ IMPL_STATIC_LINK_NOARG_TYPED( ImplSVAppData, ImplVclEventTestingHdl, void*, void } } +IMPL_STATIC_LINK_NOARG_TYPED( ImplSVAppData, ImplPrepareExitMsg, void*, void ) +{ + //now close top level frames + (void)GetpApp()->QueryExit(); +} + void Application::Execute() { ImplSVData* pSVData = ImplGetSVData(); pSVData->maAppData.mbInAppExecute = true; pSVData->maAppData.mbAppQuit = false; - sal_uInt16 n = GetCommandLineParamCount(); - for (sal_uInt16 i = 0; i != n; ++i) + if (Application::IsEventTestingModeEnabled()) { - if (GetCommandLineParam(i) == "--eventtesting") - { - pSVData->maAppData.mnEventTestLimit = 50; - pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting"); - pSVData->maAppData.mpEventTestingIdle->SetIdleHdl(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl)); - pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::MEDIUM); - pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ); - pSVData->maAppData.mpEventTestingIdle->Start(); - break; - } + pSVData->maAppData.mnEventTestLimit = 50; + pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting"); + pSVData->maAppData.mpEventTestingIdle->SetIdleHdl(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl)); + pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::MEDIUM); + pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ); + pSVData->maAppData.mpEventTestingIdle->Start(); } while ( !pSVData->maAppData.mbAppQuit ) @@ -1655,6 +1665,18 @@ void Application::EnableConsoleOnly() bConsoleOnly = true; } +static bool bEventTestingMode = false; + +bool Application::IsEventTestingModeEnabled() +{ + return bEventTestingMode; +} + +void Application::EnableEventTestingMode() +{ + bEventTestingMode = true; +} + void Application::ShowNativeErrorBox(const OUString& sTitle , const OUString& sMessage) { |