[Libreoffice-commits] core.git: include/vcl vcl/source

Stephan Bergmann sbergman at redhat.com
Tue Feb 24 09:15:13 PST 2015


 include/vcl/dialog.hxx       |    2 +-
 include/vcl/syswin.hxx       |    3 +--
 vcl/source/window/dialog.cxx |    7 ++++---
 vcl/source/window/syswin.cxx |    4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 6c7b85c2001edacd4f722a8cc87ad9df0385f94b
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 24 18:06:08 2015 +0100

    Avoid bad downcasts to VclBox
    
    At least in CppunitTest_smoektest there is a case where
    SystemWindow::setOptimalLayoutSize tries to downcast a VclGrid as a VclBox
    (stack top below), and that even appears to be unnecessary as the only place
    that requires the downcast is the Dialog::settingOptimalLayoutSize override.  So
    maybe it is guaranteed that GetWindow(WINDOW_FIRSTCHILD) is a VclBox if this is
    a Dialog, but need not be the case if this is not a Dialog?  Or the real bug is
    elsewhere...
    
    SystemWindow::setOptimalLayoutSize()
    SystemWindow::DoInitialLayout()
    FloatingWindow::StateChanged(StateChangedType)
    SfxFloatingWindow::StateChanged(StateChangedType)
    SmToolBoxWindow::StateChanged(StateChangedType)
    vcl::Window::ImplCallInitShow()
    vcl::Window::Show(bool, unsigned short)
    SfxChildWindow::Show(unsigned short)
    SfxWorkWindow::HidePopups_Impl(bool, bool, unsigned short)
    SfxDispatcher::DoActivate_Impl(bool, SfxViewFrame*)
    SfxViewFrame::DoActivate(bool, SfxViewFrame*)
    SfxApplication::SetViewFrame_Impl(SfxViewFrame*)
    SfxViewFrame::SetViewFrame(SfxViewFrame*)
    SfxViewFrame::MakeActive_Impl(bool)
    SfxBaseController::ConnectSfxFrame_Impl(SfxBaseController::ConnectSfxFrame)
    SfxBaseController::attachFrame(com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
    (anonymous namespace)::SfxFrameLoader_Impl::impl_createDocumentView(com::sun::star::uno::Reference<com::sun::star::frame::XModel2> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&, comphelper::NamedValueCollection const&, rtl::OUString const&)
    (anonymous namespace)::SfxFrameLoader_Impl::load(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XFrame> const&)
    framework::LoadEnv::impl_loadContent()
    framework::LoadEnv::startLoading()
    framework::LoadEnv::loadComponentFromURL(com::sun::star::uno::Reference<com::sun::star::frame::XComponentLoader> const&, com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
    ...
    
    Change-Id: I786ad451fdf73eca22860695a614ee5b889a83cd

diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 0568642..ab95f52 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -70,7 +70,7 @@ protected:
     explicit        Dialog( WindowType nType );
     explicit        Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType );
     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
-    virtual void    settingOptimalLayoutSize(VclBox *pBox) SAL_OVERRIDE;
+    virtual void    settingOptimalLayoutSize(Window *pBox) SAL_OVERRIDE;
 
 protected:
     friend class VclBuilder;
diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx
index 1f29d45..e164af8 100644
--- a/include/vcl/syswin.hxx
+++ b/include/vcl/syswin.hxx
@@ -29,7 +29,6 @@ class ModalDialog;
 class MenuBar;
 class TaskPaneList;
 class VclContainer;
-class VclBox;
 
 // - Icon-Types -
 #define ICON_LO_DEFAULT                 1
@@ -168,7 +167,7 @@ protected:
 
     void     SetWindowStateData( const WindowStateData& rData );
 
-    virtual void settingOptimalLayoutSize(VclBox *pBox);
+    virtual void settingOptimalLayoutSize(Window *pBox);
 
     SAL_DLLPRIVATE void DoInitialLayout();
 public:
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 18467af..b2d4139 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -523,12 +523,13 @@ void Dialog::set_content_area(VclBox* pContentArea)
     mpContentArea = pContentArea;
 }
 
-void Dialog::settingOptimalLayoutSize(VclBox *pBox)
+void Dialog::settingOptimalLayoutSize(Window *pBox)
 {
     const DialogStyle& rDialogStyle =
         GetSettings().GetStyleSettings().GetDialogStyle();
-    pBox->set_border_width(rDialogStyle.content_area_border);
-    pBox->set_spacing(pBox->get_spacing() +
+    VclBox * pBox2 = static_cast<VclBox*>(pBox);
+    pBox2->set_border_width(rDialogStyle.content_area_border);
+    pBox2->set_spacing(pBox2->get_spacing() +
         rDialogStyle.content_area_spacing);
 
     VclButtonBox *pActionArea = getActionArea(this);
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 6b79906..5c953f3 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -1065,7 +1065,7 @@ OUString SystemWindow::GetText() const
     return Window::GetText();
 }
 
-void SystemWindow::settingOptimalLayoutSize(VclBox* /*pBox*/)
+void SystemWindow::settingOptimalLayoutSize(Window* /*pBox*/)
 {
 }
 
@@ -1074,7 +1074,7 @@ void SystemWindow::setOptimalLayoutSize()
     maLayoutIdle.Stop();
 
     //resize SystemWindow to fit requisition on initial show
-    VclBox *pBox = static_cast<VclBox*>(GetWindow(WINDOW_FIRSTCHILD));
+    Window *pBox = GetWindow(WINDOW_FIRSTCHILD);
 
     settingOptimalLayoutSize(pBox);
 


More information about the Libreoffice-commits mailing list