summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Masei <gabriel.masei@1and1.ro>2021-06-16 09:41:12 +0300
committerMichael Meeks <michael.meeks@collabora.com>2021-06-16 10:16:50 +0200
commitbf6dabe0ebad3cc5bc0edc04ae74fba0190b6203 (patch)
treed0807dbc845034a2d1b3c4495753b8f2fdd5b65e
parent01e4acd1dc3bfedb9c37b4b9bb93be1201b475a5 (diff)
vcl: check mpWindowImpl for nullptr
Change-Id: I492c7d5c1846df7507b1f043b80de4e61ff8ca86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117282 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/source/window/dialog.cxx25
-rw-r--r--vcl/source/window/mouse.cxx3
-rw-r--r--vcl/source/window/paint.cxx17
-rw-r--r--vcl/source/window/window2.cxx5
-rw-r--r--vcl/source/window/winproc.cxx34
5 files changed, 58 insertions, 26 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 538ad37b0ede..f9c6e3b1b503 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -418,7 +418,8 @@ vcl::Window* Dialog::GetDefaultParent(WinBits nStyle)
auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
auto it = std::find_if(rExecuteDialogs.rbegin(), rExecuteDialogs.rend(),
[&pParent](VclPtr<Dialog>& rDialogPtr) {
- return pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(rDialogPtr, true) &&
+ return pParent->ImplGetFirstOverlapWindow() &&
+ pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(rDialogPtr, true) &&
rDialogPtr->IsReallyVisible() && rDialogPtr->IsEnabled() &&
rDialogPtr->IsInputEnabled() && !rDialogPtr->IsInModalMode(); });
if (it != rExecuteDialogs.rend())
@@ -963,12 +964,15 @@ bool Dialog::ImplStartExecute()
if ( pParent )
{
pParent = pParent->ImplGetFirstOverlapWindow();
- SAL_WARN_IF( !pParent->IsReallyVisible(), "vcl",
- "Dialog::StartExecuteModal() - Parent not visible" );
- SAL_WARN_IF( !pParent->IsInputEnabled(), "vcl",
- "Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
- SAL_WARN_IF( pParent->IsInModalMode(), "vcl",
- "Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
+ if (pParent)
+ {
+ SAL_WARN_IF( !pParent->IsReallyVisible(), "vcl",
+ "Dialog::StartExecuteModal() - Parent not visible" );
+ SAL_WARN_IF( !pParent->IsInputEnabled(), "vcl",
+ "Dialog::StartExecuteModal() - Parent input disabled, use another parent to ensure modality!" );
+ SAL_WARN_IF( pParent->IsInModalMode(), "vcl",
+ "Dialog::StartExecuteModal() - Parent already modally disabled, use another parent to ensure modality!" );
+ }
}
#endif
@@ -1284,12 +1288,11 @@ void Dialog::ImplSetModalInputMode( bool bModal )
void Dialog::GrabFocusToFirstControl()
{
- vcl::Window* pFocusControl;
+ vcl::Window* pFocusControl = nullptr;
+ vcl::Window* pFirstOverlapWindow = ImplGetFirstOverlapWindow();
// find focus control, even if the dialog has focus
- if ( HasFocus() )
- pFocusControl = nullptr;
- else
+ if (!HasFocus() && pFirstOverlapWindow && pFirstOverlapWindow->mpWindowImpl)
{
// prefer a child window which had focus before
pFocusControl = ImplGetFirstOverlapWindow()->mpWindowImpl->mpLastFocusWindow;
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index b2f978dbe7cf..1c0eaa3ba3cc 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -291,7 +291,8 @@ void Window::ImplGrabFocus( GetFocusFlags nFlags )
// mark this windows as the last FocusWindow
vcl::Window* pOverlapWindow = ImplGetFirstOverlapWindow();
- pOverlapWindow->mpWindowImpl->mpLastFocusWindow = this;
+ if (pOverlapWindow->mpWindowImpl)
+ pOverlapWindow->mpWindowImpl->mpLastFocusWindow = this;
mpWindowImpl->mpFrameData->mpFocusWin = this;
if( !bHasFocus )
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index d595bd78d82d..734e4d8ed63b 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -623,6 +623,9 @@ void Window::ImplCallPaint(const vcl::Region* pRegion, ImplPaintFlags nPaintFlag
void Window::ImplCallOverlapPaint()
{
+ if (!mpWindowImpl)
+ return;
+
// emit overlapping windows first
vcl::Window* pTempWindow = mpWindowImpl->mpFirstOverlap;
while ( pTempWindow )
@@ -985,7 +988,7 @@ void Window::ImplValidate()
void Window::ImplUpdateAll()
{
- if ( !mpWindowImpl->mbReallyVisible )
+ if ( !mpWindowImpl || !mpWindowImpl->mbReallyVisible )
return;
bool bFlush = false;
@@ -1264,6 +1267,9 @@ bool Window::HasPaintEvent() const
void Window::PaintImmediately()
{
+ if (!mpWindowImpl)
+ return;
+
if ( mpWindowImpl->mpBorderWindow )
{
mpWindowImpl->mpBorderWindow->PaintImmediately();
@@ -1315,7 +1321,11 @@ void Window::PaintImmediately()
// trigger an update also for system windows on top of us,
// otherwise holes would remain
- vcl::Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow()->mpWindowImpl->mpFirstOverlap;
+ vcl::Window* pUpdateOverlapWindow = ImplGetFirstOverlapWindow();
+ if (pUpdateOverlapWindow->mpWindowImpl)
+ pUpdateOverlapWindow = pUpdateOverlapWindow->mpWindowImpl->mpFirstOverlap;
+ else
+ pUpdateOverlapWindow = nullptr;
while ( pUpdateOverlapWindow )
{
pUpdateOverlapWindow->PaintImmediately();
@@ -1545,6 +1555,9 @@ void Window::ImplPaintToDevice( OutputDevice* i_pTargetOutDev, const Point& i_rP
void Window::PaintToDevice(OutputDevice* pDev, const Point& rPos)
{
+ if( !mpWindowImpl )
+ return;
+
SAL_WARN_IF( pDev->HasMirroredGraphics(), "vcl.window", "PaintToDevice to mirroring graphics" );
SAL_WARN_IF( pDev->IsRTLEnabled(), "vcl.window", "PaintToDevice to mirroring device" );
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 5477e98be940..3975629e5838 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -890,6 +890,11 @@ vcl::Window* Window::ImplGetFirstOverlapWindow()
const vcl::Window* Window::ImplGetFirstOverlapWindow() const
{
+ if (!mpWindowImpl)
+ {
+ return nullptr;
+ }
+
if ( mpWindowImpl->mbOverlapWin )
return this;
else
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 0504ab4c7df1..3361b0d77858 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -1866,6 +1866,9 @@ IMPL_LINK_NOARG(vcl::Window, ImplAsyncFocusHdl, void*, void)
static void ImplHandleGetFocus( vcl::Window* pWindow )
{
+ if (!pWindow || !pWindow->ImplGetWindowImpl() || !pWindow->ImplGetWindowImpl()->mpFrameData)
+ return;
+
pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = true;
// execute Focus-Events after a delay, such that SystemChildWindows
@@ -1882,6 +1885,9 @@ static void ImplHandleGetFocus( vcl::Window* pWindow )
static void ImplHandleLoseFocus( vcl::Window* pWindow )
{
+ if (!pWindow)
+ return;
+
ImplSVData* pSVData = ImplGetSVData();
// Abort the autoscroll if the frame loses focus
@@ -1891,23 +1897,27 @@ static void ImplHandleLoseFocus( vcl::Window* pWindow )
// Abort tracking if the frame loses focus
if (pSVData->mpWinData->mpTrackWin)
{
- if (pSVData->mpWinData->mpTrackWin->ImplGetWindowImpl()->mpFrameWindow == pWindow)
+ if (pSVData->mpWinData->mpTrackWin->ImplGetWindowImpl() &&
+ pSVData->mpWinData->mpTrackWin->ImplGetWindowImpl()->mpFrameWindow == pWindow)
pSVData->mpWinData->mpTrackWin->EndTracking(TrackingEventFlags::Cancel);
}
- pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = false;
-
- // execute Focus-Events after a delay, such that SystemChildWindows
- // do not flicker when they receive focus
- if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
+ if (pWindow->ImplGetWindowImpl() && pWindow->ImplGetWindowImpl()->mpFrameData)
{
- pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus;
- pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId = Application::PostUserEvent( LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ), nullptr, true );
- }
+ pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus = false;
+
+ // execute Focus-Events after a delay, such that SystemChildWindows
+ // do not flicker when they receive focus
+ if ( !pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId )
+ {
+ pWindow->ImplGetWindowImpl()->mpFrameData->mbStartFocusState = !pWindow->ImplGetWindowImpl()->mpFrameData->mbHasFocus;
+ pWindow->ImplGetWindowImpl()->mpFrameData->mnFocusId = Application::PostUserEvent( LINK( pWindow, vcl::Window, ImplAsyncFocusHdl ), nullptr, true );
+ }
- vcl::Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
- if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
- pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide();
+ vcl::Window* pFocusWin = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
+ if ( pFocusWin && pFocusWin->ImplGetWindowImpl()->mpCursor )
+ pFocusWin->ImplGetWindowImpl()->mpCursor->ImplHide();
+ }
// Make sure that no menu is visible when a toplevel window loses focus.
VclPtr<FloatingWindow> pFirstFloat = pSVData->mpWinData->mpFirstFloat;