1 |
From 5613954b275de8de9e6852738a7bfd215252d134 Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Tue, 7 Jun 2011 17:03:52 +0100 |
4 |
Subject: [PATCH] Related: rhbz#652604 better survive exceptions thrown during |
5 |
autorecover |
6 |
|
7 |
--- |
8 |
framework/inc/services/autorecovery.hxx | 20 ++++++++++++++ |
9 |
framework/source/services/autorecovery.cxx | 40 +++++++++++++++++++++------ |
10 |
2 files changed, 51 insertions(+), 9 deletions(-) |
11 |
|
12 |
diff --git a/framework/inc/services/autorecovery.hxx b/framework/inc/services/autorecovery.hxx |
13 |
index 636ad98..6c4207e 100644 |
14 |
--- a/framework/inc/services/autorecovery.hxx |
15 |
+++ b/framework/inc/services/autorecovery.hxx |
16 |
@@ -861,6 +861,26 @@ class AutoRecovery : public css::lang::XTypeProvider |
17 |
const ::rtl::OUString& sEventType, |
18 |
AutoRecovery::TDocumentInfo* pInfo ); |
19 |
|
20 |
+ |
21 |
+ class ListenerInformer |
22 |
+ { |
23 |
+ private: |
24 |
+ AutoRecovery &m_rRecovery; |
25 |
+ sal_Int32 m_eJob; |
26 |
+ bool m_bStopped; |
27 |
+ public: |
28 |
+ ListenerInformer(AutoRecovery &rRecovery, sal_Int32 eJob) |
29 |
+ : m_rRecovery(rRecovery), m_eJob(eJob), m_bStopped(false) |
30 |
+ { |
31 |
+ } |
32 |
+ void start(); |
33 |
+ void stop(); |
34 |
+ ~ListenerInformer() |
35 |
+ { |
36 |
+ stop(); |
37 |
+ } |
38 |
+ }; |
39 |
+ |
40 |
//--------------------------------------- |
41 |
|
42 |
// TODO document me |
43 |
diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx |
44 |
index efe2f17..ec60d13 100644 |
45 |
--- a/framework/source/services/autorecovery.cxx |
46 |
+++ b/framework/source/services/autorecovery.cxx |
47 |
@@ -576,6 +576,21 @@ void SAL_CALL AutoRecovery::dispatch(const css::util::URL& |
48 |
implts_dispatch(aParams); |
49 |
} |
50 |
|
51 |
+void AutoRecovery::ListenerInformer::start() |
52 |
+{ |
53 |
+ m_rRecovery.implts_informListener(m_eJob, |
54 |
+ AutoRecovery::implst_createFeatureStateEvent(m_eJob, OPERATION_START, NULL)); |
55 |
+} |
56 |
+ |
57 |
+void AutoRecovery::ListenerInformer::stop() |
58 |
+{ |
59 |
+ if (m_bStopped) |
60 |
+ return; |
61 |
+ m_rRecovery.implts_informListener(m_eJob, |
62 |
+ AutoRecovery::implst_createFeatureStateEvent(m_eJob, OPERATION_STOP, NULL)); |
63 |
+ m_bStopped = true; |
64 |
+} |
65 |
+ |
66 |
//----------------------------------------------- |
67 |
void AutoRecovery::implts_dispatch(const DispatchParams& aParams) |
68 |
{ |
69 |
@@ -599,8 +614,8 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams) |
70 |
implts_stopTimer(); |
71 |
implts_stopListening(); |
72 |
|
73 |
- implts_informListener(eJob, |
74 |
- AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_START, NULL)); |
75 |
+ ListenerInformer aListenerInformer(*this, eJob); |
76 |
+ aListenerInformer.start(); |
77 |
|
78 |
try |
79 |
{ |
80 |
@@ -676,13 +691,14 @@ void AutoRecovery::implts_dispatch(const DispatchParams& aParams) |
81 |
) |
82 |
implts_cleanUpWorkingEntry(aParams); |
83 |
} |
84 |
- catch(const css::uno::RuntimeException& exRun) |
85 |
- { throw exRun; } |
86 |
+ catch(const css::uno::RuntimeException&) |
87 |
+ { |
88 |
+ throw; |
89 |
+ } |
90 |
catch(const css::uno::Exception&) |
91 |
{} // TODO better error handling |
92 |
|
93 |
- implts_informListener(eJob, |
94 |
- AutoRecovery::implst_createFeatureStateEvent(eJob, OPERATION_STOP, NULL)); |
95 |
+ aListenerInformer.stop(); |
96 |
|
97 |
// SAFE -> ---------------------------------- |
98 |
aWriteLock.lock(); |
99 |
@@ -1304,8 +1320,8 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn |
100 |
xModify->insertByName(sID, css::uno::makeAny(xSet)); |
101 |
} |
102 |
} |
103 |
- catch(const css::uno::RuntimeException& exRun) |
104 |
- { throw exRun; } |
105 |
+ catch(const css::uno::RuntimeException&) |
106 |
+ { throw; } |
107 |
catch(const css::uno::Exception&) |
108 |
{} // ??? can it happen that a full disc let these set of operations fail too ??? |
109 |
|
110 |
@@ -1627,7 +1643,13 @@ IMPL_LINK(AutoRecovery, implts_asyncDispatch, void*, EMPTYARG) |
111 |
aWriteLock.unlock(); |
112 |
// <- SAFE |
113 |
|
114 |
- implts_dispatch(aParams); |
115 |
+ try |
116 |
+ { |
117 |
+ implts_dispatch(aParams); |
118 |
+ } |
119 |
+ catch (...) |
120 |
+ { |
121 |
+ } |
122 |
return 0; |
123 |
} |
124 |
|
125 |
-- |
126 |
1.7.5.2 |
127 |
|