basctl/source/basicide/IDEComboBox.cxx         |   16 +++++++----
 basctl/source/basicide/basides1.cxx            |    2 -
 basctl/source/basicide/basobj3.cxx             |    6 ++--
 basic/source/runtime/inputbox.cxx              |    3 --
 basic/source/runtime/iosys.cxx                 |    6 +---
 basic/source/runtime/methods.cxx               |    3 --
 include/vcl/svapp.hxx                          |   14 ++++++---
 include/vcl/toolkit/dialog.hxx                 |    2 +
 sc/source/ui/docshell/docsh.cxx                |    3 --
 sd/qa/unit/dialogs-test.cxx                    |   36 ++++++++-----------------
 svx/source/dialog/SafeModeUI.cxx               |    3 --
 sw/source/ui/dbui/mmresultdialogs.cxx          |    3 --
 vcl/source/app/svapp.cxx                       |    8 ++++-
 vcl/source/window/dialog.cxx                   |    2 -
 vcl/unx/generic/print/genprnpsp.cxx            |    3 --
 vcl/unx/generic/printer/cupsmgr.cxx            |    6 +---
 vcl/unx/gtk3/gtkinst.cxx                       |    7 +++-
 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx |   17 ++++-------
 18 files changed, 68 insertions(+), 72 deletions(-)

New commits:
commit 1aee8678c83c637a2d5c1e0a716528b0bcf11de0
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Aug 5 19:46:35 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Aug 6 10:55:18 2021 +0200

    drop intermediate vcl::Window from Application::GetDefDialogParent
    
    Change-Id: I96be984cbefeb8e45bf49de4c50a225a46fbefb6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120089
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/basctl/source/basicide/IDEComboBox.cxx 
b/basctl/source/basicide/IDEComboBox.cxx
index 87a45e5a9c22..e295e44ff1ed 100644
--- a/basctl/source/basicide/IDEComboBox.cxx
+++ b/basctl/source/basicide/IDEComboBox.cxx
@@ -194,14 +194,20 @@ void LibBox::ReleaseFocus()
     SfxViewShell* pCurSh = SfxViewShell::Current();
     DBG_ASSERT(pCurSh, "Current ViewShell not found!");
 
-    if (pCurSh)
-    {
-        vcl::Window* pShellWin = pCurSh->GetWindow();
-        if (!pShellWin)
-            pShellWin = Application::GetDefDialogParent();
+    if (!pCurSh)
+        return;
 
+    vcl::Window* pShellWin = pCurSh->GetWindow();
+    if (pShellWin)
+    {
         pShellWin->GrabFocus();
+        return;
     }
+
+    weld::Window* pWin = Application::GetDefDialogParent();
+    if (!pWin)
+        return;
+    pWin->grab_focus();
 }
 
 void LibBox::FillBox()
diff --git a/basctl/source/basicide/basides1.cxx 
b/basctl/source/basicide/basides1.cxx
index 8942d87f4ae0..70991525331a 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -1295,7 +1295,7 @@ BasicDebugFlags Shell::CallBasicBreakHdl( StarBASIC const 
* pBasic )
         if ( StarBASIC::IsRunning() )   // if cancelled...
         {
             if ( bAppWindowDisabled )
-                Application::GetDefDialogParent()->Enable(false);
+                Application::GetDefDialogParent()->set_sensitive(false);
 
             if ( nWaitCount )
             {
diff --git a/basctl/source/basicide/basobj3.cxx 
b/basctl/source/basicide/basobj3.cxx
index fa7c2fc3d220..06f7c6a9e08c 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -332,10 +332,10 @@ void BasicStopped(
             *pnWaitCount = nWait;
     }
 
-    vcl::Window* pDefParent = Application::GetDefDialogParent();
-    if ( pDefParent && !pDefParent->IsEnabled() )
+    weld::Window* pDefParent = Application::GetDefDialogParent();
+    if (pDefParent && !pDefParent->get_sensitive())
     {
-        pDefParent->Enable();
+        pDefParent->set_sensitive(true);
         if ( pbAppWindowDisabled )
             *pbAppWindowDisabled = true;
     }
diff --git a/basic/source/runtime/inputbox.cxx 
b/basic/source/runtime/inputbox.cxx
index 50b19ee51273..e409b1352bfd 100644
--- a/basic/source/runtime/inputbox.cxx
+++ b/basic/source/runtime/inputbox.cxx
@@ -133,8 +133,7 @@ void SbRtl_InputBox(StarBASIC *, SbxArray & rPar, bool)
             nX = rPar.Get(4)->GetLong();
             nY = rPar.Get(5)->GetLong();
         }
-        vcl::Window* pParent = Application::GetDefDialogParent();
-        SvRTLInputBox aDlg(pParent ? pParent->GetFrameWeld() : 
nullptr,rPrompt,aTitle,aDefault,nX,nY);
+        SvRTLInputBox aDlg(Application::GetDefDialogParent(), rPrompt, aTitle, 
aDefault, nX, nY);
         aDlg.run();
         rPar.Get(0)->PutString(aDlg.GetText());
     }
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index 5b177b906d2d..43ee1c4d6856 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -691,8 +691,7 @@ void SbiIoSystem::Shutdown()
     // anything left to PRINT?
     if( !aOut.isEmpty() )
     {
-        vcl::Window* pParent = Application::GetDefDialogParent();
-        std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : 
nullptr, VclMessageType::Warning,
+        std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(Application::GetDefDialogParent(), 
VclMessageType::Warning,
             VclButtonsType::Ok, aOut));
         xBox->run();
     }
