cui/source/dialogs/AdditionsDialog.cxx        |    6 ++++--
 cui/uiconfig/ui/additionsdialog.ui            |    1 +
 include/unotools/ucbstreamhelper.hxx          |    2 --
 sw/qa/uitest/options/optionsDialog.py         |    5 +++++
 unotools/source/ucbhelper/ucbstreamhelper.cxx |    5 -----
 5 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 32f4186ff10bbd04b17ba806022a5fdab2f6d277
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon Nov 2 09:34:48 2020 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Tue Nov 3 14:48:03 2020 +0100

    ucbGet needs a non-null interaction handler after all
    
    In db6c7a486395304f38e9ea52951f576f34749cbc "Use UCB instead of cURL to 
download
    https files", I had not further investigated why using the (GUI) interaction
    handler within utl::UcbStreamHelper::CreateStream would lead to deadlock 
during
    UITest_sw_options
    (UITEST_TEST_NAME=optionsDialog.optionsDialog.test_moreIconsDialog).  
Instead,
    I had passed a null XInteractionHandler into 
utl::UcbStreamHelper::CreateStream,
    assuming that would solve whatever the issue was (and it did make the UITest
    pass).
    
    However, that caused the AdditionsDialog to not be populated at all,
    with
    
    > warn:cui.dialogs:26878:26950:cui/source/dialogs/AdditionsDialog.cxx:95: 
Reading <https://yusufketen.com/api/Templates.json> failed with 0x20d(Error 
Area:Io Class:General Code:13)
    
    (see comment at 
<https://bugs.documentfoundation.org/show_bug.cgi?id=137922#c1>
    "Extensions button in Template choose does not show anything"), because
    interaction requests like com.sun.star.ucb.CertificateValidationRequest 
were not
    handled properly.
    
    As it turns out, the real reason for the deadlock was that the UITest 
quickly
    closes the dialog, causing the main thread to block at
    
      m_pSearchThread->join();
    
    in ~AdditionsDialog waiting for the SearchAndParseThread to finish, while
    SearchAndParseThread::execute encountered a CertificateValidationRequest 
that
    needs to be handled and thus blocks in UUIInteractionHelper::handleRequest
    (uui/source/iahndl.cxx) waiting for the main thread to process the
    PostUserEvent.
    
    In an ideal world, the UCB would allow to cancel the download request issued
    from ucbGet while that download is waiting for the 
CertificateValidationRequest
    to be handled, and the AdditionsDialog CloseButtonHdl would initiate such
    cancellation.  Lacking that, just keep the Close button disabled until the
    SearchAndParseThread has finished downloading.  (Pressing the Close button
    earlier, ~AdditionsDialog would have blocked the main thread anyway until
    SearchAndParseThread had finished downloading, so this should not actually
    worsen the user experience.  And the UITest now blocks waiting for the Close
    button to become enabled before pressing it; there would already be
    UITest.wait_until_property_is_updated available, but it has a hard-coded 
timeout
    which might or might not be relevant in existing uses of that function, so 
leave
    it alone and repeat the relevant code without an unhelpful timeout here.)
    
    This means that the additional utl::UcbStreamHelper::CreateStream overload
    introduced in db6c7a486395304f38e9ea52951f576f34749cbc "Use UCB instead of 
cURL
    to download https files" is not necessary after all, so remove it again.
    
    Two further items that should be looked into:
    * Should ucbGet pass the AdditionsDialog into 
utl::UcbStreamHelper::CreateStream
      as css::uno::Reference<css::awt::XWindow> xParentWin argument (which 
defaults
      to null)?
    * There might be similar deadlock issues involving ucbDownload, which can 
also
      be called (indirectly) from SearchAndParseThread::execute.
    
    Change-Id: I8d549066940fa4f259a814a31ec7c62960e0db8f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105169
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>
    Tested-by: Jenkins

