[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - sw/source
Mike Kaganski
mike.kaganski at collabora.com
Mon Jul 9 14:27:28 UTC 2018
sw/source/ui/fldui/flddb.cxx | 19 ++++++++++++++++++-
sw/source/uibase/dbui/dbmgr.cxx | 15 +++++++++------
2 files changed, 27 insertions(+), 7 deletions(-)
New commits:
commit bb08376710a1288210b6ea40c371ce05203e7290
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Tue Jul 3 21:38:48 2018 +1000
Avoid failing assert in SwDBManager::MergeMailFiles
The failing assert reproducing scenario is the steps in
https://bugs.documentfoundation.org/show_bug.cgi?id=116543#c0
rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER;
rMergeDescriptor.bPrefixIsFilename is true;
rMergeDescriptor.sPrefix is empty.
The failing assert is unrelated to the crash in tdf#116543.
It looks like the assertion was incorrect; assert on empty
prefix instead.
Change-Id: Ibeedb90a9fac810124283fc06aa756777fa04720
Reviewed-on: https://gerrit.libreoffice.org/56863
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/57105
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Aron Budea <aron.budea at collabora.com>
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 861504c28031..51f0dde9ae05 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1121,19 +1121,22 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
const bool bIsMergeSilent = IsMergeSilent();
bool bCheckSingleFile_ = rMergeDescriptor.bCreateSingleFile;
+ OUString sPrefix_ = rMergeDescriptor.sPrefix;
if( bMT_EMAIL )
{
assert( !rMergeDescriptor.bPrefixIsFilename );
- assert( bMT_EMAIL && !bCheckSingleFile_ );
+ assert(!bCheckSingleFile_);
bCheckSingleFile_ = false;
}
else if( bMT_SHELL || bMT_PRINTER )
{
- assert( !rMergeDescriptor.bPrefixIsFilename );
- assert( (bMT_SHELL || bMT_PRINTER) && bCheckSingleFile_ );
+ assert(bCheckSingleFile_);
bCheckSingleFile_ = true;
+ assert(sPrefix_.isEmpty());
+ sPrefix_.clear();
}
const bool bCreateSingleFile = bCheckSingleFile_;
+ const OUString sDescriptorPrefix = sPrefix_;
// Setup for dumping debugging documents
static const char *sMaxDumpDocs = nullptr;
@@ -1351,7 +1354,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// create a new temporary file name - only done once in case of bCreateSingleFile
if( bNeedsTempFiles && ( !bWorkDocInitialized || !bCreateSingleFile ))
{
- OUString sPrefix = rMergeDescriptor.sPrefix;
+ OUString sPrefix = sDescriptorPrefix;
OUString sLeading;
//#i97667# if the name is from a database field then it will be used _as is_
@@ -1595,11 +1598,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// save merged document
assert( aTempFile.get() );
INetURLObject aTempFileURL;
- if( rMergeDescriptor.sPrefix.isEmpty() || !rMergeDescriptor.bPrefixIsFilename )
+ if (sDescriptorPrefix.isEmpty() || !rMergeDescriptor.bPrefixIsFilename)
aTempFileURL.SetURL( aTempFile->GetURL() );
else
{
- aTempFileURL.SetURL( rMergeDescriptor.sPrefix );
+ aTempFileURL.SetURL(sDescriptorPrefix);
// remove the unneeded temporary file
aTempFile->EnableKillingFile();
}
commit c9ac66ddcf8bfa135bbd17b0fbb4e6afdcfc3335
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Wed Jul 4 01:33:38 2018 +1000
tdf#116543: don't forget to commit registrations in DB field editor
This avoids revoking the uncommitted registration when any mailmerge
doc is destroyed.
Also don't forget to pass relevant SwDocShell when registering data
source. This allows to register the data source for current document.
Change-Id: Id89be82b0120661700e9fee6a075e5877d76e3b0
Reviewed-on: https://gerrit.libreoffice.org/56891
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/57104
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Aron Budea <aron.budea at collabora.com>
diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index cb2763b475a6..4c823118ae3a 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -24,6 +24,7 @@
#include <dbfld.hxx>
#include <fldtdlg.hxx>
#include <numrule.hxx>
+#include <doc.hxx>
#include "flddb.hxx"
#include <dbconfig.hxx>
@@ -78,6 +79,14 @@ SwFieldDBPage::~SwFieldDBPage()
void SwFieldDBPage::dispose()
{
+ SwWrtShell* pSh = GetWrtShell();
+ if (!pSh)
+ pSh = ::GetActiveWrtShell();
+ // This would cleanup in the case of cancelled dialog
+ SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager();
+ if (pDbManager)
+ pDbManager->RevokeLastRegistrations();
+
m_pTypeLB.clear();
m_pDatabaseTLB.clear();
m_pAddDBPB.clear();
@@ -208,6 +217,10 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
if(!pSh)
pSh = ::GetActiveWrtShell();
+ SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager();
+ if (pDbManager)
+ pDbManager->CommitLastRegistrations();
+
if (aData.sDataSource.isEmpty())
aData = pSh->GetDBData();
@@ -477,7 +490,11 @@ IMPL_LINK( SwFieldDBPage, TreeSelectHdl, SvTreeListBox *, pBox, void )
IMPL_LINK_NOARG(SwFieldDBPage, AddDBHdl, Button*, void)
{
- OUString sNewDB = SwDBManager::LoadAndRegisterDataSource(this);
+ SwWrtShell* pSh = GetWrtShell();
+ if (!pSh)
+ pSh = ::GetActiveWrtShell();
+
+ OUString sNewDB = SwDBManager::LoadAndRegisterDataSource(this, pSh->GetDoc()->GetDocShell());
if(!sNewDB.isEmpty())
{
m_pDatabaseTLB->AddDataSource(sNewDB);
More information about the Libreoffice-commits
mailing list