@@ -831,8 +830,7 @@ void SbiIoSystem::WriteCon(std::u16string_view rText)
     {
         SolarMutexGuard aSolarGuard;
 
-        vcl::Window* pParent = Application::GetDefDialogParent();
-        std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : 
nullptr, VclMessageType::Warning,
+        std::unique_ptr<weld::MessageDialog> 
xBox(Application::CreateMessageDialog(Application::GetDefDialogParent(), 
VclMessageType::Warning,
             VclButtonsType::OkCancel, s));
         xBox->set_default_response(RET_OK);
         if (!xBox->run())
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 39309f06a4f4..27da5fdac33d 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4410,8 +4410,7 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
     WinBits nDialogType = nType & (16+32+64);
 
     SolarMutexGuard aSolarGuard;
-    vcl::Window* pParentWin = Application::GetDefDialogParent();
-    weld::Widget* pParent = pParentWin ? pParentWin->GetFrameWeld() : nullptr;
+    weld::Widget* pParent = Application::GetDefDialogParent();
 
     VclMessageType eType = VclMessageType::Other;
 
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index d6a6bfbc5065..519aad8bb27b 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1092,16 +1092,20 @@ public:
 
     /** Get the default parent window for dialog boxes.
 
-     @remark GetDefDialogParent does all sorts of things find a useful parent
-             window for dialogs. It first uses the topmost parent of the active
-             window to avoid using floating windows or other dialog boxes. If
-             there are no active windows, then it will take a random stab and
+     @remark This is almost always a terrible method to use to get a parent
+             for a dialog, try hard to instead pass a specific parent window
+             to dialogs.
+
+             GetDefDialogParent does all sorts of things to try and find a 
useful
+             parent window for dialogs. It first uses the topmost parent of the
+             active window to avoid using floating windows or other dialog 
boxes.
+             If there are no active windows, then it will take a random stab 
and
              choose the first visible top window. Otherwise, it defaults to
              the desktop.
 
      @returns Pointer to the default window.
     */
-    static vcl::Window*              GetDefDialogParent();
+    static weld::Window*        GetDefDialogParent();
 
 
     /** Gets the dialog cancel mode for headless environments.
diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx
index 52f58957bc5a..3a5a1650bdc7 100644
--- a/include/vcl/toolkit/dialog.hxx
+++ b/include/vcl/toolkit/dialog.hxx
@@ -88,6 +88,8 @@ public:
     virtual        void    doDeferredInit(WinBits nBits) override;
     SAL_DLLPRIVATE void    disposeOwnedButtons();
 
+    SAL_DLLPRIVATE static vcl::Window* GetDefDialogParent();
+
 protected:
     explicit        Dialog( WindowType nType );
     explicit        Dialog( vcl::Window* pParent, std::u16string_view rID, 
const OUString& rUIXMLDescription);
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 8e2c3c45218f..7a5732e0a154 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -3028,8 +3028,7 @@ weld::Window* ScDocShell::GetActiveDialogParent()
     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
     if ( pViewSh )
         return pViewSh->GetDialogParent();
-    vcl::Window* pRet = Application::GetDefDialogParent();
-    return pRet ? pRet->GetFrameWeld() : nullptr;
+    return Application::GetDefDialogParent();
 }
 
 void ScDocShell::SetSolverSaveData( std::unique_ptr<ScOptSolverSave> pData )
diff --git a/sd/qa/unit/dialogs-test.cxx b/sd/qa/unit/dialogs-test.cxx
index 50272165e702..16b14a7b37d8 100644
--- a/sd/qa/unit/dialogs-test.cxx
+++ b/sd/qa/unit/dialogs-test.cxx
@@ -250,9 +250,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             // it is more a 'wizard' in that it has prev/next buttons and 
implicitly
             // multiple pages. To make use of that it is necessary that the 
implementation
             // supports the 'Screenshot interface'
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateSdPublishingDlg(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 DocumentType::Impress);
             break;
         }
@@ -263,9 +262,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             // there is no object selected that can be broken up. For better
             // results it might be necessary to add/select an object that
             // delivers a good metafile (which is the base for breaking)
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateBreakDlg(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 getDrawView(),
                 getDocShell(),
                 0,
@@ -380,9 +378,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             SdrObject* pSdrObj = pSdPage->GetObj(0);
             // using one SdrObject is okay, none crashes
             CPPUNIT_ASSERT(pSdrObj);
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateMorphDlg(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 pSdrObj,
                 pSdrObj);
             break;
@@ -390,9 +387,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
         case 11:
         {
             // CreateSdOutlineBulletTabDlg(const SfxItemSet* pAttr, 
::sd::View* pView = nullptr) override;
-            auto const parent = Application::GetDefDialogParent();
             pRetval = 
getSdAbstractDialogFactory()->CreateSdOutlineBulletTabDlg(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 &getEmptySfxItemSet(),
                 getDrawView());
             break;
@@ -427,9 +423,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             aDlgSet.Put(SfxBoolItem(ATTR_PRESENT_SHOW_PAUSELOGO, 
rPresentationSettings.mbShowPauseLogo));
             //SdOptions* pOptions = 
SD_MOD()->GetSdOptions(DocumentType::Impress);
             aDlgSet.Put(SfxInt32Item(ATTR_PRESENT_DISPLAY, 0 
/*pOptions->GetDisplay()*/));
-            vcl::Window* pWin = Application::GetDefDialogParent();
             pRetval = 
getSdAbstractDialogFactory()->CreateSdStartPresentationDlg(
-                pWin ? pWin->GetFrameWeld() : nullptr,
+                Application::GetDefDialogParent(),
                 aDlgSet,
                 std::vector<OUString>(),
                 nullptr);
@@ -437,10 +432,9 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
         }
         case 14:
         {
-            auto const parent = Application::GetDefDialogParent();
             // CreateRemoteDialog(vcl::Window* pWindow) override; // ad for 
RemoteDialog
             pRetval = getSdAbstractDialogFactory()->CreateRemoteDialog(
-                parent == nullptr ? nullptr : parent->GetFrameWeld());
+                Application::GetDefDialogParent());
             break;
         }
         case 15:
@@ -452,10 +446,9 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             CPPUNIT_ASSERT(pStyleSheetPool);
             SfxStyleSheetBase* pStyleSheet = 
pStyleSheetPool->First(SfxStyleFamily::Page);
             CPPUNIT_ASSERT(pStyleSheet);
-            vcl::Window* pWin = Application::GetDefDialogParent();
             pRetval = 
getSdAbstractDialogFactory()->CreateSdPresLayoutTemplateDlg(
                 getDocShell(),
-                pWin ? pWin->GetFrameWeld() : nullptr,
+                Application::GetDefDialogParent(),
                 false,
                 *pStyleSheet,
                 PresentationObjects::Title,
@@ -465,9 +458,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
         case 16:
         {
             // CreateSdPresLayoutDlg(::sd::DrawDocShell* pDocShell, 
vcl::Window* pWindow, const SfxItemSet& rInAttrs) override;
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateSdPresLayoutDlg(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 getDocShell(),
                 getEmptySfxItemSet());
             break;
@@ -524,9 +516,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             // CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, 
::sd::DrawDocShell* pDocShell) override;
             // works well with empty Bitmap, but my be nicer with setting one
             Bitmap aEmptyBitmap;
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateSdVectorizeDlg(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 aEmptyBitmap,
                 getDocShell());
             break;
@@ -536,9 +527,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             // CreateSdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* 
pDoc) override;
             SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
             CPPUNIT_ASSERT(pDrawDoc);
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateSdPhotoAlbumDialog(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 pDrawDoc);
             break;
         }
@@ -549,9 +539,8 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             CPPUNIT_ASSERT(pDrawDoc);
             SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
             CPPUNIT_ASSERT(pSdPage);
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateMasterLayoutDialog(
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 pDrawDoc,
                 pSdPage);
             break;
