dbaccess/source/core/api/RowSet.cxx |   18 ++++++---------
 dbaccess/source/core/api/RowSet.hxx |    1 
 vcl/qt5/Qt5Frame.cxx                |   42 +++++++++++++++++++-----------------
 3 files changed, 32 insertions(+), 29 deletions(-)

New commits:
commit 84c25d55fe03f693a86816ad11f614bc7d07ed1a
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Sep 24 06:39:09 2021 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Sep 24 13:57:39 2021 +0200

    qt5: Port Qt5Frame away from deprecated QDesktopWidget
    
    Most of QDesktopWidget's methods were deprecated in
    Qt 5.11 and QDesktopWidget was removed in Qt 6.
    
    Since 'QScreen *QGuiApplication::screenAt(const QPoint &point)'
    was only introduced in 5.10, keep using
    'QDesktopWidget::screenNumber' for older Qt versions.
    
    Change-Id: I915fda0ea00b018945974ad82c1927a5fac99145
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122548
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 2c2b439be225..43ca9cdbf802 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -45,7 +45,9 @@
 #include <QtWidgets/QStyle>
 #include <QtWidgets/QToolTip>
 #include <QtWidgets/QApplication>
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
 #include <QtWidgets/QDesktopWidget>
+#endif
 #include <QtWidgets/QMenuBar>
 #include <QtWidgets/QMainWindow>
 
@@ -482,26 +484,26 @@ Size Qt5Frame::CalcDefaultSize()
     if (!m_bFullScreen)
     {
         const QScreen* pScreen = screen();
-        SAL_WNODEPRECATED_DECLARATIONS_PUSH
-        aSize = bestmaxFrameSizeForScreenSize(
-            toSize(pScreen ? pScreen->size() : 
QApplication::desktop()->screenGeometry(0).size()));
-        SAL_WNODEPRECATED_DECLARATIONS_POP
+        if (!pScreen)
+            pScreen = QGuiApplication::screens().at(0);
+        aSize = bestmaxFrameSizeForScreenSize(toSize(pScreen->size()));
     }
     else
     {
         if (!m_bFullScreenSpanAll)
         {
-            SAL_WNODEPRECATED_DECLARATIONS_PUSH
-            aSize = toSize(
-                
QApplication::desktop()->screenGeometry(maGeometry.nDisplayScreenNumber).size());
-            SAL_WNODEPRECATED_DECLARATIONS_POP
+            aSize = 
toSize(QGuiApplication::screens().at(maGeometry.nDisplayScreenNumber)->size());
         }
         else
         {
-            SAL_WNODEPRECATED_DECLARATIONS_PUSH
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+            QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0));
+#else
+            // QGuiApplication::screenAt was added in Qt 5.10, use deprecated 
QDesktopWidget
             int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 
0));
-            SAL_WNODEPRECATED_DECLARATIONS_POP
-            aSize = 
toSize(QApplication::screens()[nLeftScreen]->availableVirtualGeometry().size());
+            QScreen* pScreen = QGuiApplication::screens()[nLeftScreen];
+#endif
+            aSize = toSize(pScreen->availableVirtualGeometry().size());
         }
     }
 
@@ -1216,23 +1218,25 @@ void Qt5Frame::SetScreenNumber(unsigned int nScreen)
 
         if (!m_bFullScreenSpanAll)
         {
-            SAL_WNODEPRECATED_DECLARATIONS_PUSH
-            screenGeo = QApplication::desktop()->screenGeometry(nScreen);
-            SAL_WNODEPRECATED_DECLARATIONS_POP
+            screenGeo = QGuiApplication::screens().at(nScreen)->geometry();
             pWindow->setScreen(QApplication::screens()[nScreen]);
         }
         else // special case: fullscreen over all available screens
         {
             assert(m_bFullScreen);
             // left-most screen
-            SAL_WNODEPRECATED_DECLARATIONS_PUSH
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+            QScreen* pScreen = QGuiApplication::screenAt(QPoint(0, 0));
+#else
+            // QGuiApplication::screenAt was added in Qt 5.10, use deprecated 
QDesktopWidget
             int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 
0));
-            SAL_WNODEPRECATED_DECLARATIONS_POP
+            QScreen* pScreen = QGuiApplication::screens()[nLeftScreen];
+#endif
             // entire virtual desktop
-            screenGeo = 
QApplication::screens()[nLeftScreen]->availableVirtualGeometry();
-            pWindow->setScreen(QApplication::screens()[nLeftScreen]);
+            screenGeo = pScreen->availableVirtualGeometry();
+            pWindow->setScreen(pScreen);
             pWindow->setGeometry(screenGeo);
-            nScreen = nLeftScreen;
+            nScreen = screenNumber(pScreen);
         }
 
         // setScreen by itself has no effect, explicitly move the widget to
commit fe040e71343cb894f97a0781f77805fd046178ca
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Sep 24 11:03:34 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Sep 24 13:57:29 2021 +0200

    we just want to append to the caught exception and rethrow it
    
    try and avoid using cppu::throwException due to asan
    
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==571495==ERROR: AddressSanitizer: SEGV on unknown address (pc 
0x7f0af1cee04c bp 0x7ffc0fa694f0 sp 0x7ffc0fa69298 T0)
    ==571495==The signal is caused by a READ memory access.
    ==571495==Hint: this fault was caused by a dereference of a high value 
