1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
From fc1bf70b9c42187a3d5300e5fd6122e065fcb6c6 Mon Sep 17 00:00:00 2001
From: Noel Grandin <noel.grandin@collabora.co.uk>
Date: Mon, 8 Jun 2020 16:13:58 +0200
Subject: [PATCH] WIP postuserevent
Change-Id: I25e15d1dd8b37d6aa0d219d94a78739d6106737d
---
include/vcl/svapp.hxx | 23 +++++++++++++++++--
svtools/source/hatchwindow/documentcloser.cxx | 2 +-
.../source/uno/generictoolboxcontroller.cxx | 2 +-
.../source/uno/popupmenucontrollerbase.cxx | 2 +-
.../core/docnode/retrievedinputstreamdata.cxx | 4 +---
sw/source/ui/dbui/mmoutputtypepage.cxx | 23 +++++++++----------
sw/source/ui/inc/mmresultdialogs.hxx | 6 +++--
vcl/qt5/Qt5Menu.cxx | 2 +-
vcl/source/app/svapp.cxx | 12 +++++-----
vcl/source/gdi/print3.cxx | 2 +-
vcl/source/window/menubarwindow.cxx | 2 +-
vcl/source/window/winproc.cxx | 4 ++--
vcl/unx/generic/app/sm.cxx | 8 +++----
vcl/unx/gtk3/fpicker/SalGtkPicker.cxx | 2 +-
vcl/unx/gtk3/gtk3gtkinst.cxx | 2 +-
vcl/unx/gtk3/gtk3gtksalmenu.cxx | 2 +-
16 files changed, 58 insertions(+), 40 deletions(-)
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 48a764b80125..8ea95b97deb9 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -772,8 +772,10 @@ public:
@param bReferenceLink If true - hold a VclPtr<> reference on the Link's instance.
Taking the reference is guarded by a SolarMutexGuard.
- @return the event ID used to post the event.
+ @return the event ID used to post the event. This event id MUST be saved, and destroyed
+ via RemoveUserEvent if the owning class dies before the event is processed.
*/
+ [[nodiscard]]
static ImplSVEvent * PostUserEvent( const Link<void*,void>& rLink, void* pCaller = nullptr,
bool bReferenceLink = false );
@@ -1453,9 +1455,26 @@ VCL_DLLPUBLIC void SetSVWinData(ImplSVWinData*);
inline void Application::EndYield()
{
- PostUserEvent( Link<void*,void>() );
+ (void) PostUserEvent( Link<void*,void>() );
}
+/**
+ Declare an instance of this per user-event you need to post via Application::PostEvent,
+ and assign the result of that function to this, and this will remove
+ that event if your class dies before the event is processed.
+*/
+class UserEventCleaner
+{
+ ImplSVEvent* mpEvent;
+public:
+ void operator=(ImplSVEvent* p) { mpEvent = p; }
+ ~UserEventCleaner()
+ {
+ if (mpEvent)
+ Application::RemoveUserEvent(mpEvent);
+ }
+};
+
#endif // _APP_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx
index 6e014dd7ea46..b8fbc5dc6e14 100644
--- a/svtools/source/hatchwindow/documentcloser.cxx
+++ b/svtools/source/hatchwindow/documentcloser.cxx
@@ -89,7 +89,7 @@ void MainThreadFrameCloserRequest::Start( MainThreadFrameCloserRequest* pMTReque
worker( nullptr, pMTRequest );
}
else
- Application::PostUserEvent( LINK( nullptr, MainThreadFrameCloserRequest, worker ), pMTRequest );
+ (void) Application::PostUserEvent( LINK( nullptr, MainThreadFrameCloserRequest, worker ), pMTRequest );
}
}
diff --git a/svtools/source/uno/generictoolboxcontroller.cxx b/svtools/source/uno/generictoolboxcontroller.cxx
index 570805632b53..7423e6aa3f17 100644
--- a/svtools/source/uno/generictoolboxcontroller.cxx
+++ b/svtools/source/uno/generictoolboxcontroller.cxx
@@ -135,7 +135,7 @@ void SAL_CALL GenericToolboxController::execute( sal_Int16 /*KeyModifier*/ )
pExecuteInfo->xDispatch = xDispatch;
pExecuteInfo->aTargetURL = aTargetURL;
pExecuteInfo->aArgs = aArgs;
- Application::PostUserEvent( LINK(nullptr, GenericToolboxController , ExecuteHdl_Impl), pExecuteInfo );
+ (void) Application::PostUserEvent( LINK(nullptr, GenericToolboxController , ExecuteHdl_Impl), pExecuteInfo );
}
void GenericToolboxController::statusChanged( const FeatureStateEvent& Event )
diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx
index 9ce0bda33a63..56ab79194b67 100644
--- a/svtools/source/uno/popupmenucontrollerbase.cxx
+++ b/svtools/source/uno/popupmenucontrollerbase.cxx
@@ -141,7 +141,7 @@ void PopupMenuControllerBase::dispatchCommand( const OUString& sCommandURL,
Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( aURL, sTarget, 0 ), UNO_SET_THROW );
- Application::PostUserEvent( LINK(nullptr, PopupMenuControllerBase, ExecuteHdl_Impl), new PopupMenuControllerBaseDispatchInfo( xDispatch, aURL, rArgs ) );
+ (void) Application::PostUserEvent( LINK(nullptr, PopupMenuControllerBase, ExecuteHdl_Impl), new PopupMenuControllerBaseDispatchInfo( xDispatch, aURL, rArgs ) );
}
catch( Exception& )
diff --git a/sw/source/core/docnode/retrievedinputstreamdata.cxx b/sw/source/core/docnode/retrievedinputstreamdata.cxx
index b41125698981..b92b2574af34 100644
--- a/sw/source/core/docnode/retrievedinputstreamdata.cxx
+++ b/sw/source/core/docnode/retrievedinputstreamdata.cxx
@@ -134,10 +134,8 @@ IMPL_LINK( SwRetrievedInputStreamDataManager,
osl::MutexGuard aGuard(maMutex);
- SwRetrievedInputStreamDataManager& rDataManager =
- SwRetrievedInputStreamDataManager::GetManager();
SwRetrievedInputStreamDataManager::tData aInputStreamData;
- if ( rDataManager.PopData( *pDataKey, aInputStreamData ) )
+ if ( PopData( *pDataKey, aInputStreamData ) )
{
std::shared_ptr< SwAsyncRetrieveInputStreamThreadConsumer > pThreadConsumer =
aInputStreamData.mpThreadConsumer.lock();
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx b/sw/source/ui/dbui/mmoutputtypepage.cxx
index f7153c3bc503..7f9b4c144bed 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -309,9 +309,9 @@ IMPL_LINK_NOARG(SwSendMailDialog, CloseHdl_Impl, weld::Button&, void)
}
}
-IMPL_STATIC_LINK( SwSendMailDialog, StartSendMails, void*, pDialog, void )
+IMPL_LINK( SwSendMailDialog, StartSendMails, void*, /*pDialog*/, void )
{
- static_cast<SwSendMailDialog*>(pDialog)->SendMails();
+ SendMails();
}
IMPL_LINK( SwSendMailDialog, RemoveThis, Timer*, pTimer, void )
@@ -336,15 +336,14 @@ IMPL_LINK( SwSendMailDialog, RemoveThis, Timer*, pTimer, void )
}
}
-IMPL_STATIC_LINK( SwSendMailDialog, StopSendMails, void*, p, void )
+IMPL_LINK( SwSendMailDialog, StopSendMails, void*, /*p*/, void )
{
- SwSendMailDialog* pDialog = static_cast<SwSendMailDialog*>(p);
- if(pDialog->m_pImpl->xMailDispatcher.is() &&
- pDialog->m_pImpl->xMailDispatcher->isStarted())
+ if(m_pImpl->xMailDispatcher.is() &&
+ m_pImpl->xMailDispatcher->isStarted())
{
- pDialog->m_pImpl->xMailDispatcher->stop();
- pDialog->m_xStop->set_label(pDialog->m_sContinue);
- pDialog->m_xPaused->show();
+ m_pImpl->xMailDispatcher->stop();
+ m_xStop->set_label(m_sContinue);
+ m_xPaused->show();
}
}
@@ -452,7 +451,7 @@ void SwSendMailDialog::IterateMails()
void SwSendMailDialog::StartSend(sal_Int32 nExpectedCount)
{
- Application::PostUserEvent( LINK( this, SwSendMailDialog,
+ m_StartSendUserEvent = Application::PostUserEvent( LINK( this, SwSendMailDialog,
StartSendMails ), this );
m_nExpectedCount = nExpectedCount > 0 ? nExpectedCount : 1;
}
@@ -465,8 +464,8 @@ void SwSendMailDialog::DocumentSent( uno::Reference< mail::XMailMessage> const &
if(pError &&
m_pImpl->xMailDispatcher.is() && m_pImpl->xMailDispatcher->isStarted())
{
- Application::PostUserEvent( LINK( this, SwSendMailDialog,
- StopSendMails ), this );
+ m_StopSendUserEvent = Application::PostUserEvent( LINK( this, SwSendMailDialog,
+ StopSendMails ), this );
}
OUString sInsertImg(bResult ? OUString(RID_BMP_FORMULA_APPLY) : OUString(RID_BMP_FORMULA_CANCEL));
diff --git a/sw/source/ui/inc/mmresultdialogs.hxx b/sw/source/ui/inc/mmresultdialogs.hxx
index 4db8e0e766f4..402c1324cbaf 100644
--- a/sw/source/ui/inc/mmresultdialogs.hxx
+++ b/sw/source/ui/inc/mmresultdialogs.hxx
@@ -150,6 +150,8 @@ class SwSendMailDialog : public weld::GenericDialogController
sal_Int32 m_nExpectedCount;
sal_Int32 m_nSendCount;
sal_Int32 m_nErrorCount;
+ UserEventCleaner m_StartSendUserEvent;
+ UserEventCleaner m_StopSendUserEvent;
std::unique_ptr<weld::Label> m_xTransferStatus;
std::unique_ptr<weld::Label> m_xPaused;
@@ -162,8 +164,8 @@ class SwSendMailDialog : public weld::GenericDialogController
DECL_LINK( StopHdl_Impl, weld::Button&, void );
DECL_LINK( CloseHdl_Impl, weld::Button& , void);
- DECL_STATIC_LINK( SwSendMailDialog, StartSendMails, void*, void );
- DECL_STATIC_LINK( SwSendMailDialog, StopSendMails, void*, void );
+ DECL_LINK( StartSendMails, void*, void );
+ DECL_LINK( StopSendMails, void*, void );
DECL_LINK( RemoveThis, Timer*, void );
void IterateMails();
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 98615247035a..c875ca5154a5 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -634,7 +634,7 @@ void Qt5Menu::slotCloseDocument()
{
MenuBar* pVclMenuBar = static_cast<MenuBar*>(mpVCLMenu.get());
if (pVclMenuBar)
- Application::PostUserEvent(pVclMenuBar->GetCloseButtonClickHdl());
+ (void)Application::PostUserEvent(pVclMenuBar->GetCloseButtonClickHdl());
}
void Qt5Menu::ShowCloseButton(bool bShow)
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index ea01d31c0829..3d4f9ac2794e 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -313,12 +313,12 @@ IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllDialogsMsg, void*, void )
void Application::EndAllDialogs()
{
- Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllDialogsMsg ) );
+ (void) Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllDialogsMsg ) );
}
void Application::EndAllPopups()
{
- Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllPopupsMsg ) );
+ (void) Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllPopupsMsg ) );
}
@@ -369,7 +369,7 @@ namespace
{
Application::EndAllPopups();
Application::EndAllDialogs();
- Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplPrepareExitMsg ) );
+ (void) Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplPrepareExitMsg ) );
}
}
@@ -381,7 +381,7 @@ IMPL_LINK_NOARG(ImplSVAppData, VclEventTestingHdl, Timer *, void)
}
else
{
- Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
+ (void) Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
}
}
@@ -404,7 +404,7 @@ IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplVclEventTestingHdl, void*, void )
SAL_INFO("vcl.eventtesting", "Event Input exhausted, exit next cycle");
pSVData->maAppData.mnEventTestLimit = 0;
}
- Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
+ (void) Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplVclEventTestingHdl ) );
}
}
@@ -527,7 +527,7 @@ IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplQuitMsg, void*, void )
void Application::Quit()
{
ImplGetSVData()->maAppData.mbAppQuit = true;
- Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplQuitMsg ) );
+ (void) Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplQuitMsg ) );
}
comphelper::SolarMutex& Application::GetSolarMutex()
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index cb326ae9d31a..1bbee35c6961 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -313,7 +313,7 @@ void Printer::PrintJob(const std::shared_ptr<PrinterController>& i_xController,
else
{
PrintJobAsync* pAsync = new PrintJobAsync(i_xController, i_rInitSetup);
- Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) );
+ (void) Application::PostUserEvent( LINK( pAsync, PrintJobAsync, ExecJob ) );
}
}
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 41a51b79ce5b..cead833427fb 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -226,7 +226,7 @@ IMPL_LINK_NOARG(MenuBarWindow, CloseHdl, ToolBox *, void)
// #i106052# call close hdl asynchronously to ease handler implementation
// this avoids still being in the handler while the DecoToolBox already
// gets destroyed
- Application::PostUserEvent(static_cast<MenuBar*>(m_pMenu.get())->GetCloseButtonClickHdl());
+ (void) Application::PostUserEvent(static_cast<MenuBar*>(m_pMenu.get())->GetCloseButtonClickHdl());
}
else
{
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 57bba25eb16b..300bd12e3432 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -787,7 +787,7 @@ bool ImplHandleMouseEvent( const VclPtr<vcl::Window>& xWindow, MouseNotifyEvent
ContextMenuEvent* pEv = new ContextMenuEvent;
pEv->pWindow = pChild;
pEv->aChildPos = aChildPos;
- Application::PostUserEvent( Link<void*,void>( pEv, ContextMenuEventLink ) );
+ (void) Application::PostUserEvent( Link<void*,void>( pEv, ContextMenuEventLink ) );
}
else
bRet = ! ImplCallCommand( pChild, CommandEventId::ContextMenu, nullptr, true, &aChildPos );
@@ -1986,7 +1986,7 @@ static void ImplHandleClose( const vcl::Window* pWindow )
{
DelayedCloseEvent* pEv = new DelayedCloseEvent;
pEv->pWindow = pWin;
- Application::PostUserEvent( Link<void*,void>( pEv, DelayedCloseEventLink ) );
+ (void) Application::PostUserEvent( Link<void*,void>( pEv, DelayedCloseEventLink ) );
}
}
diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx
index 30ff437a263a..9a1f02fc7bac 100644
--- a/vcl/unx/generic/app/sm.cxx
+++ b/vcl/unx/generic/app/sm.cxx
@@ -383,7 +383,7 @@ void SessionManagerClient::SaveYourselfProc(
}
// Smuggle argument in as void*:
sal_uIntPtr nStateVal = shutdown;
- Application::PostUserEvent( LINK( nullptr, SessionManagerClient, SaveYourselfHdl ), reinterpret_cast< void * >(nStateVal) );
+ (void) Application::PostUserEvent( LINK( nullptr, SessionManagerClient, SaveYourselfHdl ), reinterpret_cast< void * >(nStateVal) );
}
IMPL_STATIC_LINK_NOARG( SessionManagerClient, ShutDownHdl, void*, void )
@@ -412,7 +412,7 @@ void SessionManagerClient::DieProc(
if( connection == m_pSmcConnection )
{
SAL_INFO("vcl.sm.debug", " connection == m_pSmcConnection" );
- Application::PostUserEvent( LINK( nullptr, SessionManagerClient, ShutDownHdl ) );
+ (void) Application::PostUserEvent( LINK( nullptr, SessionManagerClient, ShutDownHdl ) );
}
}
@@ -432,7 +432,7 @@ void SessionManagerClient::ShutdownCanceledProc(
SAL_INFO("vcl.sm.debug", " connection == m_pSmcConnection = " << (( connection == m_pSmcConnection ) ? "true" : "false"));
if( connection == m_pSmcConnection )
- Application::PostUserEvent( LINK( nullptr, SessionManagerClient, ShutDownCancelHdl ) );
+ (void) Application::PostUserEvent( LINK( nullptr, SessionManagerClient, ShutDownCancelHdl ) );
}
void SessionManagerClient::InteractProc(
@@ -443,7 +443,7 @@ void SessionManagerClient::InteractProc(
SAL_INFO("vcl.sm.debug", " connection == m_pSmcConnection = " << (( connection == m_pSmcConnection ) ? "true" : "false"));
if( connection == m_pSmcConnection )
- Application::PostUserEvent( LINK( nullptr, SessionManagerClient, InteractionHdl ) );
+ (void) Application::PostUserEvent( LINK( nullptr, SessionManagerClient, InteractionHdl ) );
}
void SessionManagerClient::saveDone()
diff --git a/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx
index c847774d13d3..2b54c74d1fea 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx
@@ -196,7 +196,7 @@ gint RunDialog::run()
if (mbTerminateDesktop)
{
ExecuteInfo* pExecuteInfo = new ExecuteInfo(mxDesktop);
- Application::PostUserEvent(LINK(nullptr, RunDialog, TerminateDesktop), pExecuteInfo);
+ (void) Application::PostUserEvent(LINK(nullptr, RunDialog, TerminateDesktop), pExecuteInfo);
}
return nStatus;
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index fe4d84a7397d..0dfccdd202c5 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -9459,7 +9459,7 @@ private:
{
GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget);
if (!pThis->signal_cell_editing_started(path))
- Application::PostUserEvent(LINK(pThis, GtkInstanceTreeView, async_stop_cell_editing));
+ (void) Application::PostUserEvent(LINK(pThis, GtkInstanceTreeView, async_stop_cell_editing));
}
bool signal_cell_editing_started(const gchar *path)
diff --git a/vcl/unx/gtk3/gtk3gtksalmenu.cxx b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
index 13a7ef2d30ac..6fc0644ffbbf 100644
--- a/vcl/unx/gtk3/gtk3gtksalmenu.cxx
+++ b/vcl/unx/gtk3/gtk3gtksalmenu.cxx
@@ -636,7 +636,7 @@ void GtkSalMenu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsig
static void CloseMenuBar(GtkWidget *, gpointer pMenu)
{
- Application::PostUserEvent(static_cast<MenuBar*>(pMenu)->GetCloseButtonClickHdl());
+ (void) Application::PostUserEvent(static_cast<MenuBar*>(pMenu)->GetCloseButtonClickHdl());
}
void GtkSalMenu::ShowCloseButton(bool bShow)
--
2.26.2
|