@@ -569,10 +558,9 @@ VclPtr<VclAbstractDialog> 
SdDialogsTest::createDialogByID(sal_uInt32 nID)
             CPPUNIT_ASSERT(pDrawDoc);
             SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
             CPPUNIT_ASSERT(pSdPage);
-            auto const parent = Application::GetDefDialogParent();
             pRetval = getSdAbstractDialogFactory()->CreateHeaderFooterDialog(
                 getViewShell(),
-                parent == nullptr ? nullptr : parent->GetFrameWeld(),
+                Application::GetDefDialogParent(),
                 pDrawDoc,
                 pSdPage);
             break;
diff --git a/svx/source/dialog/SafeModeUI.cxx b/svx/source/dialog/SafeModeUI.cxx
index 541057e0c846..d6ab6e5c86a3 100644
--- a/svx/source/dialog/SafeModeUI.cxx
+++ b/svx/source/dialog/SafeModeUI.cxx
@@ -62,8 +62,7 @@ css::uno::Any SAL_CALL 
SafeModeUI::dispatchWithReturnValue(const css::util::URL&
 {
     SolarMutexGuard aGuard;
     css::uno::Any aRet;
-    vcl::Window* pParentWindow = Application::GetDefDialogParent();
-    SafeModeDialog aDialog(pParentWindow ? pParentWindow->GetFrameWeld() : 
nullptr);
+    SafeModeDialog aDialog(Application::GetDefDialogParent());
     aDialog.run();
     return aRet;
 }
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx 
b/sw/source/ui/dbui/mmresultdialogs.cxx
index cc659cbebd74..ab41dcb4693c 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -1075,8 +1075,7 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, 
SendDocumentsHdl_Impl, weld::Button&, voi
     xStore->storeToURL( sTargetTempURL, aValues   );
 
     //create the send dialog
-    vcl::Window* pParent = Application::GetDefDialogParent();
-    std::shared_ptr<SwSendMailDialog> xDlg = 
std::make_shared<SwSendMailDialog>(pParent ? pParent->GetFrameWeld() : nullptr, 
*xConfigItem);
+    std::shared_ptr<SwSendMailDialog> xDlg = 
std::make_shared<SwSendMailDialog>(Application::GetDefDialogParent(), 
*xConfigItem);
 
     xDlg->StartSend(nEnd - nBegin);
     weld::DialogController::runAsync(xDlg, [](sal_Int32 /*nResult*/){});
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 1a8c1d0b8e1a..be8e600f026e 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1376,7 +1376,7 @@ OUString Application::GetToolkitName()
         return OUString();
 }
 
-vcl::Window* Application::GetDefDialogParent()
+vcl::Window* Dialog::GetDefDialogParent()
 {
     ImplSVData* pSVData = ImplGetSVData();
     // find some useful dialog parent
@@ -1433,6 +1433,12 @@ vcl::Window* Application::GetDefDialogParent()
     return nullptr;
 }
 
+weld::Window* Application::GetDefDialogParent()
+{
+    vcl::Window* pWindow = Dialog::GetDefDialogParent();
+    return pWindow ? pWindow->GetFrameWeld() : nullptr;
+}
+
 DialogCancelMode Application::GetDialogCancelMode()
 {
     return ImplGetSVData()->maAppData.meDialogCancel;
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index ca5298bef0e4..50717d9da058 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -406,7 +406,7 @@ void Dialog::PixelInvalidate(const tools::Rectangle* 
pRectangle)
 
 vcl::Window* Dialog::GetDefaultParent(WinBits nStyle)
 {
-    vcl::Window* pParent = Application::GetDefDialogParent();
+    vcl::Window* pParent = Dialog::GetDefDialogParent();
     if (!pParent && !(nStyle & WB_SYSTEMWINDOW))
         pParent = ImplGetSVData()->maFrameData.mpAppWin;
 
diff --git a/vcl/unx/generic/print/genprnpsp.cxx 
b/vcl/unx/generic/print/genprnpsp.cxx
index bd511f6d9326..19ec3206287f 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -134,8 +134,7 @@ namespace
 
     int QueryFaxNumber(OUString& rNumber)
     {
-        vcl::Window* pWin = Application::GetDefDialogParent();
-        QueryString aQuery(pWin ? pWin->GetFrameWeld() : nullptr, 
VclResId(SV_PRINT_QUERYFAXNUMBER_TXT), rNumber);
+        QueryString aQuery(Application::GetDefDialogParent(), 
VclResId(SV_PRINT_QUERYFAXNUMBER_TXT), rNumber);
         return aQuery.run();
     }
 }
diff --git a/vcl/unx/generic/printer/cupsmgr.cxx 
b/vcl/unx/generic/printer/cupsmgr.cxx
index 6ac997d14c10..5c7fb3013e73 100644
--- a/vcl/unx/generic/printer/cupsmgr.cxx
+++ b/vcl/unx/generic/printer/cupsmgr.cxx
@@ -737,8 +737,7 @@ namespace
     {
         bool bRet = false;
 
-        vcl::Window* pWin = Application::GetDefDialogParent();
-        RTSPWDialog aDialog(pWin ? pWin->GetFrameWeld() : nullptr, rServer, 
rUserName);
+        RTSPWDialog aDialog(Application::GetDefDialogParent(), rServer, 
rUserName);
         if (aDialog.run() == RET_OK)
         {
             rUserName = aDialog.getUserName();
@@ -828,8 +827,7 @@ bool CUPSManager::endSpool( const OUString& rPrintername, 
const OUString& rJobTi
             {
                 OString sPrinterName(OUStringToOString(rPrintername, 
RTL_TEXTENCODING_UTF8));
                 OString sUser = cupsUser();
-                vcl::Window* pWin = Application::GetDefDialogParent();
-                RTSPWDialog aDialog(pWin ? pWin->GetFrameWeld() : nullptr, 
sPrinterName, sUser);
+                RTSPWDialog aDialog(Application::GetDefDialogParent(), 
sPrinterName, sUser);
                 aDialog.SetDomainVisible(bDomain);
                 aDialog.SetUserVisible(bUser);
                 aDialog.SetPassVisible(bPass);
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 29a16612c992..6122cff7c871 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -5901,8 +5901,11 @@ public:
 
     virtual SystemEnvData get_system_data() const override
     {
-        assert(false && "nothing should call this impl, yet anyway, if ever");
-        return SystemEnvData();
+        GtkSalFrame* pFrame = 
GtkSalFrame::getFromWindow(GTK_WIDGET(m_pWindow));
+        assert(pFrame && "nothing should call this impl, yet anyway, if ever, 
except on result of GetFrameWeld()");
+        const SystemEnvData* pEnvData = pFrame->GetSystemData();
+        assert(pEnvData);
+        return *pEnvData;
     }
 
     virtual Size get_size() const override
diff --git a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx 
b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx
index 6ffd51272dfd..c1491208977e 100644
--- a/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx
+++ b/vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx
@@ -31,7 +31,7 @@
 
 #include <vcl/svapp.hxx>
 #include <vcl/sysdata.hxx>
-#include <vcl/syswin.hxx>
+#include <vcl/weld.hxx>
 
 #include <osl/file.h>
 #include <osl/process.h>
@@ -189,20 +189,17 @@ static gboolean ignoreDeleteEvent(GtkWidget* /*widget*/, 
GdkEvent* /*event*/,
 
 std::function<void()> Gtk3KDE5FilePickerIpc::blockMainWindow()
 {
-    vcl::Window* pParentWin = Application::GetDefDialogParent();
+    weld::Window* pParentWin = Application::GetDefDialogParent();
     if (!pParentWin)
         return {};
 
-    const SystemEnvData* pSysData = 
static_cast<SystemWindow*>(pParentWin)->GetSystemData();
-    if (!pSysData)
-        return {};
-
-    sendCommand(Commands::SetWinId, 
pSysData->GetWindowHandle(pParentWin->ImplGetFrame()));
-
-    auto* pMainWindow = static_cast<GtkWidget*>(pSysData->pWidget);
+    const SystemEnvData aSysData = pParentWin->get_system_data();
+    auto* pMainWindow = static_cast<GtkWidget*>(aSysData.pWidget);
     if (!pMainWindow)
         return {};
 
+    sendCommand(Commands::SetWinId, 
aSysData.GetWindowHandle(aSysData.pSalFrame));
+
     SolarMutexGuard guard;
     auto deleteEventSignalId = g_signal_lookup("delete_event", 
gtk_widget_get_type());
 
@@ -212,7 +209,7 @@ std::function<void()> 
Gtk3KDE5FilePickerIpc::blockMainWindow()
     // block the GtkSalFrame delete_event handler
     auto blockedHandler = g_signal_handler_find(
         pMainWindow, static_cast<GSignalMatchType>(G_SIGNAL_MATCH_ID | 
G_SIGNAL_MATCH_DATA),
-        deleteEventSignalId, 0, nullptr, nullptr, pSysData->pSalFrame);
+        deleteEventSignalId, 0, nullptr, nullptr, aSysData.pSalFrame);
     g_signal_handler_block(pMainWindow, blockedHandler);
 
     // prevent the window from being closed

Reply via email to