[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/osx vcl/qt5 vcl/source vcl/unx vcl/win
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 1 05:45:49 UTC 2018
vcl/headless/svpframe.cxx | 4 ++--
vcl/inc/headless/svpframe.hxx | 2 +-
vcl/inc/osx/salframe.h | 2 +-
vcl/inc/qt5/Qt5Frame.hxx | 2 +-
vcl/inc/salframe.hxx | 2 +-
vcl/inc/unx/gtk/gtkframe.hxx | 2 +-
vcl/inc/unx/salframe.h | 2 +-
vcl/inc/win/salframe.h | 2 +-
vcl/osx/salframe.cxx | 4 ++--
vcl/qt5/Qt5Frame.cxx | 4 ++--
vcl/source/app/svapp.cxx | 17 +++++++++--------
vcl/source/window/event.cxx | 12 +++++-------
vcl/unx/generic/window/salframe.cxx | 4 ++--
vcl/unx/gtk/gtksalframe.cxx | 4 ++--
vcl/unx/gtk3/gtk3gtkframe.cxx | 4 ++--
vcl/win/window/salframe.cxx | 4 ++--
16 files changed, 35 insertions(+), 36 deletions(-)
New commits:
commit 478f3f019f780ae6f2464ea7ccd7a52a0ea9361c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Oct 30 10:48:22 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Nov 1 06:45:13 2018 +0100
loplugin:useuniqueptr in SalFrame::PostEvent
Change-Id: Ib066b1d6df90f330f2f93ec639bd7bc59a08c024
Reviewed-on: https://gerrit.libreoffice.org/62507
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 9bf3e9cb84e6..e636b46514ac 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -160,9 +160,9 @@ void SvpSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
delete pSvpGraphics;
}
-bool SvpSalFrame::PostEvent(ImplSVEvent* pData)
+bool SvpSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
- m_pInstance->PostEvent( this, pData, SalEvent::UserEvent );
+ m_pInstance->PostEvent( this, pData.release(), SalEvent::UserEvent );
return true;
}
diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx
index 309a7b5ce523..15d582ee378d 100644
--- a/vcl/inc/headless/svpframe.hxx
+++ b/vcl/inc/headless/svpframe.hxx
@@ -70,7 +70,7 @@ public:
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
- virtual bool PostEvent(ImplSVEvent* pData) override;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
virtual void SetTitle( const OUString& rTitle ) override;
virtual void SetIcon( sal_uInt16 nIcon ) override;
diff --git a/vcl/inc/osx/salframe.h b/vcl/inc/osx/salframe.h
index c2b53e270648..c1a55269b517 100644
--- a/vcl/inc/osx/salframe.h
+++ b/vcl/inc/osx/salframe.h
@@ -114,7 +114,7 @@ public:
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
- virtual bool PostEvent(ImplSVEvent* pData) override;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
virtual void SetTitle( const OUString& rTitle ) override;
virtual void SetIcon( sal_uInt16 nIcon ) override;
virtual void SetRepresentedURL( const OUString& ) override;
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 110fa9b279cf..9d7b15792731 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -123,7 +123,7 @@ public:
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
- virtual bool PostEvent(ImplSVEvent* pData) override;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
virtual void SetTitle(const OUString& rTitle) override;
virtual void SetIcon(sal_uInt16 nIcon) override;
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index f1d4a05e5662..e2662d415fc2 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -128,7 +128,7 @@ public:
// Event must be destroyed, when Frame is destroyed
// When Event is called, SalInstance::Yield() must be returned
- virtual bool PostEvent(ImplSVEvent* pData) = 0;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) = 0;
virtual void SetTitle( const OUString& rTitle ) = 0;
virtual void SetIcon( sal_uInt16 nIcon ) = 0;
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 94547848659e..7b2e78a5414e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -447,7 +447,7 @@ public:
// Event must be destroyed, when Frame is destroyed
// When Event is called, SalInstance::Yield() must be returned
- virtual bool PostEvent(ImplSVEvent* pData) override;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
virtual void SetTitle( const OUString& rTitle ) override;
virtual void SetIcon( sal_uInt16 nIcon ) override;
diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h
index 92bfcbfb9d31..9d8db1aa9e81 100644
--- a/vcl/inc/unx/salframe.h
+++ b/vcl/inc/unx/salframe.h
@@ -209,7 +209,7 @@ public:
// call with false to setup graphics with window (GetWindow())
virtual void updateGraphics( bool bClear );
- virtual bool PostEvent(ImplSVEvent* pData) override;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
virtual void SetTitle( const OUString& rTitle ) override;
virtual void SetIcon( sal_uInt16 nIcon ) override;
diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 48afedf3b715..bc1cec234b9a 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -94,7 +94,7 @@ public:
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
- virtual bool PostEvent(ImplSVEvent* pData) override;
+ virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
virtual void SetTitle( const OUString& rTitle ) override;
virtual void SetIcon( sal_uInt16 nIcon ) override;
virtual void SetMenu( SalMenu* pSalMenu ) override;
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index e0ec4ccb0d5f..23f52dfbbf4f 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -300,9 +300,9 @@ void AquaSalFrame::ReleaseGraphics( SalGraphics *pGraphics )
mbGraphics = FALSE;
}
-bool AquaSalFrame::PostEvent(ImplSVEvent* pData)
+bool AquaSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
- GetSalData()->mpInstance->PostEvent( this, pData, SalEvent::UserEvent );
+ GetSalData()->mpInstance->PostEvent( this, pData.release(), SalEvent::UserEvent );
return TRUE;
}
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 822b8004b6e7..17fb684e3c0e 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -229,10 +229,10 @@ void Qt5Frame::ReleaseGraphics(SalGraphics* pSalGraph)
m_bGraphicsInUse = false;
}
-bool Qt5Frame::PostEvent(ImplSVEvent* pData)
+bool Qt5Frame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
Qt5Instance* pInst = static_cast<Qt5Instance*>(GetSalData()->m_pInstance);
- pInst->PostEvent(this, pData, SalEvent::UserEvent);
+ pInst->PostEvent(this, pData.release(), SalEvent::UserEvent);
return true;
}
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index fb8ec12d28d7..7c1219795d6b 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -948,7 +948,11 @@ void Application::RemoveMouseAndKeyEvents( vcl::Window* pWin )
ImplSVEvent * Application::PostUserEvent( const Link<void*,void>& rLink, void* pCaller,
bool bReferenceLink )
{
- ImplSVEvent* pSVEvent = new ImplSVEvent;
+ vcl::Window* pDefWindow = ImplGetDefaultWindow();
+ if ( pDefWindow == nullptr )
+ return nullptr;
+
+ std::unique_ptr<ImplSVEvent> pSVEvent(new ImplSVEvent);
pSVEvent->mpData = pCaller;
pSVEvent->maLink = rLink;
pSVEvent->mpWindow = nullptr;
@@ -963,13 +967,10 @@ ImplSVEvent * Application::PostUserEvent( const Link<void*,void>& rLink, void* p
pSVEvent->mpInstanceRef = static_cast<vcl::Window *>(rLink.GetInstance());
}
- vcl::Window* pDefWindow = ImplGetDefaultWindow();
- if ( pDefWindow == nullptr || !pDefWindow->ImplGetFrame()->PostEvent( pSVEvent ) )
- {
- delete pSVEvent;
- pSVEvent = nullptr;
- }
- return pSVEvent;
+ auto pTmpEvent = pSVEvent.get();
+ if (!pDefWindow->ImplGetFrame()->PostEvent( std::move(pSVEvent) ))
+ return nullptr;
+ return pTmpEvent;
}
void Application::RemoveUserEvent( ImplSVEvent * nUserEvent )
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
index 81a0558e3321..399dddd3abaa 100644
--- a/vcl/source/window/event.cxx
+++ b/vcl/source/window/event.cxx
@@ -321,7 +321,7 @@ void Window::RemoveChildEventListener( const Link<VclWindowEvent&,void>& rEventL
ImplSVEvent * Window::PostUserEvent( const Link<void*,void>& rLink, void* pCaller, bool bReferenceLink )
{
- ImplSVEvent* pSVEvent = new ImplSVEvent;
+ std::unique_ptr<ImplSVEvent> pSVEvent(new ImplSVEvent);
pSVEvent->mpData = pCaller;
pSVEvent->maLink = rLink;
pSVEvent->mpWindow = this;
@@ -335,12 +335,10 @@ ImplSVEvent * Window::PostUserEvent( const Link<void*,void>& rLink, void* pCalle
pSVEvent->mpInstanceRef = static_cast<vcl::Window *>(rLink.GetInstance());
}
- if ( !mpWindowImpl->mpFrame->PostEvent( pSVEvent ) )
- {
- delete pSVEvent;
- pSVEvent = nullptr;
- }
- return pSVEvent;
+ auto pTmpEvent = pSVEvent.get();
+ if (!mpWindowImpl->mpFrame->PostEvent( std::move(pSVEvent) ))
+ return nullptr;
+ return pTmpEvent;
}
void Window::RemoveUserEvent( ImplSVEvent * nUserEvent )
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 560c7caf4af6..c1f29cf47bc7 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -2309,9 +2309,9 @@ X11SalFrame::HandleExtTextEvent (XClientMessageEvent const *pEvent)
// PostEvent
-bool X11SalFrame::PostEvent(ImplSVEvent* pData)
+bool X11SalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
- GetDisplay()->SendInternalEvent( this, pData );
+ GetDisplay()->SendInternalEvent( this, pData.release() );
return true;
}
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 760744b0a80b..305a1c3048bf 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -1335,9 +1335,9 @@ void GtkSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
m_bGraphics = false;
}
-bool GtkSalFrame::PostEvent(ImplSVEvent* pData)
+bool GtkSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
- getDisplay()->SendInternalEvent( this, pData );
+ getDisplay()->SendInternalEvent( this, pData.release() );
return true;
}
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 37c01fa11a3d..048f15c19207 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -1354,9 +1354,9 @@ void GtkSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
m_bGraphics = false;
}
-bool GtkSalFrame::PostEvent(ImplSVEvent* pData)
+bool GtkSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
- getDisplay()->SendInternalEvent( this, pData );
+ getDisplay()->SendInternalEvent( this, pData.release() );
return true;
}
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index ae703aa235fc..9829896763c7 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -1054,9 +1054,9 @@ void WinSalFrame::ReleaseGraphics( SalGraphics* pGraphics )
mbGraphics = false;
}
-bool WinSalFrame::PostEvent(ImplSVEvent* pData)
+bool WinSalFrame::PostEvent(std::unique_ptr<ImplSVEvent> pData)
{
- BOOL const ret = PostMessageW(mhWnd, SAL_MSG_USEREVENT, 0, reinterpret_cast<LPARAM>(pData));
+ BOOL const ret = PostMessageW(mhWnd, SAL_MSG_USEREVENT, 0, reinterpret_cast<LPARAM>(pData.release()));
SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
return static_cast<bool>(ret);
}
More information about the Libreoffice-commits
mailing list