From ddd0e56cd787c2f86e9a154cbb0b4ad09ee40f80 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 3 Oct 2012 13:03:49 +0100 Subject: handle children of deferred dialog better Change-Id: I86f0a23408c031a99a31cd309defec519a2e91ec --- vcl/inc/vcl/builder.hxx | 1 + vcl/inc/vcl/dialog.hxx | 2 ++ vcl/source/control/fixed.cxx | 4 ++-- vcl/source/window/builder.cxx | 8 ++++++++ vcl/source/window/dialog.cxx | 18 ++++++++++++------ vcl/source/window/window.cxx | 6 ++---- 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 112e2939b9e9..191079151e21 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -116,6 +116,7 @@ private: OString m_sID; OString m_sHelpRoot; Window *m_pParent; + bool m_bToplevelHasDeferredInit; ParserState *m_pParserState; Window *get_by_name(OString sID); diff --git a/vcl/inc/vcl/dialog.hxx b/vcl/inc/vcl/dialog.hxx index 63163225fb6d..107c29d1a464 100644 --- a/vcl/inc/vcl/dialog.hxx +++ b/vcl/inc/vcl/dialog.hxx @@ -58,6 +58,7 @@ private: sal_Bool mbOldSaveBack; sal_Bool mbInClose; sal_Bool mbModalMode; + bool mbIsDefferedInit; Timer maLayoutTimer; SAL_DLLPRIVATE void ImplInitDialogData(); @@ -81,6 +82,7 @@ public: SAL_DLLPRIVATE sal_Bool IsInClose() const { return mbInClose; } SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutTimer.IsActive(); } SAL_DLLPRIVATE void doDeferredInit(bool bResizable); + SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDefferedInit; } protected: Dialog( WindowType nType ); diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index a63eb3ed8ba1..688b69961f00 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -949,7 +949,7 @@ WinBits FixedImage::ImplInitStyle( WinBits nStyle ) void FixedImage::ImplInitSettings() { Window* pParent = GetParent(); - if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() ) + if ( pParent && pParent->IsChildTransparentModeEnabled() && !IsControlBackground() ) { EnableChildTransparentMode( sal_True ); SetParentClipMode( PARENTCLIPMODE_NOCLIP ); @@ -964,7 +964,7 @@ void FixedImage::ImplInitSettings() if ( IsControlBackground() ) SetBackground( GetControlBackground() ); - else + else if ( pParent ) SetBackground( pParent->GetBackground() ); } } diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 67bf87159a8c..63fce3934281 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -57,6 +57,8 @@ VclBuilder::VclBuilder(Window *pParent, OUString sUIDir, OUString sUIFile, OStri , m_pParent(pParent) , m_pParserState(new ParserState) { + m_bToplevelHasDeferredInit = (pParent && pParent->IsDialog()) ? ((Dialog*)pParent)->isDeferredInit() : false; + sal_Int32 nIdx = m_sHelpRoot.lastIndexOf('.'); if (nIdx != -1) m_sHelpRoot = m_sHelpRoot.copy(0, nIdx); @@ -685,6 +687,7 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, const O { Dialog *pDialog = (Dialog*)pCurrentChild; pDialog->doDeferredInit(extractResizable(rMap)); + m_bToplevelHasDeferredInit = false; } if (pCurrentChild->GetHelpId().isEmpty()) { @@ -696,6 +699,11 @@ Window *VclBuilder::insertObject(Window *pParent, const OString &rClass, const O } else { + //if we're being inserting under a toplevel dialog whose init is + //deferred due to waiting to encounter it in this .ui, and it hasn't + //been seen yet, then make unattached widgets parent-less toplevels + if (pParent == m_pParent && m_bToplevelHasDeferredInit) + pParent = NULL; pCurrentChild = makeObject(pParent, rClass, rID, rMap); } diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index da9482c7c69f..65a72fbd9172 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -466,8 +466,9 @@ void Dialog::ImplInitSettings() // ----------------------------------------------------------------------- -Dialog::Dialog( WindowType nType ) : - SystemWindow( nType ) +Dialog::Dialog( WindowType nType ) + : SystemWindow( nType ) + , mbIsDefferedInit(false) { ImplInitDialogData(); } @@ -514,11 +515,13 @@ void Dialog::doDeferredInit(bool bResizable) Window *pParent = mpDialogParent; mpDialogParent = NULL; ImplInit(pParent, nBits); + mbIsDefferedInit = false; } Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription) : SystemWindow( WINDOW_DIALOG ) , mpDialogParent(pParent) //will be unset in doDeferredInit + , mbIsDefferedInit(true) { ImplInitDialogData(); m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); @@ -527,6 +530,7 @@ Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rU Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rUIXMLDescription, WindowType nType) : SystemWindow( nType ) , mpDialogParent(pParent) //will be unset in doDeferredInit + , mbIsDefferedInit(true) { ImplInitDialogData(); m_pUIBuilder = new VclBuilder(this, getUIRootDir(), rUIXMLDescription, rID); @@ -535,8 +539,9 @@ Dialog::Dialog(Window* pParent, const rtl::OString& rID, const rtl::OUString& rU // ----------------------------------------------------------------------- -Dialog::Dialog( Window* pParent, WinBits nStyle ) : - SystemWindow( WINDOW_DIALOG ) +Dialog::Dialog( Window* pParent, WinBits nStyle ) + : SystemWindow( WINDOW_DIALOG ) + , mbIsDefferedInit(false) { ImplInitDialogData(); ImplInit( pParent, nStyle ); @@ -544,8 +549,9 @@ Dialog::Dialog( Window* pParent, WinBits nStyle ) : // ----------------------------------------------------------------------- -Dialog::Dialog( Window* pParent, const ResId& rResId ) : - SystemWindow( WINDOW_DIALOG ) +Dialog::Dialog( Window* pParent, const ResId& rResId ) + : SystemWindow( WINDOW_DIALOG ) + , mbIsDefferedInit(false) { ImplInitDialogData(); rResId.SetRT( RSC_DIALOG ); diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index 44f1a584fc31..d874d811527b 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -1039,12 +1039,10 @@ void Window::ImplInsertWindow( Window* pParent ) mpWindowImpl->mpParent = pParent; mpWindowImpl->mpRealParent = pParent; - Window* pFrameParent = NULL; - if (pParent && !mpWindowImpl->mbFrame) - pFrameParent = pParent->mpWindowImpl->mpFrameWindow; - if (pFrameParent) + if ( pParent && !mpWindowImpl->mbFrame ) { // search frame window and set window frame data + Window* pFrameParent = pParent->mpWindowImpl->mpFrameWindow; mpWindowImpl->mpFrameData = pFrameParent->mpWindowImpl->mpFrameData; mpWindowImpl->mpFrame = pFrameParent->mpWindowImpl->mpFrame; mpWindowImpl->mpFrameWindow = pFrameParent; -- cgit v1.2.3