GUI: fix crash when adding+moving column in restable

This commit is contained in:
Jean-Francois Dockes 2011-03-03 12:39:32 +01:00
parent 3bbcf6d54d
commit bd472c71ab
3 changed files with 33 additions and 39 deletions

View File

@ -194,7 +194,7 @@ RecollModel::RecollModel(const QStringList fields, QObject *parent)
for (QStringList::const_iterator it = fields.begin();
it != fields.end(); it++) {
m_fields.push_back((const char *)(it->toUtf8()));
m_getters.push_back(chooseGetter(m_fields[m_fields.size()-1]));
m_getters.push_back(chooseGetter(m_fields.back()));
}
g_hiliter.set_inputhtml(false);
@ -397,7 +397,7 @@ void ResTable::init()
header->setSortIndicator(-1, Qt::AscendingOrder);
header->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header, SIGNAL(sectionResized(int,int,int)),
this, SLOT(saveColWidths()));
this, SLOT(saveColState()));
connect(header, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(createHeaderPopupMenu(const QPoint&)));
}
@ -443,38 +443,27 @@ void ResTable::saveColState()
settings.setValue("resTableSplitterSizes", splitter->saveState());
QHeaderView *header = tableView->horizontalHeader();
if (header && header->sectionsMoved()) {
// Remember the current column order. Walk in visual order and
// create new list
QStringList newfields;
vector<int> newwidths;
for (int vi = 0; vi < header->count(); vi++) {
int li = header->logicalIndex(vi);
newfields.push_back(prefs.restableFields.at(li));
newwidths.push_back(header->sectionSize(li));
}
prefs.restableFields = newfields;
prefs.restableColWidths = newwidths;
} else {
const vector<string>& vf = m_model->getFields();
prefs.restableFields.clear();
for (int i = 0; i < int(vf.size()); i++) {
prefs.restableFields.push_back(QString::fromUtf8(vf[i].c_str()));
}
saveColWidths();
}
}
void ResTable::saveColWidths()
{
LOGDEB(("ResTable::saveColWidths()\n"));
QHeaderView *header = tableView->horizontalHeader();
if (!header)
const vector<string>& vf = m_model->getFields();
if (!header) {
LOGERR(("ResTable::saveColState: no table header ??\n"));
return;
prefs.restableColWidths.clear();
for (int i = 0; i < header->count(); i++) {
prefs.restableColWidths.push_back(header->sectionSize(i));
}
// Remember the current column order. Walk in visual order and
// create new list
QStringList newfields;
vector<int> newwidths;
for (int vi = 0; vi < header->count(); vi++) {
int li = header->logicalIndex(vi);
if (li < 0 || li >= int(vf.size())) {
LOGERR(("saveColState: logical index beyond list size!\n"));
continue;
}
newfields.push_back(QString::fromUtf8(vf[li].c_str()));
newwidths.push_back(header->sectionSize(li));
}
prefs.restableFields = newfields;
prefs.restableColWidths = newwidths;
}
void ResTable::onTableView_currentChanged(const QModelIndex& index)

View File

@ -96,13 +96,12 @@ public:
virtual ~ResTable() {}
virtual RecollModel *getModel() {return m_model;}
virtual void saveColState();
public slots:
virtual void onTableView_currentChanged(const QModelIndex&);
virtual void on_tableView_entered(const QModelIndex& index);
virtual void saveColWidths();
virtual void setDocSource(RefCntr<DocSequence> nsource);
virtual void saveColState();
virtual void resetSource();
virtual void readDocSource(bool resetPos = true);
virtual void onSortDataChanged(DocSeqSortSpec);

View File

@ -81,11 +81,17 @@
<h2><a name="b_1_15_2">recoll 1.15.2</a></h2>
<ul>
<li>Clicking one of the category filter checkboxes (one of the
media/message/text/... things) with an empty result list crashes
the GUI (just like this, yeah, I know, quality insurance
etc.). Workaround: don't click these before running the first
query.</li>
<li>If a result table column is both added and moved in the same
GUI instance, the list becomes garbled (or/and the GUI
crashes). Workaround: remove the Qt GUI config
(.config/Recoll.org/recoll.conf), and perform the operation in 2 GUI
sessions: add column, exit recoll, restart, move column.</li>
<li>Clicking one of the category filter checkboxes
(one of the media/message/text/... things) with an empty result
list crashes the GUI (just like this, yeah, I know, quality
insurance etc.). Workaround: don't click these before running the
first query.</li>
<li>Changing the indexing configuration parameters from the GUI
while the indexing thread (not an external recollindex command) is