address (see register values below).  Disassemble the provided pc to learn 
which register was used.
        #0 0x7f0af1cee04c  (<unknown module>)
        #1 0xab690cf in dbtools::SQLExceptionInfo::doThrow() 
connectivity/source/commontools/dbexception.cxx:240:9
        #2 0xa5e0a26 in dbaccess::ORowSet::impl_ensureStatement_throw() 
dbaccess/source/core/api/RowSet.cxx:1661:16
        #3 0xa5e0d80 in dbaccess::ORowSet::impl_prepareAndExecute_throw() 
dbaccess/source/core/api/RowSet.cxx:1667:5
        #4 0xa5d33c4 in 
dbaccess::ORowSet::execute_NoApprove_NoNewConn(osl::ResettableGuard<osl::Mutex>&)
 dbaccess/source/core/api/RowSet.cxx:1800:45
        #5 0xa5d0a10 in dbaccess::ORowSet::execute() 
dbaccess/source/core/api/RowSet.cxx:1556:5
        #6 0x6eae94 in ScDocShell::DBaseImport(rtl::OUString const&, unsigned 
short, std::__1::map<short, ScColWidthParam, std::__1::less<short>, 
std::__1::allocator<std::__1::pair<short const, ScColWidthParam> > >&, 
ScFlatBoolRowSegments&) sc/source/ui/docshell/docsh8.cxx:316:18
        #7 0x65ba78 in TestImportDBF sc/source/ui/docshell/docsh.cxx:3448:33
        #8 0x627912 in LLVMFuzzerTestOneInput vcl/workben/dbffuzzer.cxx:49:11
        #9 0x53fe23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, 
unsigned long) cxa_noexception.cpp
        #10 0x53f61a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned 
long, bool, fuzzer::InputInfo*, bool, bool*) cxa_noexception.cpp
        #11 0x540ccb in fuzzer::Fuzzer::MutateAndTestOne() cxa_noexception.cpp
        #12 0x5416f5 in 
fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, 
std::__Fuzzer::allocator<fuzzer::SizedFile> >&) cxa_noexception.cpp
        #13 0x5325ce in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned 
char const*, unsigned long)) cxa_noexception.cpp
        #14 0x557582 in main 
/src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
        #15 0x7f0af28b90b2 in __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    
    seen in oss-fuzz build with
    clang version 14.0.0 (https://github.com/llvm/llvm-project.git 
0e03450ae4358e8a8242b73d493d96efea9d3ccf)
    
    Change-Id: I0d676e10d7749ab331870b3d763e8f0bbefa18c3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122571
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/dbaccess/source/core/api/RowSet.cxx 
b/dbaccess/source/core/api/RowSet.cxx
index 79ffe82ea2da..6a5af36e205e 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -123,6 +123,7 @@ ORowSet::ORowSet( const Reference< 
css::uno::XComponentContext >& _rxContext )
     ,m_aRowsetListeners(*m_pMutex)
     ,m_aApproveListeners(*m_pMutex)
     ,m_aRowsChangeListener(*m_pMutex)
+    
,m_sErrorString(ResourceManager::loadString(RID_STR_COMMAND_LEADING_TO_ERROR))
     ,m_nFetchDirection(FetchDirection::FORWARD)
     ,m_nFetchSize(50)
     ,m_nMaxFieldSize(0)
@@ -1644,21 +1645,18 @@ void ORowSet::impl_ensureStatement_throw()
             // then the driver doesn't support this feature
         }
     }
-    catch( const SQLException& )
+    catch (SQLException& rException)
     {
-        SQLExceptionInfo aError( ::cppu::getCaughtException() );
-        OSL_ENSURE( aError.isValid(), "ORowSet::impl_makeNewStatement_throw: 
caught an SQLException which we cannot analyze!" );
+        css::sdbc::SQLException* pLastExceptionInChain = 
SQLExceptionInfo::getLastException(&rException);
+        assert(pLastExceptionInChain && "will at least be &rException");
 
         // append information about what we were actually going to execute
-        try
-        {
-            OUString sInfo(DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, 
"$command$", sCommandToExecute )  );
-            aError.append( SQLExceptionInfo::TYPE::SQLContext, sInfo );
-        }
-        catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); }
+        OUString sInfo(m_sErrorString.replaceFirst("$command$", 
sCommandToExecute));
+        css::uno::Any aAppend = 
SQLExceptionInfo::createException(SQLExceptionInfo::TYPE::SQLContext, sInfo, 
OUString(), 0);
+        pLastExceptionInChain->NextException = aAppend;
 
         // propagate
-        aError.doThrow();
+        throw;
     }
 }
 
diff --git a/dbaccess/source/core/api/RowSet.hxx 
b/dbaccess/source/core/api/RowSet.hxx
index 6da5fdb2ece1..4dc244d1b5db 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -116,6 +116,7 @@ namespace dbaccess
         OUString                               m_aUpdateCatalogName; // is set 
by a query
         OUString                               m_aUpdateSchemaName; // is set 
by a query
         OUString                               m_aUpdateTableName; // is set 
by a query
+        OUString                               m_sErrorString;
 
         sal_Int32                   m_nFetchDirection;
         sal_Int32                   m_nFetchSize;

Reply via email to