diff --git a/cui/source/dialogs/AdditionsDialog.cxx 
b/cui/source/dialogs/AdditionsDialog.cxx
index 45a2ffadd72b..ab91e47cd21b 100644
--- a/cui/source/dialogs/AdditionsDialog.cxx
+++ b/cui/source/dialogs/AdditionsDialog.cxx
@@ -70,8 +70,7 @@ std::string ucbGet(const OUString& rURL)
 {
     try
     {
-        auto const s = utl::UcbStreamHelper::CreateStream(
-            rURL, StreamMode::STD_READ, 
css::uno::Reference<css::task::XInteractionHandler>());
+        auto const s = utl::UcbStreamHelper::CreateStream(rURL, 
StreamMode::STD_READ);
         if (!s)
         {
             SAL_WARN("cui.dialogs", "CreateStream <" << rURL << "> failed");
@@ -522,7 +521,10 @@ AdditionsDialog::getInstalledExtensions()
 void AdditionsDialog::SetProgress(const OUString& rProgress)
 {
     if (rProgress.isEmpty())
+    {
         m_xLabelProgress->hide();
+        m_xButtonClose->set_sensitive(true);
+    }
     else
     {
         SolarMutexGuard aGuard;
diff --git a/cui/uiconfig/ui/additionsdialog.ui 
b/cui/uiconfig/ui/additionsdialog.ui
index cd072fe47f57..7671a5bf2fd9 100644
--- a/cui/uiconfig/ui/additionsdialog.ui
+++ b/cui/uiconfig/ui/additionsdialog.ui
@@ -146,6 +146,7 @@
               <object class="GtkButton" id="buttonClose">
                 <property name="label">gtk-close</property>
                 <property name="visible">True</property>
+                <property name="sensitive">False</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="valign">end</property>
diff --git a/include/unotools/ucbstreamhelper.hxx 
b/include/unotools/ucbstreamhelper.hxx
index 9f16bb8fc0de..69bae538b316 100644
--- a/include/unotools/ucbstreamhelper.hxx
+++ b/include/unotools/ucbstreamhelper.hxx
@@ -33,14 +33,12 @@ namespace com::sun::star::io
             }
 
 namespace com::sun::star::awt { class XWindow; }
-namespace com::sun::star::task { class XInteractionHandler; }
 
 namespace utl
 {
     class UNOTOOLS_DLLPUBLIC UcbStreamHelper
     {
     public:
-        static std::unique_ptr<SvStream> CreateStream(const OUString& 
rFileName, StreamMode eOpenMode, 
css::uno::Reference<css::task::XInteractionHandler> const & handler);
         static std::unique_ptr<SvStream> CreateStream(const OUString& 
rFileName, StreamMode eOpenMode, css::uno::Reference<css::awt::XWindow> 
xParentWin = nullptr);
         static std::unique_ptr<SvStream> CreateStream(const OUString& 
rFileName, StreamMode eOpenMode,
                                                       bool bFileExists, 
css::uno::Reference<css::awt::XWindow> xParentWin = nullptr);
diff --git a/sw/qa/uitest/options/optionsDialog.py 
b/sw/qa/uitest/options/optionsDialog.py
index 13a856c0e246..d991eae826f1 100644
--- a/sw/qa/uitest/options/optionsDialog.py
+++ b/sw/qa/uitest/options/optionsDialog.py
@@ -5,6 +5,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 from uitest.framework import UITestCase
+import time
+import uitest.config
+import uitest.uihelper.common
 
 class optionsDialog(UITestCase):
 
@@ -25,6 +28,8 @@ class optionsDialog(UITestCase):
         def handle_more_icons_dlg(dialog):
             # Check it doesn't crash while opening it
             xCloseBtn = dialog.getChild("buttonClose")
+            while 
uitest.uihelper.common.get_state_as_dict(xCloseBtn)['Enabled'] != 'true':
+                time.sleep(uitest.config.DEFAULT_SLEEP)
             self.ui_test.close_dialog_through_button(xCloseBtn)
 
         self.ui_test.execute_blocking_action(xMoreIconsBtn.executeAction, 
args=('CLICK', ()),
diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx 
b/unotools/source/ucbhelper/ucbstreamhelper.cxx
index 7c95e7ef9078..6f72c00bc985 100644
--- a/unotools/source/ucbhelper/ucbstreamhelper.cxx
+++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx
@@ -138,11 +138,6 @@ static std::unique_ptr<SvStream> lcl_CreateStream( const 
OUString& rFileName, St
     return pStream;
 }
 
-std::unique_ptr<SvStream> UcbStreamHelper::CreateStream(const OUString& 
rFileName, StreamMode eOpenMode, 
css::uno::Reference<css::task::XInteractionHandler> const & handler)
-{
-    return lcl_CreateStream( rFileName, eOpenMode, handler, true /* 
bEnsureFileExists */ );
-}
-
 std::unique_ptr<SvStream> UcbStreamHelper::CreateStream(const OUString& 
rFileName, StreamMode eOpenMode, css::uno::Reference<css::awt::XWindow> 
xParentWin)
 {
     // related tdf#99312
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to