sal/rtl/source/uri.cxx | 34 ++++++++++++++------------------ solenv/gbuild/platform/WNT_INTEL_MSC.mk | 1 svtools/source/misc/transfer.cxx | 2 - sw/inc/printdata.hxx | 2 - sw/inc/unotxdoc.hxx | 5 ++-- sw/source/core/view/printdata.cxx | 5 ++++ sw/source/ui/uno/unotxdoc.cxx | 26 ++++++++++++++++-------- 7 files changed, 44 insertions(+), 31 deletions(-)
New commits: commit d53e12c7a9c2d0a3b487303673c1fafd09f6593c Author: Michael Stahl <mst...@redhat.com> Date: Wed Sep 26 12:43:29 2012 +0200 rhbz#827695: sw: prevent crashes after incomplete print: If the last page is not printed for whatever reason, then SwXTextDocument's destructor will delete a SwViewOptionAdjust_Impl, which accesses the document's ViewShell, which has already been deleted at that point. Add a horrible kludge to not crash for now. Change-Id: I67fe37970d60782030b84f2badddd1e66ef3f9c6 diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 00e7fe5..0f58d30 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -42,7 +42,6 @@ class SwDoc; class SwDocShell; -class ViewShell; class _SetGetExpFlds; class SwViewOption; class OutputDevice; @@ -277,6 +276,7 @@ public: void ViewOptionAdjustStart( ViewShell &rSh, const SwViewOption &rViewOptions); void ViewOptionAdjust( SwPrintData const* const pPrtOptions ); void ViewOptionAdjustStop(); + void ViewOptionAdjustCrashPreventionKludge(); bool HasSwPrtOptions() const { return m_pPrtOptions != 0; } SwPrintData const* GetSwPrtOptions() const { return m_pPrtOptions.get(); } diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 443aa76..3182bd2 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -579,7 +579,7 @@ public: -----------------------------------------------------------------------*/ class SwViewOptionAdjust_Impl { - ViewShell & m_rShell; + ViewShell * m_pShell; SwViewOption m_aOldViewOptions; public: @@ -587,7 +587,8 @@ public: ~SwViewOptionAdjust_Impl(); void AdjustViewOptions( SwPrintData const* const pPrtOptions ); bool checkShell( const ViewShell& rCompare ) const - { return &rCompare == &m_rShell; } + { return &rCompare == m_pShell; } + void DontTouchThatViewShellItSmellsFunny() { m_pShell = 0; } }; diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx index 4e6d37f..9988855 100644 --- a/sw/source/core/view/printdata.cxx +++ b/sw/source/core/view/printdata.cxx @@ -131,6 +131,11 @@ void SwRenderData::ViewOptionAdjustStop() m_pViewOptionAdjust.reset(); } +void SwRenderData::ViewOptionAdjustCrashPreventionKludge() +{ + m_pViewOptionAdjust->DontTouchThatViewShellItSmellsFunny(); +} + void SwRenderData::MakeSwPrtOptions( SwDocShell const*const pDocShell, diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index 8bee384..ef09ecf 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -400,6 +400,13 @@ SwXTextDocument::~SwXTextDocument() xNumFmtAgg = 0; } delete m_pPrintUIOptions; + if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) + { // rhbz#827695: this can happen if the last page is not printed + // the ViewShell has been deleted already by SwView::~SwView + // FIXME: replace this awful implementation of XRenderable with + // something less insane that has its own view + m_pRenderData->ViewOptionAdjustCrashPreventionKludge(); + } delete m_pRenderData; } @@ -3852,14 +3859,17 @@ void SwXDocumentPropertyHelper::onChange() SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( ViewShell& rSh, const SwViewOption &rViewOptions) - : m_rShell( rSh ) + : m_pShell(&rSh) , m_aOldViewOptions( rViewOptions ) { } SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() { - m_rShell.ApplyViewOptions( m_aOldViewOptions ); + if (m_pShell) + { + m_pShell->ApplyViewOptions( m_aOldViewOptions ); + } } void @@ -3867,14 +3877,14 @@ SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions) { // to avoid unnecessary reformatting the view options related to the content // below should only change if necessary, that is if respective content is present - const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars(); - const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); + const bool bContainsHiddenChars = m_pShell->GetDoc()->ContainsHiddenChars(); + const SwFieldType* pFldType = m_pShell->GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); const bool bContainsHiddenFields = pFldType && pFldType->GetDepends(); - pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENPARAFLD ); + pFldType = m_pShell->GetDoc()->GetSysFldType( RES_HIDDENPARAFLD ); const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends(); - pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); + pFldType = m_pShell->GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); - const bool bContainsFields = m_rShell.IsAnyFieldInDoc(); + const bool bContainsFields = m_pShell->IsAnyFieldInDoc(); SwViewOption aRenderViewOptions( m_aOldViewOptions ); @@ -3914,7 +3924,7 @@ SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const pPrtOptions) if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary { aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); - m_rShell.ApplyViewOptions( aRenderViewOptions ); + m_pShell->ApplyViewOptions( aRenderViewOptions ); } } commit 0843533459302d9d9fe962f79dc5b040c3907ebc Author: Michael Stahl <mst...@redhat.com> Date: Wed Sep 26 12:37:26 2012 +0200 sal: uri.cxx: deploy some asserts Change-Id: I1d755086295f5a8cd7acf56204402b95fe228d2d diff --git a/sal/rtl/source/uri.cxx b/sal/rtl/source/uri.cxx index 3945e04..34da06f 100644 --- a/sal/rtl/source/uri.cxx +++ b/sal/rtl/source/uri.cxx @@ -201,15 +201,13 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, &nInfo, &nConverted); if (nInfo == 0) { - OSL_ASSERT( - nConverted + assert( nConverted == sal::static_int_cast< sal_uInt32 >( aBuf.getLength())); rtl_destroyTextToUnicodeConverter(aConverter); *pBegin = p; *pType = EscapeChar; - OSL_ASSERT( - nDstSize == 1 + assert( nDstSize == 1 || (nDstSize == 2 && isHighSurrogate(aDst[0]) && isLowSurrogate(aDst[1]))); return nDstSize == 1 @@ -230,7 +228,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, } else { - OSL_ASSERT( + assert( (nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL) == 0); break; @@ -252,7 +250,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd, void writeUcs4(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32) { - OSL_ENSURE(nUtf32 <= 0x10FFFF, "bad UTF-32 char"); + assert(nUtf32 <= 0x10FFFF); // bad UTF-32 char if (nUtf32 <= 0xFFFF) { writeUnicode( pBuffer, pCapacity, static_cast< sal_Unicode >(nUtf32)); @@ -270,7 +268,7 @@ void writeUcs4(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32) void writeEscapeOctet(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nOctet) { - OSL_ENSURE(nOctet <= 0xFF, "bad octet"); + assert(nOctet <= 0xFF); // bad octet static sal_Unicode const aHex[16] = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, @@ -284,7 +282,7 @@ void writeEscapeOctet(rtl_uString ** pBuffer, sal_Int32 * pCapacity, bool writeEscapeChar(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32, rtl_TextEncoding eCharset, bool bStrict) { - OSL_ENSURE(nUtf32 <= 0x10FFFF, "bad UTF-32 char"); + assert(nUtf32 <= 0x10FFFF); // bad UTF-32 char if (eCharset == RTL_TEXTENCODING_UTF8) { if (nUtf32 < 0x80) writeEscapeOctet(pBuffer, pCapacity, nUtf32); @@ -333,10 +331,10 @@ bool writeEscapeChar(rtl_uString ** pBuffer, sal_Int32 * pCapacity, | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR | RTL_UNICODETOTEXT_FLAGS_FLUSH, &nInfo, &nConverted); - OSL_ASSERT((nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL) == 0); + assert((nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL) == 0); rtl_destroyUnicodeToTextConverter(aConverter); if (nInfo == 0) { - OSL_ENSURE(nConverted == nSrcSize, "bad rtl_convertUnicodeToText"); + assert(nConverted == nSrcSize); // bad rtl_convertUnicodeToText for (sal_Size i = 0; i < nDstSize; ++i) writeEscapeOctet(pBuffer, pCapacity, static_cast< unsigned char >(aDst[i])); @@ -366,7 +364,7 @@ struct Component inline sal_Int32 Component::getLength() const { - OSL_ENSURE(isPresent(), "taking length of non-present component"); + assert(isPresent()); // taking length of non-present component return static_cast< sal_Int32 >(pEnd - pBegin); } @@ -430,7 +428,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents) if (pPos != pEnd) { - OSL_ASSERT(*pPos == '#'); + assert(*pPos == '#'); pComponents->aFragment.pBegin = pPos; pComponents->aFragment.pEnd = pEnd; } @@ -438,8 +436,8 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents) rtl::OUString joinPaths(Component const & rBasePath, Component const & rRelPath) { - OSL_ASSERT(rBasePath.isPresent() && *rBasePath.pBegin == '/'); - OSL_ASSERT(rRelPath.isPresent()); + assert(rBasePath.isPresent() && *rBasePath.pBegin == '/'); + assert(rRelPath.isPresent()); // The invariant of aBuffer is that it always starts and ends with a slash // (until probably right at the end of the algorithm, when the last segment @@ -591,11 +589,10 @@ sal_Bool const * SAL_CALL rtl_getUriCharClass(rtl_UriCharClass eCharClass) 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /*`abcdefghijklmno*/ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0 /*pqrstuvwxyz{|}~ */ }}; - OSL_ENSURE( + assert( (eCharClass >= 0 && (sal::static_int_cast< std::size_t >(eCharClass) - < SAL_N_ELEMENTS(aCharClass))), - "bad eCharClass"); + < SAL_N_ELEMENTS(aCharClass)))); // bad eCharClass return aCharClass[eCharClass]; } @@ -604,8 +601,7 @@ void SAL_CALL rtl_uriEncode(rtl_uString * pText, sal_Bool const * pCharClass, rtl_TextEncoding eCharset, rtl_uString ** pResult) SAL_THROW_EXTERN_C() { - OSL_ENSURE(!pCharClass[0x25], "bad pCharClass"); - // make sure the percent sign is encoded... + assert(!pCharClass[0x25]); // make sure the percent sign is encoded... sal_Unicode const * p = pText->buffer; sal_Unicode const * pEnd = p + pText->length; commit 8385aa5f73e4f6dda8a234240d03420e9a7da69e Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 25 21:19:16 2012 +0200 TransferableHelper: fix annoying assertion "bad pCharClass" The % must be URI encoded, not acceptable. Change-Id: I1274170275d1a1432fb2f933cbd3c6ee8c35d436 diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx index 79a6412..8c41222 100644 --- a/svtools/source/misc/transfer.cxx +++ b/svtools/source/misc/transfer.cxx @@ -181,7 +181,7 @@ static ::rtl::OUString ImplGetParameterString( const TransferableObjectDescripto pToAccept[nBInd] = sal_False; const char aQuotedParamChars[] = - "()<>@,;:\\\"/[]?=!#$%&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. "; + "()<>@,;:\\\"/[]?=!#$&'*+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz{|}~. "; for ( sal_Int32 nInd = 0; nInd < RTL_CONSTASCII_LENGTH(aQuotedParamChars); ++nInd ) { commit f0f2efaea61e674ea62430d6cda65882c90104a1 Author: Michael Stahl <mst...@redhat.com> Date: Tue Sep 25 14:46:03 2012 +0200 gbuild: disable MSVC warning C4628 for C++: the useless "digraphs not supported with -Ze. Character sequence '<:' not interpreted as alternate token for '['" occurs a lot with templates. Change-Id: I1f7ddb7545732a5e92d1fc78a16222540cca5bb9 diff --git a/solenv/gbuild/platform/WNT_INTEL_MSC.mk b/solenv/gbuild/platform/WNT_INTEL_MSC.mk index 33ee98d..f23c478 100644 --- a/solenv/gbuild/platform/WNT_INTEL_MSC.mk +++ b/solenv/gbuild/platform/WNT_INTEL_MSC.mk @@ -167,6 +167,7 @@ gb_CXXFLAGS := \ -wd4619 \ -wd4625 \ -wd4626 \ + -wd4628 \ -wd4640 \ -wd4668 \ -wd4675 \ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits