mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Audit all the LASSERT calls, and try to do something sensible at
each failure. There are several places I was not sure what to do. These are marked by comments beginning "LASSERT:" so they can be found easily. At the moment, they are at: Author.cpp:105: // LASSERT: What should we do here? Author.cpp:121: // LASSERT: What should we do here? Buffer.cpp:4525: // LASSERT: Is it safe to continue here, or should we just return? Cursor.cpp:345: // LASSERT: Is it safe to continue here, or should we return? Cursor.cpp:403: // LASSERT: Is it safe to continue here, or should we return? Cursor.cpp:1143: // LASSERT: There have been several bugs around this code, that seem CursorSlice.cpp:83: // LASSERT: This should only ever be called from an InsetMath. CursorSlice.cpp:92: // LASSERT: This should only ever be called from an InsetMath. LayoutFile.cpp:303: // LASSERT: Why would this fail? Text.cpp:995: // LASSERT: Is it safe to continue here?
This commit is contained in:
parent
62df59cde4
commit
1b1f8dd235
@ -361,7 +361,7 @@ SpellChecker::Result AspellChecker::Private::check(
|
||||
for (; result == WORD_OK;) {
|
||||
string const word_str = toAspellWord(w1);
|
||||
int const word_ok = aspell_speller_check(m, word_str.c_str(), -1);
|
||||
LASSERT(word_ok != -1, /**/);
|
||||
LASSERT(word_ok != -1, return UNKNOWN_WORD);
|
||||
result = (word_ok) ? WORD_OK : UNKNOWN_WORD;
|
||||
if (rest.empty())
|
||||
break;
|
||||
@ -371,7 +371,7 @@ SpellChecker::Result AspellChecker::Private::check(
|
||||
return result;
|
||||
string const word_str = toAspellWord(word.word());
|
||||
int const word_ok = aspell_speller_check(m, word_str.c_str(), -1);
|
||||
LASSERT(word_ok != -1, /**/);
|
||||
LASSERT(word_ok != -1, return UNKNOWN_WORD);
|
||||
return (word_ok) ? WORD_OK : UNKNOWN_WORD;
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ void AspellChecker::suggest(WordLangTuple const & wl,
|
||||
string const word = d->toAspellWord(wl.word());
|
||||
AspellWordList const * sugs =
|
||||
aspell_speller_suggest(m, word.c_str(), -1);
|
||||
LASSERT(sugs != 0, /**/);
|
||||
LASSERT(sugs != 0, return);
|
||||
AspellStringEnumeration * els = aspell_word_list_elements(sugs);
|
||||
if (!els || aspell_word_list_empty(sugs))
|
||||
return;
|
||||
|
@ -102,6 +102,7 @@ int AuthorList::record(Author const & a)
|
||||
|
||||
void AuthorList::record(int id, Author const & a)
|
||||
{
|
||||
// LASSERT: What should we do here?
|
||||
LASSERT(unsigned(id) < authors_.size(), /**/);
|
||||
|
||||
authors_[id] = a;
|
||||
@ -117,6 +118,7 @@ void AuthorList::recordCurrentAuthor(Author const & a)
|
||||
|
||||
Author const & AuthorList::get(int id) const
|
||||
{
|
||||
// LASSERT: What should we do here?
|
||||
LASSERT(id < (int)authors_.size() , /**/);
|
||||
return authors_[id];
|
||||
}
|
||||
|
@ -370,9 +370,10 @@ string parseEmbeddedOption(string const & format, string & ifelsepart)
|
||||
LYXERR0("ERROR! Couldn't parse `" << format <<"'.");
|
||||
return format;
|
||||
}
|
||||
LASSERT(rest.size() <= format.size(), /* */);
|
||||
LASSERT(rest.size() <= format.size(),
|
||||
{ ifelsepart = ""; return format; });
|
||||
ifelsepart = format.substr(0, format.size() - rest.size());
|
||||
return rest;
|
||||
return rest;
|
||||
}
|
||||
|
||||
|
||||
|
@ -452,13 +452,17 @@ Buffer::~Buffer()
|
||||
// if we're the master buffer, then we should get rid of the list
|
||||
// of clones
|
||||
if (!parent()) {
|
||||
// if this is not empty, we have leaked something. worse, one of the
|
||||
// children still has a reference to this list.
|
||||
LASSERT(d->clone_list_->empty(), /* */);
|
||||
// If this is not empty, we have leaked something. Worse, one of the
|
||||
// children still has a reference to this list. But we will try to
|
||||
// continue, rather than shut down.
|
||||
LATTEST(d->clone_list_->empty());
|
||||
list<CloneList *>::iterator it =
|
||||
find(cloned_buffers.begin(), cloned_buffers.end(), d->clone_list_);
|
||||
LASSERT(it != cloned_buffers.end(), /* */);
|
||||
cloned_buffers.erase(it);
|
||||
if (it == cloned_buffers.end()) {
|
||||
// We will leak in this case, but it is safe to continue.
|
||||
LATTEST(false);
|
||||
} else
|
||||
cloned_buffers.erase(it);
|
||||
delete d->clone_list_;
|
||||
}
|
||||
// FIXME Do we really need to do this right before we delete d?
|
||||
@ -603,7 +607,7 @@ void Buffer::changed(bool update_metrics) const
|
||||
|
||||
frontend::WorkAreaManager & Buffer::workAreaManager() const
|
||||
{
|
||||
LASSERT(d->wa_, /**/);
|
||||
LBUFERR(d->wa_, _("Unable to find WorkArea for Buffer!"));
|
||||
return *d->wa_;
|
||||
}
|
||||
|
||||
@ -2600,8 +2604,8 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
|
||||
|
||||
void Buffer::changeLanguage(Language const * from, Language const * to)
|
||||
{
|
||||
LASSERT(from, /**/);
|
||||
LASSERT(to, /**/);
|
||||
LASSERT(from, return);
|
||||
LASSERT(to, return);
|
||||
|
||||
for_each(par_iterator_begin(),
|
||||
par_iterator_end(),
|
||||
@ -2712,7 +2716,7 @@ bool Buffer::isClean() const
|
||||
|
||||
bool Buffer::isExternallyModified(CheckMethod method) const
|
||||
{
|
||||
LASSERT(d->filename.exists(), /**/);
|
||||
LASSERT(d->filename.exists(), return false);
|
||||
// if method == timestamp, check timestamp before checksum
|
||||
return (method == checksum_method
|
||||
|| d->timestamp_ != d->filename.lastModified())
|
||||
@ -4252,6 +4256,8 @@ void Buffer::setBuffersForInsets() const
|
||||
|
||||
void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
|
||||
{
|
||||
LBUFERR(!text().paragraphs().empty(), _("Buffer error"));
|
||||
|
||||
// Use the master text class also for child documents
|
||||
Buffer const * const master = masterBuffer();
|
||||
DocumentClass const & textclass = master->params().documentClass();
|
||||
@ -4292,8 +4298,6 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
|
||||
|
||||
Buffer & cbuf = const_cast<Buffer &>(*this);
|
||||
|
||||
LASSERT(!text().paragraphs().empty(), /**/);
|
||||
|
||||
// do the real work
|
||||
ParIterator parit = cbuf.par_iterator_begin();
|
||||
updateBuffer(parit, utype);
|
||||
@ -4365,7 +4369,7 @@ static depth_type getItemDepth(ParIterator const & it)
|
||||
static bool needEnumCounterReset(ParIterator const & it)
|
||||
{
|
||||
Paragraph const & par = *it;
|
||||
LASSERT(par.layout().labeltype == LABEL_ENUMERATE, /**/);
|
||||
LASSERT(par.layout().labeltype == LABEL_ENUMERATE, return false);
|
||||
depth_type const cur_depth = par.getDepth();
|
||||
ParIterator prev_it = it;
|
||||
while (prev_it.pit()) {
|
||||
@ -4518,6 +4522,7 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
|
||||
|
||||
void Buffer::updateBuffer(ParIterator & parit, UpdateType utype) const
|
||||
{
|
||||
// LASSERT: Is it safe to continue here, or should we just return?
|
||||
LASSERT(parit.pit() == 0, /**/);
|
||||
|
||||
// Set the position of the text in the buffer to be able
|
||||
|
@ -92,13 +92,15 @@ BufferList::const_iterator BufferList::end() const
|
||||
|
||||
void BufferList::release(Buffer * buf)
|
||||
{
|
||||
LASSERT(buf, /**/);
|
||||
// We may leak here, but we probably do not need to
|
||||
// shut down.
|
||||
LASSERT(buf, return);
|
||||
BufferStorage::iterator const it =
|
||||
find(bstore.begin(), bstore.end(), buf);
|
||||
if (it != bstore.end()) {
|
||||
Buffer * tmp = (*it);
|
||||
LASSERT(tmp, /**/);
|
||||
bstore.erase(it);
|
||||
LASSERT(tmp, return);
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
@ -192,13 +194,14 @@ Buffer * BufferList::getBuffer(unsigned int choice)
|
||||
|
||||
Buffer * BufferList::next(Buffer const * buf) const
|
||||
{
|
||||
LASSERT(buf, /**/);
|
||||
// Something is wrong, but we can probably survive it.
|
||||
LASSERT(buf, return 0);
|
||||
|
||||
if (bstore.empty())
|
||||
return 0;
|
||||
BufferStorage::const_iterator it =
|
||||
find(bstore.begin(), bstore.end(), buf);
|
||||
LASSERT(it != bstore.end(), /**/);
|
||||
LASSERT(it != bstore.end(), return 0);
|
||||
++it;
|
||||
Buffer * nextbuf = (it == bstore.end()) ? bstore.front() : *it;
|
||||
return nextbuf;
|
||||
@ -207,13 +210,14 @@ Buffer * BufferList::next(Buffer const * buf) const
|
||||
|
||||
Buffer * BufferList::previous(Buffer const * buf) const
|
||||
{
|
||||
LASSERT(buf, /**/);
|
||||
// Something is wrong, but we can probably survive it.
|
||||
LASSERT(buf, return 0);
|
||||
|
||||
if (bstore.empty())
|
||||
return 0;
|
||||
BufferStorage::const_iterator it =
|
||||
find(bstore.begin(), bstore.end(), buf);
|
||||
LASSERT(it != bstore.end(), /**/);
|
||||
LASSERT(it != bstore.end(), return 0);
|
||||
|
||||
Buffer * previousbuf = (it == bstore.begin()) ? bstore.back() : *(it - 1);
|
||||
return previousbuf;
|
||||
|
@ -335,8 +335,7 @@ BufferParams::Impl::Impl()
|
||||
BufferParams::Impl *
|
||||
BufferParams::MemoryTraits::clone(BufferParams::Impl const * ptr)
|
||||
{
|
||||
LASSERT(ptr, /**/);
|
||||
|
||||
LBUFERR(ptr, _("Attempting to clone non-existent BufferParams!"));
|
||||
return new BufferParams::Impl(*ptr);
|
||||
}
|
||||
|
||||
@ -423,7 +422,7 @@ BufferParams::BufferParams()
|
||||
|
||||
docstring BufferParams::B_(string const & l10n) const
|
||||
{
|
||||
LASSERT(language, /**/);
|
||||
LASSERT(language, return from_utf8(l10n));
|
||||
return getMessages(language->code()).get(l10n);
|
||||
}
|
||||
|
||||
@ -511,28 +510,28 @@ IndicesList const & BufferParams::indiceslist() const
|
||||
|
||||
Bullet & BufferParams::temp_bullet(lyx::size_type const index)
|
||||
{
|
||||
LASSERT(index < 4, /**/);
|
||||
LASSERT(index < 4, return pimpl_->temp_bullets[0]);
|
||||
return pimpl_->temp_bullets[index];
|
||||
}
|
||||
|
||||
|
||||
Bullet const & BufferParams::temp_bullet(lyx::size_type const index) const
|
||||
{
|
||||
LASSERT(index < 4, /**/);
|
||||
LASSERT(index < 4, return pimpl_->temp_bullets[0]);
|
||||
return pimpl_->temp_bullets[index];
|
||||
}
|
||||
|
||||
|
||||
Bullet & BufferParams::user_defined_bullet(lyx::size_type const index)
|
||||
{
|
||||
LASSERT(index < 4, /**/);
|
||||
LASSERT(index < 4, return pimpl_->temp_bullets[0]);
|
||||
return pimpl_->user_defined_bullets[index];
|
||||
}
|
||||
|
||||
|
||||
Bullet const & BufferParams::user_defined_bullet(lyx::size_type const index) const
|
||||
{
|
||||
LASSERT(index < 4, /**/);
|
||||
LASSERT(index < 4, return pimpl_->temp_bullets[0]);
|
||||
return pimpl_->user_defined_bullets[index];
|
||||
}
|
||||
|
||||
|
@ -876,7 +876,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter)
|
||||
|
||||
if (tm.contains(bot_pit)) {
|
||||
ParagraphMetrics const & pm = tm.parMetrics(bot_pit);
|
||||
LASSERT(!pm.rows().empty(), /**/);
|
||||
LBUFERR(!pm.rows().empty(), _(""));
|
||||
// FIXME: smooth scrolling doesn't work in mathed.
|
||||
CursorSlice const & cs = dit.innerTextSlice();
|
||||
int offset = coordOffset(dit).y_;
|
||||
@ -2169,7 +2169,7 @@ void BufferView::clearLastInset(Inset * inset) const
|
||||
{
|
||||
if (d->last_inset_ != inset) {
|
||||
LYXERR0("Wrong last_inset!");
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
}
|
||||
d->last_inset_ = 0;
|
||||
}
|
||||
@ -2401,7 +2401,7 @@ TextMetrics const & BufferView::textMetrics(Text const * t) const
|
||||
|
||||
TextMetrics & BufferView::textMetrics(Text const * t)
|
||||
{
|
||||
LASSERT(t, /**/);
|
||||
LBUFERR(t, _(""));
|
||||
TextMetricsCache::iterator tmc_it = d->text_metrics_.find(t);
|
||||
if (tmc_it == d->text_metrics_.end()) {
|
||||
tmc_it = d->text_metrics_.insert(
|
||||
@ -2467,7 +2467,7 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old)
|
||||
|
||||
bool BufferView::mouseSetCursor(Cursor & cur, bool select)
|
||||
{
|
||||
LASSERT(&cur.bv() == this, /**/);
|
||||
LASSERT(&cur.bv() == this, return false);
|
||||
|
||||
if (!select)
|
||||
// this event will clear selection so we save selection for
|
||||
@ -2708,7 +2708,7 @@ void BufferView::updateMetrics()
|
||||
|
||||
void BufferView::insertLyXFile(FileName const & fname)
|
||||
{
|
||||
LASSERT(d->cursor_.inTexted(), /**/);
|
||||
LASSERT(d->cursor_.inTexted(), return);
|
||||
|
||||
// Get absolute path of file and add ".lyx"
|
||||
// to the filename if necessary
|
||||
@ -2791,7 +2791,8 @@ Point BufferView::coordOffset(DocIterator const & dit) const
|
||||
CursorSlice const & sl = dit[0];
|
||||
TextMetrics const & tm = textMetrics(sl.text());
|
||||
ParagraphMetrics const & pm = tm.parMetrics(sl.pit());
|
||||
LASSERT(!pm.rows().empty(), /**/);
|
||||
|
||||
LBUFERR(!pm.rows().empty(), _(""));
|
||||
y -= pm.rows()[0].ascent();
|
||||
#if 1
|
||||
// FIXME: document this mess
|
||||
|
@ -348,25 +348,25 @@ docstring const Bullet::bulletEntry(int f, int c)
|
||||
void Bullet::testInvariant() const
|
||||
{
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
LASSERT(font >= MIN, /**/);
|
||||
LASSERT(font < FONTMAX, /**/);
|
||||
LASSERT(character >= MIN, /**/);
|
||||
LASSERT(character < CHARMAX, /**/);
|
||||
LASSERT(size >= MIN, /**/);
|
||||
LASSERT(size < SIZEMAX, /**/);
|
||||
LASSERT(user_text >= -1, /**/);
|
||||
LASSERT(user_text <= 1, /**/);
|
||||
LATTEST(font >= MIN);
|
||||
LATTEST(font < FONTMAX);
|
||||
LATTEST(character >= MIN);
|
||||
LATTEST(character < CHARMAX);
|
||||
LATTEST(size >= MIN);
|
||||
LATTEST(size < SIZEMAX);
|
||||
LATTEST(user_text >= -1);
|
||||
LATTEST(user_text <= 1);
|
||||
// now some relational/operational tests
|
||||
if (user_text == 1) {
|
||||
LASSERT(font == -1 && (character == -1 && size == -1), /**/);
|
||||
// LASSERT(!text.empty(), /**/); // this isn't necessarily an error
|
||||
LATTEST(font == -1 && (character == -1 && size == -1));
|
||||
// LATTEST(!text.empty()); // this isn't necessarily an error
|
||||
}
|
||||
// else if (user_text == -1) {
|
||||
// LASSERT(!text.empty(), /**/); // this also isn't necessarily an error
|
||||
// LATTEST(!text.empty()); // this also isn't necessarily an error
|
||||
// }
|
||||
// else {
|
||||
// // user_text == 0
|
||||
// LASSERT(text.empty(), /**/); // not usually true
|
||||
// LATTEST(text.empty()); // not usually true
|
||||
// }
|
||||
#endif
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ string const X11hexname(RGBColor const & col)
|
||||
RGBColor rgbFromHexName(string const & x11hexname)
|
||||
{
|
||||
RGBColor c;
|
||||
LASSERT(x11hexname.size() == 7 && x11hexname[0] == '#', /**/);
|
||||
LASSERT(x11hexname.size() == 7 && x11hexname[0] == '#',
|
||||
return c);
|
||||
c.r = hexstrToInt(x11hexname.substr(1, 2));
|
||||
c.g = hexstrToInt(x11hexname.substr(3, 2));
|
||||
c.b = hexstrToInt(x11hexname.substr(5, 2));
|
||||
|
@ -602,7 +602,7 @@ Compare::Impl::SnakeResult Compare::Impl::retrieveMiddleSnake(
|
||||
if (os[k].empty() && os_r[kk].empty()) {
|
||||
// No, there is no snake at all, in which case
|
||||
// the length of the shortest edit script is M+N.
|
||||
LASSERT(2 * D - odd_offset_ == M_ + N_, /**/);
|
||||
LATTEST(2 * D - odd_offset_ == M_ + N_);
|
||||
return NoSnake;
|
||||
}
|
||||
|
||||
@ -822,7 +822,7 @@ void Compare::Impl::processSnake(DocRangePair const & rp)
|
||||
pit_type const pit = it.o.pit() - rp.o.from.pit();
|
||||
pos_type const pos = pit ? it.o.pos() : it.o.pos() - rp.o.from.pos();
|
||||
inset = pars[pit].getInset(pos);
|
||||
LASSERT(inset, /**/);
|
||||
LASSERT(inset, continue);
|
||||
diffInset(inset, it);
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ FileName const & ConverterCache::cacheName(FileName const & orig_from,
|
||||
LYXERR(Debug::FILES, orig_from << ' ' << to_format);
|
||||
|
||||
CacheItem * const item = pimpl_->find(orig_from, to_format);
|
||||
LASSERT(item, /**/);
|
||||
LASSERT(item, { static const FileName fn; return fn; });
|
||||
return item->cache_name;
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ bool ConverterCache::copy(FileName const & orig_from, string const & to_format,
|
||||
}
|
||||
|
||||
CacheItem * const item = pimpl_->find(orig_from, to_format);
|
||||
LASSERT(item, /**/);
|
||||
LASSERT(item, return false);
|
||||
Mover const & mover = getMover(to_format);
|
||||
return mover.copy(item->cache_name, dest,
|
||||
onlyFileName(dest.absFileName()));
|
||||
|
@ -26,10 +26,10 @@ namespace lyx {
|
||||
Point::Point(int x, int y)
|
||||
: x_(x), y_(y)
|
||||
{
|
||||
LASSERT(x > -1000000, /**/);
|
||||
LASSERT(x < 1000000, /**/);
|
||||
LASSERT(y > -1000000, /**/);
|
||||
LASSERT(y < 1000000, /**/);
|
||||
LASSERT(x > -1000000, x = -1000000);
|
||||
LASSERT(x < 1000000, x = 1000000);
|
||||
LASSERT(y > -1000000, y = -1000000);
|
||||
LASSERT(y < 1000000, y = 1000000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,7 +261,7 @@ void Counters::step(docstring const & ctr, UpdateType utype)
|
||||
|
||||
it->second.step();
|
||||
if (utype == OutputUpdate) {
|
||||
LASSERT(!counter_stack_.empty(), /* */);
|
||||
LBUFERR(!counter_stack_.empty(), _("Empty counter stack!"));
|
||||
counter_stack_.pop_back();
|
||||
counter_stack_.push_back(ctr);
|
||||
}
|
||||
@ -293,7 +293,7 @@ void Counters::reset()
|
||||
|
||||
void Counters::reset(docstring const & match)
|
||||
{
|
||||
LASSERT(!match.empty(), /**/);
|
||||
LASSERT(!match.empty(), return);
|
||||
|
||||
CounterList::iterator it = counterList_.begin();
|
||||
CounterList::iterator end = counterList_.end();
|
||||
@ -597,7 +597,7 @@ docstring Counters::prettyCounter(docstring const & name,
|
||||
|
||||
docstring Counters::currentCounter() const
|
||||
{
|
||||
LASSERT(!counter_stack_.empty(), /* */);
|
||||
LBUFERR(!counter_stack_.empty(), _("Empty counter stack!"));
|
||||
return counter_stack_.back();
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,11 @@
|
||||
#include "TextMetrics.h"
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include "insets/InsetTabular.h"
|
||||
#include "insets/InsetText.h"
|
||||
@ -340,6 +342,7 @@ bool Cursor::getStatus(FuncRequest const & cmd, FuncStatus & status) const
|
||||
bool res = false;
|
||||
for ( ; cur.depth(); cur.pop()) {
|
||||
//lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
|
||||
// LASSERT: Is it safe to continue here, or should we return?
|
||||
LASSERT(cur.idx() <= cur.lastidx(), /**/);
|
||||
LASSERT(cur.pit() <= cur.lastpit(), /**/);
|
||||
LASSERT(cur.pos() <= cur.lastpos(), /**/);
|
||||
@ -397,6 +400,7 @@ void Cursor::dispatch(FuncRequest const & cmd0)
|
||||
for (; depth(); pop(), boundary(false)) {
|
||||
LYXERR(Debug::DEBUG, "Cursor::dispatch: cmd: "
|
||||
<< cmd0 << endl << *this);
|
||||
// LASSERT: Is it safe to continue here, or should we return?
|
||||
LASSERT(pos() <= lastpos(), /**/);
|
||||
LASSERT(idx() <= lastidx(), /**/);
|
||||
LASSERT(pit() <= lastpit(), /**/);
|
||||
@ -456,14 +460,14 @@ DispatchResult const & Cursor::result() const
|
||||
|
||||
BufferView & Cursor::bv() const
|
||||
{
|
||||
LASSERT(bv_, /**/);
|
||||
LBUFERR(bv_, _("Cursor has no BufferView!"));
|
||||
return *bv_;
|
||||
}
|
||||
|
||||
|
||||
void Cursor::pop()
|
||||
{
|
||||
LASSERT(depth() >= 1, /**/);
|
||||
LBUFERR(depth() >= 1, _("Attempt to pop empty cursor!"));
|
||||
pop_back();
|
||||
}
|
||||
|
||||
@ -509,7 +513,7 @@ bool Cursor::popForward()
|
||||
|
||||
int Cursor::currentMode()
|
||||
{
|
||||
LASSERT(!empty(), /**/);
|
||||
LASSERT(!empty(), return Inset::UNDECIDED_MODE);
|
||||
for (int i = depth() - 1; i >= 0; --i) {
|
||||
int res = operator[](i).inset().currentMode();
|
||||
bool locked_mode = operator[](i).inset().lockedMode();
|
||||
@ -534,7 +538,6 @@ Row const & Cursor::textRow() const
|
||||
{
|
||||
CursorSlice const & cs = innerTextSlice();
|
||||
ParagraphMetrics const & pm = bv().parMetrics(cs.text(), cs.pit());
|
||||
LASSERT(!pm.rows().empty(), /**/);
|
||||
return pm.getRow(pos(), boundary());
|
||||
}
|
||||
|
||||
@ -1136,7 +1139,14 @@ CursorSlice Cursor::normalAnchor() const
|
||||
{
|
||||
if (!selection())
|
||||
return top();
|
||||
LASSERT(anchor_.depth() >= depth(), /**/);
|
||||
if (anchor_.depth() >= depth()) {
|
||||
// LASSERT: There have been several bugs around this code, that seem
|
||||
// to involve failures to reset the anchor. We can at least not crash
|
||||
// in release mode by resetting it ourselves.
|
||||
LASSERT(false, /* */);
|
||||
DocIterator & di = const_cast<DocIterator &>(anchor_);
|
||||
di = *this;
|
||||
}
|
||||
CursorSlice normal = anchor_[depth() - 1];
|
||||
if (depth() < anchor_.depth() && top() <= normal) {
|
||||
// anchor is behind cursor -> move anchor behind the inset
|
||||
@ -1437,7 +1447,7 @@ void Cursor::insert(docstring const & str)
|
||||
void Cursor::insert(char_type c)
|
||||
{
|
||||
//lyxerr << "Cursor::insert char '" << c << "'" << endl;
|
||||
LASSERT(!empty(), /**/);
|
||||
LASSERT(!empty(), return);
|
||||
if (inMathed()) {
|
||||
cap::selClearOrDel(*this);
|
||||
insert(new InsetMathChar(c));
|
||||
@ -1458,7 +1468,7 @@ void Cursor::insert(MathAtom const & t)
|
||||
|
||||
void Cursor::insert(Inset * inset0)
|
||||
{
|
||||
LASSERT(inset0, /**/);
|
||||
LASSERT(inset0, return);
|
||||
if (inMathed())
|
||||
insert(MathAtom(inset0->asInsetMath()));
|
||||
else {
|
||||
@ -1962,7 +1972,7 @@ bool Cursor::atFirstOrLastRow(bool up)
|
||||
|
||||
bool Cursor::upDownInText(bool up, bool & updateNeeded)
|
||||
{
|
||||
LASSERT(text(), /**/);
|
||||
LASSERT(text(), return false);
|
||||
|
||||
// where are we?
|
||||
int xo = 0;
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "mathed/InsetMath.h"
|
||||
#include "mathed/MathMacro.h"
|
||||
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include <ostream>
|
||||
@ -42,7 +44,7 @@ CursorSlice::CursorSlice()
|
||||
CursorSlice::CursorSlice(Inset & p)
|
||||
: inset_(&p), idx_(0), pit_(0), pos_(0)
|
||||
{
|
||||
LASSERT(inset_, /**/);
|
||||
LBUFERR(inset_, _("Invalid initialization of CursorSlice!"));
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +62,7 @@ Paragraph & CursorSlice::paragraph() const
|
||||
|
||||
pos_type CursorSlice::lastpos() const
|
||||
{
|
||||
LASSERT(inset_, /**/);
|
||||
LBUFERR(inset_, _("Cursor slice not properly initialized!"));
|
||||
InsetMath const * math = inset_->asInsetMath();
|
||||
bool paramless_macro = math && math->asMacro() && !math->asMacro()->nargs();
|
||||
return math ? (paramless_macro ? 0 : cell().size())
|
||||
@ -78,6 +80,8 @@ pit_type CursorSlice::lastpit() const
|
||||
|
||||
CursorSlice::row_type CursorSlice::row() const
|
||||
{
|
||||
// LASSERT: This should only ever be called from an InsetMath.
|
||||
// Should we crash in release mode, though, or try to continue?
|
||||
LASSERT(asInsetMath(), /**/);
|
||||
return asInsetMath()->row(idx_);
|
||||
}
|
||||
@ -85,6 +89,8 @@ CursorSlice::row_type CursorSlice::row() const
|
||||
|
||||
CursorSlice::col_type CursorSlice::col() const
|
||||
{
|
||||
// LASSERT: This should only ever be called from an InsetMath.
|
||||
// Should we crash in release mode, though, or try to continue?
|
||||
LASSERT(asInsetMath(), /**/);
|
||||
return asInsetMath()->col(idx_);
|
||||
}
|
||||
@ -110,7 +116,7 @@ void CursorSlice::forwardPos()
|
||||
// otherwise move on one cell
|
||||
//lyxerr << "... next idx" << endl;
|
||||
|
||||
LASSERT(idx_ < nargs(), /**/);
|
||||
LASSERT(idx_ < nargs(), return);
|
||||
|
||||
++idx_;
|
||||
pit_ = 0;
|
||||
@ -120,7 +126,7 @@ void CursorSlice::forwardPos()
|
||||
|
||||
void CursorSlice::forwardIdx()
|
||||
{
|
||||
LASSERT(idx_ < nargs(), /**/);
|
||||
LASSERT(idx_ < nargs(), return);
|
||||
|
||||
++idx_;
|
||||
pit_ = 0;
|
||||
@ -148,7 +154,7 @@ void CursorSlice::backwardPos()
|
||||
return;
|
||||
}
|
||||
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
}
|
||||
|
||||
|
||||
@ -187,7 +193,8 @@ bool operator<(CursorSlice const & p, CursorSlice const & q)
|
||||
if (p.inset_ != q.inset_) {
|
||||
LYXERR0("can't compare cursor and anchor in different insets\n"
|
||||
<< "p: " << p << '\n' << "q: " << q);
|
||||
LASSERT(false, /**/);
|
||||
// It should be safe to continue, just registering the error.
|
||||
LASSERT(false, return false);
|
||||
}
|
||||
if (p.idx_ != q.idx_)
|
||||
return p.idx_ < q.idx_;
|
||||
|
@ -551,9 +551,12 @@ void copySelectionHelper(Buffer const & buf, Text const & text,
|
||||
{
|
||||
ParagraphList const & pars = text.paragraphs();
|
||||
|
||||
LASSERT(0 <= start && start <= pars[startpit].size(), /**/);
|
||||
LASSERT(0 <= end && end <= pars[endpit].size(), /**/);
|
||||
LASSERT(startpit != endpit || start <= end, /**/);
|
||||
// In most of these cases, we can try to recover.
|
||||
LASSERT(0 <= start, start = 0);
|
||||
LASSERT(start <= pars[startpit].size(), start = pars[startpit].size());
|
||||
LASSERT(0 <= end, end = 0);
|
||||
LASSERT(end <= pars[endpit].size(), end = pars[endpit].size());
|
||||
LASSERT(startpit != endpit || start <= end, return);
|
||||
|
||||
// Clone the paragraphs within the selection.
|
||||
ParagraphList copy_pars(boost::next(pars.begin(), startpit),
|
||||
@ -682,7 +685,7 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
|
||||
{
|
||||
errorlist.clear();
|
||||
|
||||
LASSERT(!in.paragraphs().empty(), /**/);
|
||||
LBUFERR(!in.paragraphs().empty(), _(""));
|
||||
if (oldone == newone)
|
||||
return;
|
||||
|
||||
@ -800,7 +803,7 @@ void cutSelection(Cursor & cur, bool doclear, bool realcut)
|
||||
|
||||
if (cur.inTexted()) {
|
||||
Text * text = cur.text();
|
||||
LASSERT(text, /**/);
|
||||
LBUFERR(text, _("Invalid cursor!"));
|
||||
|
||||
saveSelection(cur);
|
||||
|
||||
@ -909,7 +912,7 @@ void copySelectionToStack(Cursor const & cur, CutStack & cutstack)
|
||||
|
||||
if (cur.inTexted()) {
|
||||
Text * text = cur.text();
|
||||
LASSERT(text, /**/);
|
||||
LBUFERR(text, _("Invalid cursor!"));
|
||||
// ok we have a selection. This is always between cur.selBegin()
|
||||
// and sel_end cursor
|
||||
|
||||
@ -1023,7 +1026,7 @@ void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
||||
{
|
||||
if (cur.inTexted()) {
|
||||
Text * text = cur.text();
|
||||
LASSERT(text, /**/);
|
||||
LBUFERR(text, _("Invalid cursor!"));
|
||||
|
||||
PasteReturnValue prv =
|
||||
pasteSelectionHelper(cur, parlist, docclass, errorList);
|
||||
@ -1034,7 +1037,7 @@ void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
||||
}
|
||||
|
||||
// mathed is handled in InsetMathNest/InsetMathGrid
|
||||
LASSERT(!cur.inMathed(), /**/);
|
||||
LATTEST(!cur.inMathed());
|
||||
}
|
||||
|
||||
|
||||
@ -1162,7 +1165,7 @@ void pasteSimpleText(Cursor & cur, bool asParagraphs)
|
||||
void pasteClipboardGraphics(Cursor & cur, ErrorList & /* errorList */,
|
||||
Clipboard::GraphicsType preferedType)
|
||||
{
|
||||
LASSERT(theClipboard().hasGraphicsContents(preferedType), /**/);
|
||||
LASSERT(theClipboard().hasGraphicsContents(preferedType), return);
|
||||
|
||||
// get picture from clipboard
|
||||
FileName filename = theClipboard().getAsGraphics(cur, preferedType);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "insets/InsetTabular.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
@ -80,7 +82,7 @@ DocIterator DocIterator::clone(Buffer * buffer) const
|
||||
DocIterator dit(buffer);
|
||||
size_t const n = slices_.size();
|
||||
for (size_t i = 0 ; i != n; ++i) {
|
||||
LASSERT(inset, /**/);
|
||||
LBUFERR(inset, _("Iterator slice not properly initialized!"));
|
||||
dit.push_back(slices_[i]);
|
||||
dit.top().inset_ = inset;
|
||||
if (i + 1 != n)
|
||||
@ -143,7 +145,7 @@ Inset * DocIterator::prevInset() const
|
||||
|
||||
Inset * DocIterator::realInset() const
|
||||
{
|
||||
LASSERT(inTexted(), /**/);
|
||||
LASSERT(inTexted(), return 0);
|
||||
// if we are in a tabular, we need the cell
|
||||
if (inset().lyxCode() == TABULAR_CODE) {
|
||||
InsetTabular * tabular = inset().asInsetTabular();
|
||||
@ -172,23 +174,24 @@ MathAtom & DocIterator::nextAtom() const
|
||||
|
||||
Text * DocIterator::text() const
|
||||
{
|
||||
LASSERT(!empty(), /**/);
|
||||
LASSERT(!empty(), return 0);
|
||||
return top().text();
|
||||
}
|
||||
|
||||
|
||||
Paragraph & DocIterator::paragraph() const
|
||||
{
|
||||
if (!inTexted())
|
||||
if (!inTexted()) {
|
||||
LYXERR0(*this);
|
||||
LASSERT(inTexted(), /**/);
|
||||
LBUFERR(false, _("DocIterator::paragraph() called outside Text."));
|
||||
}
|
||||
return top().paragraph();
|
||||
}
|
||||
|
||||
|
||||
Paragraph & DocIterator::innerParagraph() const
|
||||
{
|
||||
LASSERT(!empty(), /**/);
|
||||
LBUFERR(!empty(), _("Empty DocIterator."));
|
||||
return innerTextSlice().paragraph();
|
||||
}
|
||||
|
||||
@ -207,7 +210,7 @@ FontSpan DocIterator::locateWord(word_location const loc) const
|
||||
|
||||
CursorSlice const & DocIterator::innerTextSlice() const
|
||||
{
|
||||
LASSERT(!empty(), /**/);
|
||||
LBUFERR(!empty(), _(""));
|
||||
// go up until first non-0 text is hit
|
||||
// (innermost text is 0 in mathed)
|
||||
for (int i = depth() - 1; i >= 0; --i)
|
||||
@ -216,9 +219,10 @@ CursorSlice const & DocIterator::innerTextSlice() const
|
||||
|
||||
// This case is in principe not possible. We _must_
|
||||
// be inside a Text.
|
||||
LASSERT(false, /**/);
|
||||
static CursorSlice dummy;
|
||||
return dummy;
|
||||
LBUFERR(false, _(""));
|
||||
// Squash warning
|
||||
static const CursorSlice c;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
@ -282,7 +286,7 @@ MathData & DocIterator::cell() const
|
||||
|
||||
Text * DocIterator::innerText() const
|
||||
{
|
||||
LASSERT(!empty(), /**/);
|
||||
LASSERT(!empty(), return 0);
|
||||
return innerTextSlice().text();
|
||||
}
|
||||
|
||||
@ -464,7 +468,7 @@ void DocIterator::updateInsets(Inset * inset)
|
||||
size_t const n = slices_.size();
|
||||
slices_.resize(0);
|
||||
for (size_t i = 0 ; i < n; ++i) {
|
||||
LASSERT(inset, /**/);
|
||||
LBUFERR(inset, _("Improperly initialized DocIterator."));
|
||||
push_back(dit[i]);
|
||||
top().inset_ = inset;
|
||||
if (i + 1 != n)
|
||||
|
@ -537,7 +537,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
|
||||
Encoding const * const ascii = encodings.fromLyXName("ascii");
|
||||
pair<bool, int> const c = switchEncoding(os.os(), bparams,
|
||||
runparams, *ascii);
|
||||
LASSERT(c.first, /**/);
|
||||
LATTEST(c.first);
|
||||
count += c.second;
|
||||
runparams.encoding = ascii;
|
||||
open_encoding_ = false;
|
||||
|
@ -96,16 +96,13 @@ string const HSpace::asLatexCommand() const
|
||||
switch (kind_) {
|
||||
case DEFAULT:
|
||||
return string();
|
||||
break;
|
||||
case LENGTH: {
|
||||
case LENGTH:
|
||||
return len_.asLatexString();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
LASSERT(false, /**/);
|
||||
return string();
|
||||
}
|
||||
default:
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
return string();
|
||||
}
|
||||
|
||||
|
||||
@ -149,15 +146,13 @@ int HSpace::inPixels(BufferView const & bv) const
|
||||
case DEFAULT:
|
||||
// FIXME: replace by correct length
|
||||
return bv.buffer().params().getIndentation().inPixels(bv);
|
||||
//return 0;
|
||||
break;
|
||||
case LENGTH:
|
||||
return len_.len().inPixels(bv.workWidth());
|
||||
break;
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
return 0;
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,14 +83,16 @@ bool LayoutFileList::haveClass(string const & classname) const
|
||||
|
||||
LayoutFile const & LayoutFileList::operator[](string const & classname) const
|
||||
{
|
||||
LASSERT(haveClass(classname), /**/);
|
||||
LATTEST(haveClass(classname));
|
||||
// safe to continue, since we will make an empty LayoutFile
|
||||
return *classmap_[classname];
|
||||
}
|
||||
|
||||
|
||||
LayoutFile & LayoutFileList::operator[](string const & classname)
|
||||
{
|
||||
LASSERT(haveClass(classname), /**/);
|
||||
LATTEST(haveClass(classname));
|
||||
// safe to continue, since we will make an empty LayoutFile
|
||||
return *classmap_[classname];
|
||||
}
|
||||
|
||||
@ -184,7 +186,8 @@ std::vector<LayoutFileIndex> LayoutFileList::classList() const
|
||||
|
||||
void LayoutFileList::reset(LayoutFileIndex const & classname)
|
||||
{
|
||||
LASSERT(haveClass(classname), /**/);
|
||||
LATTEST(haveClass(classname));
|
||||
// safe to continue, since we will make an empty LayoutFile
|
||||
LayoutFile * tc = classmap_[classname];
|
||||
LayoutFile * tmpl =
|
||||
new LayoutFile(tc->name(), tc->latexname(), tc->description(),
|
||||
@ -253,7 +256,7 @@ LayoutFileIndex LayoutFileList::addEmptyClass(string const & textclass)
|
||||
if (!tc->load(tempLayout.absFileName())) {
|
||||
// This can only happen if the hardcoded file above is wrong
|
||||
// or there is some weird filesystem error.
|
||||
LASSERT(false, /* */);
|
||||
LATTEST(false); // We will get an empty layout or something.
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,6 +276,7 @@ LayoutFileIndex LayoutFileList::addLocalLayout(
|
||||
string fullName = addName(path, textclass + ".layout");
|
||||
|
||||
FileName const layout_file(fullName);
|
||||
|
||||
if (!layout_file.exists())
|
||||
return string();
|
||||
|
||||
@ -296,6 +300,7 @@ LayoutFileIndex LayoutFileList::addLocalLayout(
|
||||
smatch sub;
|
||||
if (regex_match(line, sub, reg)) {
|
||||
// returns: whole string, classtype (not used here), class name, description
|
||||
// LASSERT: Why would this fail?
|
||||
LASSERT(sub.size() == 4, /**/);
|
||||
// now, create a TextClass with description containing path information
|
||||
class_name = (sub.str(2) == "" ? textclass : sub.str(2));
|
||||
|
50
src/LyX.cpp
50
src/LyX.cpp
@ -261,7 +261,7 @@ Messages & LyX::messages(string const & language)
|
||||
pair<map<string, Messages>::iterator, bool> result =
|
||||
pimpl_->messages_.insert(make_pair(language, Messages(language)));
|
||||
|
||||
LASSERT(result.second, /**/);
|
||||
LATTEST(result.second);
|
||||
return result.first->second;
|
||||
}
|
||||
|
||||
@ -436,7 +436,7 @@ void LyX::prepareExit()
|
||||
|
||||
void LyX::earlyExit(int status)
|
||||
{
|
||||
LASSERT(pimpl_->application_.get(), /**/);
|
||||
LATTEST(pimpl_->application_.get());
|
||||
// LyX::pimpl_::application_ is not initialised at this
|
||||
// point so it's safe to just exit after some cleanup.
|
||||
prepareExit();
|
||||
@ -484,7 +484,7 @@ int LyX::init(int & argc, char * argv[])
|
||||
|
||||
bool LyX::loadFiles()
|
||||
{
|
||||
LASSERT(!use_gui, /**/);
|
||||
LATTEST(!use_gui);
|
||||
bool success = true;
|
||||
vector<string>::const_iterator it = pimpl_->files_to_load_.begin();
|
||||
vector<string>::const_iterator end = pimpl_->files_to_load_.end();
|
||||
@ -520,7 +520,7 @@ bool LyX::loadFiles()
|
||||
|
||||
void execBatchCommands()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
singleton_->execCommands();
|
||||
}
|
||||
|
||||
@ -1268,35 +1268,35 @@ void LyX::easyParse(int & argc, char * argv[])
|
||||
|
||||
FuncStatus getStatus(FuncRequest const & action)
|
||||
{
|
||||
LASSERT(theApp(), /**/);
|
||||
LAPPERR(theApp(), _("Appplication not initialized."));
|
||||
return theApp()->getStatus(action);
|
||||
}
|
||||
|
||||
|
||||
void dispatch(FuncRequest const & action)
|
||||
{
|
||||
LASSERT(theApp(), /**/);
|
||||
LAPPERR(theApp(), _("Appplication not initialized."));
|
||||
return theApp()->dispatch(action);
|
||||
}
|
||||
|
||||
|
||||
void dispatch(FuncRequest const & action, DispatchResult & dr)
|
||||
{
|
||||
LASSERT(theApp(), /**/);
|
||||
LAPPERR(theApp(), _("Appplication not initialized."));
|
||||
return theApp()->dispatch(action, dr);
|
||||
}
|
||||
|
||||
|
||||
vector<string> & theFilesToLoad()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->files_to_load_;
|
||||
}
|
||||
|
||||
|
||||
BufferList & theBufferList()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->buffer_list_;
|
||||
}
|
||||
|
||||
@ -1304,8 +1304,8 @@ BufferList & theBufferList()
|
||||
Server & theServer()
|
||||
{
|
||||
// FIXME: this should not be use_gui dependent
|
||||
LASSERT(use_gui, /**/);
|
||||
LASSERT(singleton_, /**/);
|
||||
LWARNIF(use_gui, _("LyX server can only be used with GUI."));
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return *singleton_->pimpl_->lyx_server_.get();
|
||||
}
|
||||
|
||||
@ -1313,71 +1313,71 @@ Server & theServer()
|
||||
ServerSocket & theServerSocket()
|
||||
{
|
||||
// FIXME: this should not be use_gui dependent
|
||||
LASSERT(use_gui, /**/);
|
||||
LASSERT(singleton_, /**/);
|
||||
LWARNIF(use_gui, _("LyX server can only be used with GUI."));
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return *singleton_->pimpl_->lyx_socket_.get();
|
||||
}
|
||||
|
||||
|
||||
KeyMap & theTopLevelKeymap()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->toplevel_keymap_;
|
||||
}
|
||||
|
||||
|
||||
Converters & theConverters()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->converters_;
|
||||
}
|
||||
|
||||
|
||||
Converters & theSystemConverters()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->system_converters_;
|
||||
}
|
||||
|
||||
|
||||
Movers & theMovers()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->movers_;
|
||||
}
|
||||
|
||||
|
||||
Mover const & getMover(string const & fmt)
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->movers_(fmt);
|
||||
}
|
||||
|
||||
|
||||
void setMover(string const & fmt, string const & command)
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
singleton_->pimpl_->movers_.set(fmt, command);
|
||||
}
|
||||
|
||||
|
||||
Movers & theSystemMovers()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->system_movers_;
|
||||
}
|
||||
|
||||
|
||||
Messages const & getMessages(string const & language)
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->messages(language);
|
||||
}
|
||||
|
||||
|
||||
Messages const & getGuiMessages()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
// A cache to translate full language name to language code
|
||||
static string last_language = "auto";
|
||||
static string code;
|
||||
@ -1396,14 +1396,14 @@ Messages const & getGuiMessages()
|
||||
|
||||
Session & theSession()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return *singleton_->pimpl_->session_.get();
|
||||
}
|
||||
|
||||
|
||||
LaTeXFonts & theLaTeXFonts()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
if (!singleton_->pimpl_->latexfonts_)
|
||||
singleton_->pimpl_->latexfonts_ = new LaTeXFonts;
|
||||
return *singleton_->pimpl_->latexfonts_;
|
||||
@ -1412,7 +1412,7 @@ LaTeXFonts & theLaTeXFonts()
|
||||
|
||||
CmdDef & theTopLevelCmdDef()
|
||||
{
|
||||
LASSERT(singleton_, /**/);
|
||||
LAPPERR(singleton_, _("Appplication not initialized."));
|
||||
return singleton_->pimpl_->toplevel_cmddef_;
|
||||
}
|
||||
|
||||
|
@ -3730,7 +3730,7 @@ bool LyXAction::funcHasFlag(FuncCode action,
|
||||
|
||||
if (ici == lyx_info_map.end()) {
|
||||
LYXERR0("action: " << action << " is not known.");
|
||||
LASSERT(false, /**/);
|
||||
LASSERT(false, return false);
|
||||
}
|
||||
|
||||
return ici->second.attrib & flag;
|
||||
|
@ -593,8 +593,8 @@ void Paragraph::addChangesToToc(DocIterator const & cdit,
|
||||
|
||||
bool Paragraph::isDeleted(pos_type start, pos_type end) const
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
LASSERT(start >= 0 && start <= size(), return false);
|
||||
LASSERT(end > start && end <= size() + 1, return false);
|
||||
|
||||
return d->changes_.isDeleted(start, end);
|
||||
}
|
||||
@ -602,8 +602,8 @@ bool Paragraph::isDeleted(pos_type start, pos_type end) const
|
||||
|
||||
bool Paragraph::isChanged(pos_type start, pos_type end) const
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
LASSERT(start >= 0 && start <= size(), return false);
|
||||
LASSERT(end > start && end <= size() + 1, return false);
|
||||
|
||||
return d->changes_.isChanged(start, end);
|
||||
}
|
||||
@ -648,7 +648,7 @@ void Paragraph::setChange(Change const & change)
|
||||
|
||||
void Paragraph::setChange(pos_type pos, Change const & change)
|
||||
{
|
||||
LASSERT(pos >= 0 && pos <= size(), /**/);
|
||||
LASSERT(pos >= 0 && pos <= size(), return);
|
||||
d->changes_.set(change, pos);
|
||||
|
||||
// see comment in setChange(Change const &) above
|
||||
@ -660,15 +660,16 @@ void Paragraph::setChange(pos_type pos, Change const & change)
|
||||
|
||||
Change const & Paragraph::lookupChange(pos_type pos) const
|
||||
{
|
||||
LASSERT(pos >= 0 && pos <= size(), /**/);
|
||||
LBUFERR(pos >= 0 && pos <= size(),
|
||||
_("Invalid position given to lookupChange()"));
|
||||
return d->changes_.lookup(pos);
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
LASSERT(start >= 0 && start <= size(), return);
|
||||
LASSERT(end > start && end <= size() + 1, return);
|
||||
|
||||
for (pos_type pos = start; pos < end; ++pos) {
|
||||
switch (lookupChange(pos).type) {
|
||||
@ -702,8 +703,8 @@ void Paragraph::acceptChanges(pos_type start, pos_type end)
|
||||
|
||||
void Paragraph::rejectChanges(pos_type start, pos_type end)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end > start && end <= size() + 1, /**/);
|
||||
LASSERT(start >= 0 && start <= size(), return);
|
||||
LASSERT(end > start && end <= size() + 1, return);
|
||||
|
||||
for (pos_type pos = start; pos < end; ++pos) {
|
||||
switch (lookupChange(pos).type) {
|
||||
@ -738,7 +739,7 @@ void Paragraph::rejectChanges(pos_type start, pos_type end)
|
||||
void Paragraph::Private::insertChar(pos_type pos, char_type c,
|
||||
Change const & change)
|
||||
{
|
||||
LASSERT(pos >= 0 && pos <= int(text_.size()), /**/);
|
||||
LASSERT(pos >= 0 && pos <= int(text_.size()), return);
|
||||
|
||||
// track change
|
||||
changes_.insert(change, pos);
|
||||
@ -769,8 +770,8 @@ void Paragraph::Private::insertChar(pos_type pos, char_type c,
|
||||
bool Paragraph::insertInset(pos_type pos, Inset * inset,
|
||||
Change const & change)
|
||||
{
|
||||
LASSERT(inset, /**/);
|
||||
LASSERT(pos >= 0 && pos <= size(), /**/);
|
||||
LASSERT(inset, return false);
|
||||
LASSERT(pos >= 0 && pos <= size(), return false);
|
||||
|
||||
// Paragraph::insertInset() can be used in cut/copy/paste operation where
|
||||
// d->inset_owner_ is not set yet.
|
||||
@ -778,7 +779,7 @@ bool Paragraph::insertInset(pos_type pos, Inset * inset,
|
||||
return false;
|
||||
|
||||
d->insertChar(pos, META_INSET, change);
|
||||
LASSERT(d->text_[pos] == META_INSET, /**/);
|
||||
LASSERT(d->text_[pos] == META_INSET, return false);
|
||||
|
||||
// Add a new entry in the insetlist_.
|
||||
d->insetlist_.insert(inset, pos);
|
||||
@ -846,8 +847,8 @@ bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
|
||||
|
||||
int Paragraph::eraseChars(pos_type start, pos_type end, bool trackChanges)
|
||||
{
|
||||
LASSERT(start >= 0 && start <= size(), /**/);
|
||||
LASSERT(end >= start && end <= size() + 1, /**/);
|
||||
LASSERT(start >= 0 && start <= size(), return 0);
|
||||
LASSERT(end >= start && end <= size() + 1, return 0);
|
||||
|
||||
pos_type i = start;
|
||||
for (pos_type count = end - start; count; --count) {
|
||||
@ -1043,7 +1044,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
|
||||
unsigned int & column)
|
||||
{
|
||||
Inset * inset = owner_->getInset(i);
|
||||
LASSERT(inset, /**/);
|
||||
LBUFERR(inset, _(""));
|
||||
|
||||
if (style.pass_thru) {
|
||||
odocstringstream ods;
|
||||
@ -1805,7 +1806,7 @@ Font const & Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
{
|
||||
if (pos > size()) {
|
||||
LYXERR0("pos: " << pos << " size: " << size());
|
||||
LASSERT(pos <= size(), /**/);
|
||||
LBUFERR(false, _("Invalid position."));
|
||||
}
|
||||
|
||||
FontList::const_iterator cit = d->fontlist_.fontIterator(pos);
|
||||
@ -1830,7 +1831,7 @@ Font const & Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
|
||||
FontSpan Paragraph::fontSpan(pos_type pos) const
|
||||
{
|
||||
LASSERT(pos <= size(), /**/);
|
||||
LBUFERR(pos <= size(), _("Invalid position"));
|
||||
pos_type start = 0;
|
||||
|
||||
FontList::const_iterator cit = d->fontlist_.begin();
|
||||
@ -1849,8 +1850,9 @@ FontSpan Paragraph::fontSpan(pos_type pos) const
|
||||
}
|
||||
|
||||
// This should not happen, but if so, we take no chances.
|
||||
// LYXERR0("Paragraph::getEndPosOfFontSpan: This should not happen!");
|
||||
return FontSpan(pos, pos);
|
||||
LBUFERR(false, _("Invalid position."));
|
||||
// Squash warning
|
||||
return FontSpan();
|
||||
}
|
||||
|
||||
|
||||
@ -1881,7 +1883,7 @@ Font const & Paragraph::getFirstFontSettings(BufferParams const & bparams) const
|
||||
Font const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
|
||||
Font const & outerfont) const
|
||||
{
|
||||
LASSERT(pos >= 0, /**/);
|
||||
LBUFERR(pos >= 0, _("Invalid position."));
|
||||
|
||||
Font font = getFontSettings(bparams, pos);
|
||||
|
||||
@ -1974,7 +1976,7 @@ char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
|
||||
|
||||
void Paragraph::setFont(pos_type pos, Font const & font)
|
||||
{
|
||||
LASSERT(pos <= size(), /**/);
|
||||
LASSERT(pos <= size(), return);
|
||||
|
||||
// First, reduce font against layout/label font
|
||||
// Update: The setCharFont() routine in text2.cpp already
|
||||
@ -3256,8 +3258,7 @@ void Paragraph::setPlainOrDefaultLayout(DocumentClass const & tclass)
|
||||
|
||||
Inset const & Paragraph::inInset() const
|
||||
{
|
||||
LASSERT(d->inset_owner_, throw ExceptionMessage(BufferException,
|
||||
_("Memory problem"), _("Paragraph not properly initialized")));
|
||||
LBUFERR(d->inset_owner_, _("Paragraph not properly initialized"));
|
||||
return *d->inset_owner_;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/textutils.h"
|
||||
@ -135,7 +136,7 @@ void ParagraphMetrics::setInsetDimension(Inset const * inset,
|
||||
|
||||
Row & ParagraphMetrics::getRow(pos_type pos, bool boundary)
|
||||
{
|
||||
LASSERT(!rows().empty(), /**/);
|
||||
LBUFERR(!rows().empty(), _("ParagraphMetrics has no rows!"));
|
||||
|
||||
// If boundary is set we should return the row on which
|
||||
// the character before is inside.
|
||||
@ -154,7 +155,7 @@ Row & ParagraphMetrics::getRow(pos_type pos, bool boundary)
|
||||
|
||||
Row const & ParagraphMetrics::getRow(pos_type pos, bool boundary) const
|
||||
{
|
||||
LASSERT(!rows().empty(), /**/);
|
||||
LBUFERR(!rows().empty(), _("ParagraphMetrics has no rows!"));
|
||||
|
||||
// If boundary is set we should return the row on which
|
||||
// the character before is inside.
|
||||
@ -173,7 +174,7 @@ Row const & ParagraphMetrics::getRow(pos_type pos, bool boundary) const
|
||||
|
||||
size_t ParagraphMetrics::pos2row(pos_type pos) const
|
||||
{
|
||||
LASSERT(!rows().empty(), /**/);
|
||||
LBUFERR(!rows().empty(), _("ParagraphMetrics has no rows!"));
|
||||
|
||||
RowList::const_iterator rit = rows_.end();
|
||||
RowList::const_iterator const begin = rows_.begin();
|
||||
@ -245,7 +246,7 @@ bool ParagraphMetrics::hfillExpansion(Row const & row, pos_type pos) const
|
||||
if (!par_->isHfill(pos))
|
||||
return false;
|
||||
|
||||
LASSERT(pos >= row.pos() && pos < row.endpos(), /**/);
|
||||
LASSERT(pos >= row.pos() && pos < row.endpos(), return false);
|
||||
|
||||
// expand at the end of a row only if there is another hfill on the same row
|
||||
if (pos == row.endpos() - 1) {
|
||||
|
@ -40,6 +40,7 @@ PrinterParams::PrinterParams()
|
||||
|
||||
void PrinterParams::testInvariant() const
|
||||
{
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
switch (target) {
|
||||
case PRINTER:
|
||||
// We can't do this test, because no default printer
|
||||
@ -47,12 +48,13 @@ void PrinterParams::testInvariant() const
|
||||
// LASSERT(!printer_name.empty(), /**/);
|
||||
break;
|
||||
case FILE:
|
||||
LASSERT(!file_name.empty(), /**/);
|
||||
LATTEST(!file_name.empty());
|
||||
break;
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
43
src/Text.cpp
43
src/Text.cpp
@ -143,7 +143,7 @@ void breakParagraphConservative(BufferParams const & bparams,
|
||||
tmp.setInsetOwner(&par.inInset());
|
||||
tmp.makeSameLayout(par);
|
||||
|
||||
LASSERT(pos <= par.size(), /**/);
|
||||
LASSERT(pos <= par.size(), return);
|
||||
|
||||
if (pos < par.size()) {
|
||||
// move everything behind the break position to the new paragraph
|
||||
@ -726,7 +726,7 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
|
||||
|
||||
void Text::breakParagraph(Cursor & cur, bool inverse_logic)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
Paragraph & cpar = cur.paragraph();
|
||||
pit_type cpit = cur.pit();
|
||||
@ -883,7 +883,7 @@ void Text::insertStringAsParagraphs(Cursor & cur, docstring const & str,
|
||||
// same Paragraph one to the right and make a rebreak
|
||||
void Text::insertChar(Cursor & cur, char_type c)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
cur.recordUndo(INSERT_UNDO);
|
||||
|
||||
@ -992,6 +992,7 @@ void Text::insertChar(Cursor & cur, char_type c)
|
||||
"beginning of a paragraph. Please read the Tutorial."));
|
||||
return;
|
||||
}
|
||||
// LASSERT: Is it safe to continue here?
|
||||
LASSERT(cur.pos() > 0, /**/);
|
||||
if ((par.isLineSeparator(cur.pos() - 1) || par.isNewline(cur.pos() - 1))
|
||||
&& !par.isDeleted(cur.pos() - 1)) {
|
||||
@ -1032,7 +1033,7 @@ void Text::charInserted(Cursor & cur)
|
||||
&& !par.isWordSeparator(cur.pos() - 2)
|
||||
&& par.isWordSeparator(cur.pos() - 1)) {
|
||||
// get the word in front of cursor
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
cur.paragraph().updateWords();
|
||||
}
|
||||
}
|
||||
@ -1043,7 +1044,7 @@ void Text::charInserted(Cursor & cur)
|
||||
|
||||
bool Text::cursorForwardOneWord(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
pos_type const lastpos = cur.lastpos();
|
||||
pit_type pit = cur.pit();
|
||||
@ -1069,7 +1070,7 @@ bool Text::cursorForwardOneWord(Cursor & cur)
|
||||
else while (pos != lastpos && !par.isWordSeparator(pos))
|
||||
++pos;
|
||||
} else {
|
||||
LASSERT(pos < lastpos, /**/); // see above
|
||||
LASSERT(pos < lastpos, return false); // see above
|
||||
if (!par.isWordSeparator(pos))
|
||||
while (pos != lastpos && !par.isWordSeparator(pos))
|
||||
++pos;
|
||||
@ -1090,7 +1091,7 @@ bool Text::cursorForwardOneWord(Cursor & cur)
|
||||
|
||||
bool Text::cursorBackwardOneWord(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
pit_type pit = cur.pit();
|
||||
pos_type pos = cur.pos();
|
||||
@ -1131,7 +1132,7 @@ bool Text::cursorBackwardOneWord(Cursor & cur)
|
||||
|
||||
bool Text::cursorVisLeftOneWord(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
pos_type left_pos, right_pos;
|
||||
bool left_is_letter, right_is_letter;
|
||||
@ -1168,7 +1169,7 @@ bool Text::cursorVisLeftOneWord(Cursor & cur)
|
||||
|
||||
bool Text::cursorVisRightOneWord(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
pos_type left_pos, right_pos;
|
||||
bool left_is_letter, right_is_letter;
|
||||
@ -1207,7 +1208,7 @@ bool Text::cursorVisRightOneWord(Cursor & cur)
|
||||
|
||||
void Text::selectWord(Cursor & cur, word_location loc)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
CursorSlice from = cur.top();
|
||||
CursorSlice to = cur.top();
|
||||
getWord(from, to, loc);
|
||||
@ -1225,7 +1226,7 @@ void Text::selectWord(Cursor & cur, word_location loc)
|
||||
|
||||
void Text::selectAll(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
if (cur.lastpos() == 0 && cur.lastpit() == 0)
|
||||
return;
|
||||
// If the cursor is at the beginning, make sure the cursor ends there
|
||||
@ -1246,7 +1247,7 @@ void Text::selectAll(Cursor & cur)
|
||||
// selection is currently set
|
||||
bool Text::selectWordWhenUnderCursor(Cursor & cur, word_location loc)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
if (cur.selection())
|
||||
return false;
|
||||
selectWord(cur, loc);
|
||||
@ -1256,7 +1257,7 @@ bool Text::selectWordWhenUnderCursor(Cursor & cur, word_location loc)
|
||||
|
||||
void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
if (!cur.selection()) {
|
||||
bool const changed = cur.paragraph().isChanged(cur.pos());
|
||||
@ -1411,7 +1412,7 @@ void Text::rejectChanges()
|
||||
|
||||
void Text::deleteWordForward(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
if (cur.lastpos() == 0)
|
||||
cursorForward(cur);
|
||||
else {
|
||||
@ -1427,7 +1428,7 @@ void Text::deleteWordForward(Cursor & cur)
|
||||
|
||||
void Text::deleteWordBackward(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
if (cur.lastpos() == 0)
|
||||
cursorBackward(cur);
|
||||
else {
|
||||
@ -1444,7 +1445,7 @@ void Text::deleteWordBackward(Cursor & cur)
|
||||
// Kill to end of line.
|
||||
void Text::changeCase(Cursor & cur, TextCase action)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
CursorSlice from;
|
||||
CursorSlice to;
|
||||
|
||||
@ -1573,7 +1574,7 @@ bool Text::erase(Cursor & cur)
|
||||
|
||||
bool Text::backspacePos0(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
if (cur.pit() == 0)
|
||||
return false;
|
||||
|
||||
@ -1626,7 +1627,7 @@ bool Text::backspacePos0(Cursor & cur)
|
||||
|
||||
bool Text::backspace(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
bool needsUpdate = false;
|
||||
if (cur.pos() == 0) {
|
||||
if (cur.pit() == 0)
|
||||
@ -1828,7 +1829,7 @@ bool Text::read(Lexer & lex,
|
||||
// Returns the current font and depth as a message.
|
||||
docstring Text::currentState(Cursor const & cur) const
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
Buffer & buf = *cur.buffer();
|
||||
Paragraph const & par = cur.paragraph();
|
||||
odocstringstream os;
|
||||
@ -2014,7 +2015,7 @@ void Text::forToc(docstring & os, size_t maxlen, bool shorten) const
|
||||
|
||||
void Text::charsTranspose(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
pos_type pos = cur.pos();
|
||||
|
||||
@ -2114,7 +2115,7 @@ CompletionList const * Text::createCompletionList(Cursor const & cur) const
|
||||
|
||||
bool Text::insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/)
|
||||
{
|
||||
LASSERT(cur.bv().cursor() == cur, /**/);
|
||||
LBUFERR(cur.bv().cursor() == cur, _("Invalid cursor."));
|
||||
cur.insert(s);
|
||||
cur.bv().cursor() = cur;
|
||||
if (!(cur.result().screenUpdate() & Update::Force))
|
||||
|
@ -157,7 +157,7 @@ void Text::setInsetFont(BufferView const & bv, pit_type pit,
|
||||
pos_type pos, Font const & font)
|
||||
{
|
||||
Inset * const inset = pars_[pit].getInset(pos);
|
||||
LASSERT(inset && inset->resetFontEdit(), /**/);
|
||||
LASSERT(inset && inset->resetFontEdit(), return);
|
||||
|
||||
CursorSlice::idx_type endidx = inset->nargs();
|
||||
for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
|
||||
@ -176,7 +176,7 @@ void Text::setInsetFont(BufferView const & bv, pit_type pit,
|
||||
void Text::setLayout(pit_type start, pit_type end,
|
||||
docstring const & layout)
|
||||
{
|
||||
LASSERT(start != end, /**/);
|
||||
LASSERT(start != end, return);
|
||||
|
||||
Buffer const & buffer = owner_->buffer();
|
||||
BufferParams const & bp = buffer.params();
|
||||
@ -194,7 +194,7 @@ void Text::setLayout(pit_type start, pit_type end,
|
||||
// set layout over selection and make a total rebreak of those paragraphs
|
||||
void Text::setLayout(Cursor & cur, docstring const & layout)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
pit_type start = cur.selBegin().pit();
|
||||
pit_type end = cur.selEnd().pit() + 1;
|
||||
@ -218,7 +218,7 @@ static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
|
||||
|
||||
bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
// this happens when selecting several cells in tabular (bug 2630)
|
||||
if (cur.selBegin().idx() != cur.selEnd().idx())
|
||||
return false;
|
||||
@ -238,7 +238,7 @@ bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
|
||||
|
||||
void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
pit_type const beg = cur.selBegin().pit();
|
||||
pit_type const end = cur.selEnd().pit() + 1;
|
||||
cur.recordUndoSelection();
|
||||
@ -383,21 +383,21 @@ void Text::setFont(BufferView const & bv, CursorSlice const & begin,
|
||||
|
||||
bool Text::cursorTop(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
return setCursor(cur, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
bool Text::cursorBottom(Cursor & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
|
||||
}
|
||||
|
||||
|
||||
void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
// If the mask is completely neutral, tell user
|
||||
if (font.fontInfo() == ignore_font && font.language() == ignore_language) {
|
||||
// Could only happen with user style
|
||||
@ -429,7 +429,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
|
||||
|
||||
docstring Text::getStringToIndex(Cursor const & cur)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
if (cur.selection())
|
||||
return cur.selectionAsString(false);
|
||||
@ -482,7 +482,7 @@ void Text::setLabelWidthStringToSequence(Cursor const & cur,
|
||||
|
||||
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
||||
{
|
||||
LASSERT(cur.text(), /**/);
|
||||
LBUFERR(cur.text(), _("Uninitalized cursor."));
|
||||
|
||||
//FIXME UNICODE
|
||||
string const argument = to_utf8(arg);
|
||||
@ -508,12 +508,9 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
||||
}
|
||||
|
||||
|
||||
//FIXME This is a little redundant now, but it's probably worth keeping,
|
||||
//especially if we're going to go away from using serialization internally
|
||||
//quite so much.
|
||||
void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
|
||||
{
|
||||
LASSERT(cur.text(), /**/);
|
||||
LBUFERR(cur.text(), _("Uninitalized cursor."));
|
||||
|
||||
depth_type priordepth = -1;
|
||||
Layout priorlayout;
|
||||
@ -539,8 +536,8 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
|
||||
// this really should just insert the inset and not move the cursor.
|
||||
void Text::insertInset(Cursor & cur, Inset * inset)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LASSERT(inset, /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
LBUFERR(inset, _("Uninitialized Text."));
|
||||
cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
|
||||
Change(cur.buffer()->params().trackChanges
|
||||
? Change::INSERTED : Change::UNCHANGED));
|
||||
@ -563,7 +560,7 @@ bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos,
|
||||
|
||||
void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
|
||||
{
|
||||
LASSERT(par != int(paragraphs().size()), /**/);
|
||||
LASSERT(par != int(paragraphs().size()), return);
|
||||
cur.pit() = par;
|
||||
cur.pos() = pos;
|
||||
|
||||
@ -572,15 +569,15 @@ void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
|
||||
|
||||
// None of these should happen, but we're scaredy-cats
|
||||
if (pos < 0) {
|
||||
lyxerr << "don't like -1" << endl;
|
||||
LASSERT(false, /**/);
|
||||
LYXERR0("Don't like -1!");
|
||||
LATTEST(false);
|
||||
}
|
||||
|
||||
if (pos > para.size()) {
|
||||
lyxerr << "don't like 1, pos: " << pos
|
||||
LYXERR0("Don't like 1, pos: " << pos
|
||||
<< " size: " << para.size()
|
||||
<< " par: " << par << endl;
|
||||
LASSERT(false, /**/);
|
||||
<< " par: " << par);
|
||||
LATTEST(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -588,7 +585,7 @@ void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
|
||||
void Text::setCursorIntern(Cursor & cur,
|
||||
pit_type par, pos_type pos, bool setfont, bool boundary)
|
||||
{
|
||||
LASSERT(this == cur.text(), /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
cur.boundary(boundary);
|
||||
setCursor(cur.top(), par, pos);
|
||||
if (setfont)
|
||||
@ -923,7 +920,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
||||
|
||||
void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges)
|
||||
{
|
||||
LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), /**/);
|
||||
LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), return);
|
||||
|
||||
for (pit_type pit = first; pit <= last; ++pit) {
|
||||
Paragraph & par = pars_[pit];
|
||||
|
@ -148,7 +148,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
|
||||
#endif
|
||||
cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
LASSERT(old_pos == cur.pos(), /**/);
|
||||
LATTEST(old_pos == cur.pos());
|
||||
#endif
|
||||
cur.nextInset()->edit(cur, true);
|
||||
// don't do that also for LFUN_MATH_MODE
|
||||
@ -488,7 +488,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
// at the end?
|
||||
cur.noScreenUpdate();
|
||||
|
||||
LASSERT(cur.text() == this, /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
CursorSlice const oldTopSlice = cur.top();
|
||||
bool const oldBoundary = cur.boundary();
|
||||
bool const oldSelection = cur.selection();
|
||||
@ -1236,7 +1236,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
case LFUN_PASTE: {
|
||||
cur.message(_("Paste"));
|
||||
LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), /**/);
|
||||
LASSERT(cur.selBegin().idx() == cur.selEnd().idx(), break);
|
||||
cap::replaceSelection(cur);
|
||||
|
||||
// without argument?
|
||||
@ -1272,7 +1272,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
else if (arg == "wmf")
|
||||
type = Clipboard::WmfGraphicsType;
|
||||
else
|
||||
LASSERT(false, /**/);
|
||||
// We used to assert, but couldn't the argument come from, say, the
|
||||
// minibuffer and just be mistyped?
|
||||
LYXERR0("Unrecognized graphics type: " << arg);
|
||||
|
||||
pasteClipboardGraphics(cur, bv->buffer().errorList("Paste"), type);
|
||||
}
|
||||
@ -1924,7 +1926,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
cap::replaceSelection(cur);
|
||||
cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
|
||||
checkAndActivateInset(cur, true);
|
||||
LASSERT(cur.inMathed(), /**/);
|
||||
LASSERT(cur.inMathed(), break);
|
||||
cur.dispatch(cmd);
|
||||
break;
|
||||
}
|
||||
@ -2375,7 +2377,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
FuncStatus & flag) const
|
||||
{
|
||||
LASSERT(cur.text() == this, /**/);
|
||||
LBUFERR(this == cur.text(), _("Invalid cursor."));
|
||||
|
||||
FontInfo const & fontinfo = cur.real_current_font.fontInfo();
|
||||
bool enable = true;
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/ExceptionMessage.h"
|
||||
#include "support/FileName.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/gettext.h"
|
||||
@ -1271,20 +1272,20 @@ bool TextClass::hasInsetLayout(docstring const & n) const
|
||||
|
||||
Layout const & TextClass::operator[](docstring const & name) const
|
||||
{
|
||||
LASSERT(!name.empty(), /**/);
|
||||
LATTEST(!name.empty());
|
||||
|
||||
const_iterator it =
|
||||
find_if(begin(), end(), LayoutNamesEqual(name));
|
||||
|
||||
if (it == end()) {
|
||||
lyxerr << "We failed to find the layout '" << to_utf8(name)
|
||||
<< "' in the layout list. You MUST investigate!"
|
||||
<< endl;
|
||||
LYXERR0("We failed to find the layout '" << name
|
||||
<< "' in the layout list. You MUST investigate!");
|
||||
for (const_iterator cit = begin(); cit != end(); ++cit)
|
||||
lyxerr << " " << to_utf8(cit->name()) << endl;
|
||||
|
||||
// we require the name to exist
|
||||
LASSERT(false, /**/);
|
||||
// We require the name to exist
|
||||
static const Layout dummy;
|
||||
LASSERT(false, return dummy);
|
||||
}
|
||||
|
||||
return *it;
|
||||
@ -1293,7 +1294,8 @@ Layout const & TextClass::operator[](docstring const & name) const
|
||||
|
||||
Layout & TextClass::operator[](docstring const & name)
|
||||
{
|
||||
LASSERT(!name.empty(), /**/);
|
||||
LATTEST(!name.empty());
|
||||
// Safe to continue, given what we do below.
|
||||
|
||||
iterator it = find_if(begin(), end(), LayoutNamesEqual(name));
|
||||
|
||||
@ -1304,7 +1306,10 @@ Layout & TextClass::operator[](docstring const & name)
|
||||
LYXERR0(" " << to_utf8(cit->name()));
|
||||
|
||||
// we require the name to exist
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
// we are here only in release mode
|
||||
layoutlist_.push_back(createBasicLayout(name, true));
|
||||
it = find_if(begin(), end(), LayoutNamesEqual(name));
|
||||
}
|
||||
|
||||
return *it;
|
||||
@ -1440,7 +1445,7 @@ Layout TextClass::createBasicLayout(docstring const & name, bool unknown) const
|
||||
if (!readStyle(lex, *defaultLayout)) {
|
||||
// The only way this happens is because the hardcoded layout above
|
||||
// is wrong.
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
};
|
||||
return *defaultLayout;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstring_list.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include <cstdlib>
|
||||
@ -128,7 +129,7 @@ static int numberOfHfills(Paragraph const & par, Row const & row)
|
||||
TextMetrics::TextMetrics(BufferView * bv, Text * text)
|
||||
: bv_(bv), text_(text)
|
||||
{
|
||||
LASSERT(bv_, /**/);
|
||||
LBUFERR(bv_, _("Text metrics error."));
|
||||
max_width_ = bv_->workWidth();
|
||||
dim_.wid = max_width_;
|
||||
dim_.asc = 10;
|
||||
@ -158,7 +159,7 @@ pair<pit_type, ParagraphMetrics const *> TextMetrics::first() const
|
||||
|
||||
pair<pit_type, ParagraphMetrics const *> TextMetrics::last() const
|
||||
{
|
||||
LASSERT(!par_metrics_.empty(), /**/);
|
||||
LBUFERR(!par_metrics_.empty(), _("Text metrics error."));
|
||||
ParMetricsCache::const_reverse_iterator it = par_metrics_.rbegin();
|
||||
return make_pair(it->first, &it->second);
|
||||
}
|
||||
@ -179,7 +180,7 @@ ParagraphMetrics & TextMetrics::parMetrics(pit_type pit, bool redo)
|
||||
|
||||
bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
|
||||
{
|
||||
LASSERT(mi.base.textwidth > 0, /**/);
|
||||
LBUFERR(mi.base.textwidth > 0, _("Text metrics error."));
|
||||
max_width_ = mi.base.textwidth;
|
||||
// backup old dimension.
|
||||
Dimension const old_dim = dim_;
|
||||
@ -239,7 +240,7 @@ void TextMetrics::applyOuterFont(Font & font) const
|
||||
|
||||
Font TextMetrics::displayFont(pit_type pit, pos_type pos) const
|
||||
{
|
||||
LASSERT(pos >= 0, /**/);
|
||||
LASSERT(pos >= 0, { static Font f; return f; });
|
||||
|
||||
ParagraphList const & pars = text_->paragraphs();
|
||||
Paragraph const & par = pars[pit];
|
||||
@ -416,7 +417,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
||||
// should be.
|
||||
bv_->buffer().updateBuffer();
|
||||
parPos = text_->macrocontextPosition();
|
||||
LASSERT(!parPos.empty(), /**/);
|
||||
LBUFERR(!parPos.empty(), _("Text metrics error."));
|
||||
parPos.pit() = pit;
|
||||
}
|
||||
|
||||
@ -692,7 +693,7 @@ int TextMetrics::labelFill(pit_type const pit, Row const & row) const
|
||||
Paragraph const & par = text_->getPar(pit);
|
||||
|
||||
pos_type last = par.beginOfBody();
|
||||
LASSERT(last > 0, /**/);
|
||||
LBUFERR(last > 0, _("Text metrics error."));
|
||||
|
||||
// -1 because a label ends with a space that is in the label
|
||||
--last;
|
||||
@ -1268,7 +1269,8 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
|
||||
left_side = true;
|
||||
}
|
||||
|
||||
LASSERT(vc <= end, /**/); // This shouldn't happen.
|
||||
// This shouldn't happen. But we can reset and try to continue.
|
||||
LASSERT(vc <= end, vc = end);
|
||||
|
||||
boundary = false;
|
||||
|
||||
@ -1341,7 +1343,7 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int x) const
|
||||
// upDownInText() while in selection mode.
|
||||
ParagraphMetrics const & pm = parMetrics(pit);
|
||||
|
||||
LASSERT(row < int(pm.rows().size()), /**/);
|
||||
LBUFERR(row < int(pm.rows().size()), _("Text metrics error."));
|
||||
bool bound = false;
|
||||
Row const & r = pm.rows()[row];
|
||||
return r.pos() + getColumnNearX(pit, r, x, bound);
|
||||
@ -1444,7 +1446,7 @@ Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit,
|
||||
ParagraphMetrics const & pm = par_metrics_[pit];
|
||||
|
||||
int yy = pm.position() - pm.ascent();
|
||||
LASSERT(!pm.rows().empty(), /**/);
|
||||
LBUFERR(!pm.rows().empty(), _("Text metrics error."));
|
||||
RowList::const_iterator rit = pm.rows().begin();
|
||||
RowList::const_iterator rlast = pm.rows().end();
|
||||
--rlast;
|
||||
@ -1544,7 +1546,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
|
||||
|
||||
void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x, int const y)
|
||||
{
|
||||
LASSERT(text_ == cur.text(), /**/);
|
||||
LASSERT(text_ == cur.text(), return);
|
||||
pit_type const pit = getPitNearY(y);
|
||||
LASSERT(pit != -1, return);
|
||||
|
||||
@ -1555,7 +1557,7 @@ void TextMetrics::setCursorFromCoordinates(Cursor & cur, int const x, int const
|
||||
" pit: " << pit << " yy: " << yy);
|
||||
|
||||
int r = 0;
|
||||
LASSERT(pm.rows().size(), /**/);
|
||||
LBUFERR(pm.rows().size(), _("Text metrics error."));
|
||||
for (; r < int(pm.rows().size()) - 1; ++r) {
|
||||
Row const & row = pm.rows()[r];
|
||||
if (int(yy + row.height()) > y)
|
||||
@ -1625,7 +1627,7 @@ Inset * TextMetrics::checkInsetHit(int x, int y)
|
||||
int TextMetrics::cursorX(CursorSlice const & sl,
|
||||
bool boundary) const
|
||||
{
|
||||
LASSERT(sl.text() == text_, /**/);
|
||||
LASSERT(sl.text() == text_, return 0);
|
||||
pit_type const pit = sl.pit();
|
||||
Paragraph const & par = text_->paragraphs()[pit];
|
||||
ParagraphMetrics const & pm = par_metrics_[pit];
|
||||
@ -1800,7 +1802,7 @@ int TextMetrics::cursorY(CursorSlice const & sl, bool boundary) const
|
||||
|
||||
bool TextMetrics::cursorHome(Cursor & cur)
|
||||
{
|
||||
LASSERT(text_ == cur.text(), /**/);
|
||||
LASSERT(text_ == cur.text(), return false);
|
||||
ParagraphMetrics const & pm = par_metrics_[cur.pit()];
|
||||
Row const & row = pm.getRow(cur.pos(),cur.boundary());
|
||||
return text_->setCursor(cur, cur.pit(), row.pos());
|
||||
@ -1809,7 +1811,7 @@ bool TextMetrics::cursorHome(Cursor & cur)
|
||||
|
||||
bool TextMetrics::cursorEnd(Cursor & cur)
|
||||
{
|
||||
LASSERT(text_ == cur.text(), /**/);
|
||||
LASSERT(text_ == cur.text(), return false);
|
||||
// if not on the last row of the par, put the cursor before
|
||||
// the final space exept if I have a spanning inset or one string
|
||||
// is so long that we force a break.
|
||||
@ -1831,7 +1833,7 @@ bool TextMetrics::cursorEnd(Cursor & cur)
|
||||
|
||||
void TextMetrics::deleteLineForward(Cursor & cur)
|
||||
{
|
||||
LASSERT(text_ == cur.text(), /**/);
|
||||
LASSERT(text_ == cur.text(), return);
|
||||
if (cur.lastpos() == 0) {
|
||||
// Paragraph is empty, so we just go forward
|
||||
text_->cursorForward(cur);
|
||||
@ -1866,8 +1868,6 @@ bool TextMetrics::isFirstRow(pit_type pit, Row const & row) const
|
||||
|
||||
int TextMetrics::leftMargin(int max_width, pit_type pit) const
|
||||
{
|
||||
LASSERT(pit >= 0, /**/);
|
||||
LASSERT(pit < int(text_->paragraphs().size()), /**/);
|
||||
return leftMargin(max_width, pit, text_->paragraphs()[pit].size());
|
||||
}
|
||||
|
||||
@ -1877,11 +1877,11 @@ int TextMetrics::leftMargin(int max_width,
|
||||
{
|
||||
ParagraphList const & pars = text_->paragraphs();
|
||||
|
||||
LASSERT(pit >= 0, /**/);
|
||||
LASSERT(pit < int(pars.size()), /**/);
|
||||
LASSERT(pit >= 0, return 0);
|
||||
LASSERT(pit < int(pars.size()), return 0);
|
||||
Paragraph const & par = pars[pit];
|
||||
LASSERT(pos >= 0, /**/);
|
||||
LASSERT(pos <= par.size(), /**/);
|
||||
LASSERT(pos >= 0, return 0);
|
||||
LASSERT(pos <= par.size(), return 0);
|
||||
Buffer const & buffer = bv_->buffer();
|
||||
//lyxerr << "TextMetrics::leftMargin: pit: " << pit << " pos: " << pos << endl;
|
||||
DocumentClass const & tclass = buffer.params().documentClass();
|
||||
|
@ -182,7 +182,8 @@ TocIterator TocBackend::item(string const & type,
|
||||
{
|
||||
TocList::const_iterator toclist_it = tocs_.find(type);
|
||||
// Is the type supported?
|
||||
LASSERT(toclist_it != tocs_.end(), /**/);
|
||||
// We will try to make the best of it in release mode
|
||||
LASSERT(toclist_it != tocs_.end(), toclist_it = tocs_.begin());
|
||||
return toclist_it->second.item(dit);
|
||||
}
|
||||
|
||||
|
23
src/Undo.cpp
23
src/Undo.cpp
@ -30,8 +30,9 @@
|
||||
|
||||
#include "insets/Inset.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
@ -340,7 +341,7 @@ void Undo::Private::doRecordUndo(UndoKind kind,
|
||||
// main Text _is_ the whole document.
|
||||
// record the relevant paragraphs
|
||||
Text const * text = cell.text();
|
||||
LASSERT(text, /**/);
|
||||
LBUFERR(text, _("Uninitialized cell."));
|
||||
ParagraphList const & plist = text->paragraphs();
|
||||
ParagraphList::const_iterator first = plist.begin();
|
||||
advance(first, first_pit);
|
||||
@ -361,8 +362,8 @@ void Undo::Private::recordUndo(UndoKind kind,
|
||||
CursorData const & cur,
|
||||
bool isFullBuffer)
|
||||
{
|
||||
LASSERT(first_pit <= cell.lastpit(), /**/);
|
||||
LASSERT(last_pit <= cell.lastpit(), /**/);
|
||||
LASSERT(first_pit <= cell.lastpit(), return);
|
||||
LASSERT(last_pit <= cell.lastpit(), return);
|
||||
|
||||
doRecordUndo(kind, cell, first_pit, last_pit, cur,
|
||||
isFullBuffer, undostack_);
|
||||
@ -400,7 +401,7 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack,
|
||||
//LYXERR0("undo, performing: " << undo);
|
||||
DocIterator dit = undo.cell.asDocIterator(&buffer_);
|
||||
if (undo.isFullBuffer) {
|
||||
LASSERT(undo.pars, /**/);
|
||||
LBUFERR(undo.pars, _("Undo stack is corrupt!"));
|
||||
// This is a full document
|
||||
delete otherstack.top().bparams;
|
||||
otherstack.top().bparams = new BufferParams(buffer_.params());
|
||||
@ -413,15 +414,15 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack,
|
||||
// gained by storing just 'a few' paragraphs (most if not
|
||||
// all math inset cells have just one paragraph!)
|
||||
//LYXERR0("undo.array: " << *undo.array);
|
||||
LASSERT(undo.array, /**/);
|
||||
LBUFERR(undo.array, _("Undo stack is corrupt!"));
|
||||
dit.cell().swap(*undo.array);
|
||||
delete undo.array;
|
||||
undo.array = 0;
|
||||
} else {
|
||||
// Some finer machinery is needed here.
|
||||
Text * text = dit.text();
|
||||
LASSERT(text, /**/);
|
||||
LASSERT(undo.pars, /**/);
|
||||
LBUFERR(text, _("Invalid cursor."));
|
||||
LBUFERR(undo.pars, _("Undo stack is corrupt!"));
|
||||
ParagraphList & plist = text->paragraphs();
|
||||
|
||||
// remove new stuff between first and last
|
||||
@ -445,8 +446,10 @@ void Undo::Private::doTextUndoOrRedo(CursorData & cur, UndoElementStack & stack,
|
||||
delete undo.pars;
|
||||
undo.pars = 0;
|
||||
}
|
||||
LASSERT(undo.pars == 0, /**/);
|
||||
LASSERT(undo.array == 0, /**/);
|
||||
|
||||
// We'll clean up in release mode.
|
||||
LASSERT(undo.pars == 0, undo.pars = 0);
|
||||
LASSERT(undo.array == 0, undo.array = 0);
|
||||
|
||||
if (!undo.cur_before.empty())
|
||||
cur = undo.cur_before;
|
||||
|
@ -147,9 +147,10 @@ string const VSpace::asLatexCommand(BufferParams const & params) const
|
||||
: "\\vspace{" + len_.asLatexString() + '}';
|
||||
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
return string();
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
return string();
|
||||
}
|
||||
|
||||
|
||||
@ -230,9 +231,10 @@ int VSpace::inPixels(BufferView const & bv) const
|
||||
return len_.len().inPixels(bv.workWidth());
|
||||
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
return 0;
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ WordList::~WordList()
|
||||
docstring const & WordList::word(size_t idx) const
|
||||
{
|
||||
Impl::Words::const_iterator it = d->words_.find_summed_weight(idx);
|
||||
LASSERT(it != d->words_.end(), /**/);
|
||||
LASSERT(it != d->words_.end(), { static docstring dummy; return dummy; });
|
||||
|
||||
// We use the key() method here, and not something like it->first
|
||||
// because the btree only returns (iterator-) temporary value pairs.
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "insets/Inset.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include <QLabel>
|
||||
@ -117,14 +118,16 @@ BufferView const * Dialog::bufferview() const
|
||||
|
||||
Buffer const & Dialog::buffer() const
|
||||
{
|
||||
LASSERT(lyxview_->currentBufferView(), /**/);
|
||||
LAPPERR(lyxview_->currentBufferView(),
|
||||
_("Dialog has no associated Buffer!"));
|
||||
return lyxview_->currentBufferView()->buffer();
|
||||
}
|
||||
|
||||
|
||||
Buffer const & Dialog::documentBuffer() const
|
||||
{
|
||||
LASSERT(lyxview_->documentBufferView(), /**/);
|
||||
LAPPERR(lyxview_->currentBufferView(),
|
||||
_("Dialog has no associated Buffer!"));
|
||||
return lyxview_->documentBufferView()->buffer();
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ static vector<string> const & allManualsFiles()
|
||||
}
|
||||
|
||||
|
||||
/** Switch p_buf to point to next document buffer.
|
||||
/** Switch buf to point to next document buffer.
|
||||
**
|
||||
** Return true if restarted from master-document buffer.
|
||||
**/
|
||||
@ -157,7 +157,7 @@ static bool nextDocumentBuffer(Buffer * & buf)
|
||||
LYXERR(Debug::FIND, "children.size()=" << children.size());
|
||||
ListOfBuffers::const_iterator it =
|
||||
find(children.begin(), children.end(), buf);
|
||||
LASSERT(it != children.end(), /**/);
|
||||
LASSERT(it != children.end(), return false);
|
||||
++it;
|
||||
if (it == children.end()) {
|
||||
buf = *children.begin();
|
||||
@ -178,7 +178,7 @@ static bool prevDocumentBuffer(Buffer * & buf)
|
||||
LYXERR(Debug::FIND, "children.size()=" << children.size());
|
||||
ListOfBuffers::const_iterator it =
|
||||
find(children.begin(), children.end(), buf);
|
||||
LASSERT(it != children.end(), /**/)
|
||||
LASSERT(it != children.end(), return false)
|
||||
if (it == children.begin()) {
|
||||
it = children.end();
|
||||
--it;
|
||||
@ -422,7 +422,7 @@ bool FindAndReplaceWidget::findAndReplace(
|
||||
else if (AllManualsRB->isChecked())
|
||||
scope = FindAndReplaceOptions::S_ALL_MANUALS;
|
||||
else
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
LYXERR(Debug::FIND, "FindAndReplaceOptions: "
|
||||
<< "find_buf_name=" << find_buf_name
|
||||
<< ", casesensitiv=" << casesensitive
|
||||
|
@ -338,7 +338,7 @@ QString findPng(QString const & name)
|
||||
{
|
||||
PngMap const * const begin = sorted_png_map;
|
||||
PngMap const * const end = begin + nr_sorted_png_map;
|
||||
LASSERT(sorted(begin, end), /**/);
|
||||
LATTEST(sorted(begin, end));
|
||||
|
||||
PngMap const * const it = find_if(begin, end, CompareKey(name));
|
||||
|
||||
@ -1274,7 +1274,7 @@ void GuiApplication::gotoBookmark(unsigned int idx, bool openFile,
|
||||
return;
|
||||
BookmarksSection::Bookmark const & bm =
|
||||
theSession().bookmarks().bookmark(idx);
|
||||
LASSERT(!bm.filename.empty(), /**/);
|
||||
LASSERT(!bm.filename.empty(), return);
|
||||
string const file = bm.filename.absFileName();
|
||||
// if the file is not opened, open it.
|
||||
if (!theBufferList().exists(bm.filename)) {
|
||||
@ -2480,7 +2480,7 @@ void GuiApplication::commitData(QSessionManager & sm)
|
||||
|
||||
void GuiApplication::unregisterView(GuiView * gv)
|
||||
{
|
||||
LASSERT(d->views_[gv->id()] == gv, /**/);
|
||||
LAPPERR(d->views_[gv->id()] == gv, _("Application error."));
|
||||
d->views_.remove(gv->id());
|
||||
if (current_view_ == gv)
|
||||
current_view_ = 0;
|
||||
@ -2509,7 +2509,7 @@ bool GuiApplication::closeAllViews()
|
||||
|
||||
GuiView & GuiApplication::view(int id) const
|
||||
{
|
||||
LASSERT(d->views_.contains(id), /**/);
|
||||
LAPPERR(d->views_.contains(id), _("Application error.") /**/);
|
||||
return *d->views_.value(id);
|
||||
}
|
||||
|
||||
@ -2824,7 +2824,7 @@ void hideDialogs(std::string const & name, Inset * inset)
|
||||
|
||||
frontend::FontLoader & theFontLoader()
|
||||
{
|
||||
LASSERT(frontend::guiApp, /**/);
|
||||
LAPPERR(frontend::guiApp, _("No Gui Application."));
|
||||
return frontend::guiApp->fontLoader();
|
||||
}
|
||||
|
||||
@ -2837,7 +2837,7 @@ frontend::FontMetrics const & theFontMetrics(Font const & f)
|
||||
|
||||
frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
|
||||
{
|
||||
LASSERT(frontend::guiApp, /**/);
|
||||
LAPPERR(frontend::guiApp, _("No Gui Application."));
|
||||
return frontend::guiApp->fontLoader().metrics(f);
|
||||
}
|
||||
|
||||
@ -2850,14 +2850,14 @@ frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
|
||||
|
||||
frontend::Clipboard & theClipboard()
|
||||
{
|
||||
LASSERT(frontend::guiApp, /**/);
|
||||
LAPPERR(frontend::guiApp, _("No Gui Application."));
|
||||
return frontend::guiApp->clipboard();
|
||||
}
|
||||
|
||||
|
||||
frontend::Selection & theSelection()
|
||||
{
|
||||
LASSERT(frontend::guiApp, /**/);
|
||||
LAPPERR(frontend::guiApp, _("No Gui Application."));
|
||||
return frontend::guiApp->selection();
|
||||
}
|
||||
|
||||
|
@ -149,9 +149,9 @@ FileName GuiClipboard::getPastedGraphicsFileName(Cursor const & cur,
|
||||
types.push_back(Clipboard::PngGraphicsType);
|
||||
if (hasGraphicsContents(Clipboard::JpegGraphicsType))
|
||||
types.push_back(Clipboard::JpegGraphicsType);
|
||||
|
||||
LASSERT(!types.empty(), /**/);
|
||||
|
||||
|
||||
LASSERT(!types.empty(), return FileName());
|
||||
|
||||
// select prefered type if AnyGraphicsType was passed
|
||||
if (type == Clipboard::AnyGraphicsType)
|
||||
type = types.front();
|
||||
@ -279,7 +279,7 @@ FileName GuiClipboard::getAsGraphics(Cursor const & cur, GraphicsType type) cons
|
||||
else if (type == JpegGraphicsType)
|
||||
image.save(toqstr(filename.absFileName()), "JPEG");
|
||||
else
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
|
||||
return filename;
|
||||
}
|
||||
@ -291,7 +291,7 @@ FileName GuiClipboard::getAsGraphics(Cursor const & cur, GraphicsType type) cons
|
||||
case LinkBackGraphicsType: mime = pdfMimeType(); break;
|
||||
case EmfGraphicsType: mime = emfMimeType(); break;
|
||||
case WmfGraphicsType: mime = wmfMimeType(); break;
|
||||
default: LASSERT(false, /**/);
|
||||
default: LASSERT(false, return FileName());
|
||||
}
|
||||
|
||||
// get data
|
||||
@ -322,7 +322,7 @@ FileName GuiClipboard::getAsGraphics(Cursor const & cur, GraphicsType type) cons
|
||||
ds << pdfLen; // big endian by default
|
||||
#else
|
||||
// only non-Mac this should never happen
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
#endif // Q_WS_MACX
|
||||
}
|
||||
|
||||
@ -499,7 +499,7 @@ bool GuiClipboard::hasGraphicsContents(Clipboard::GraphicsType type) const
|
||||
case EmfGraphicsType: mime = emfMimeType(); break;
|
||||
case WmfGraphicsType: mime = wmfMimeType(); break;
|
||||
case PdfGraphicsType: mime = pdfMimeType(); break;
|
||||
default: LASSERT(false, /**/);
|
||||
default: LASSERT(false, return false);
|
||||
}
|
||||
|
||||
return cache_.hasFormat(mime);
|
||||
|
@ -787,7 +787,8 @@ void GuiCompleter::setCurrentCompletion(QString const & s)
|
||||
i = n;
|
||||
else
|
||||
i = l;
|
||||
LASSERT(i <= n, /**/);
|
||||
// we can try to recover
|
||||
LASSERT(i <= n, i = 0);
|
||||
}
|
||||
|
||||
// select the first if none was found
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/Systemcall.h"
|
||||
#include "support/Package.h"
|
||||
@ -90,14 +91,15 @@ size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_fonts[0]);
|
||||
static GuiFontInfo * fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE];
|
||||
|
||||
|
||||
/// Get font info (font + metrics) for the given LyX font.
|
||||
// Get font info (font + metrics) for the given LyX font.
|
||||
// if not cached, create it.
|
||||
GuiFontInfo & fontinfo(FontInfo const & f)
|
||||
{
|
||||
LASSERT(f.family() < NUM_FAMILIES, /**/);
|
||||
LASSERT(f.series() < NUM_SERIES, /**/);
|
||||
LASSERT(f.realShape() < NUM_SHAPE, /**/);
|
||||
LASSERT(f.size() < NUM_SIZE, /**/);
|
||||
// LASSERT: Is there anything we might do here besides crash?
|
||||
LBUFERR(f.family() < NUM_FAMILIES, _("Font lookup error."));
|
||||
LBUFERR(f.series() < NUM_SERIES, _("Font lookup error."));
|
||||
LBUFERR(f.realShape() < NUM_SHAPE, _("Font lookup error."));
|
||||
LBUFERR(f.size() < NUM_SIZE, _("Font lookup error."));
|
||||
// fi is a reference to the pointer type (GuiFontInfo *) in the
|
||||
// fontinfo_ table.
|
||||
GuiFontInfo * & fi =
|
||||
|
@ -43,7 +43,7 @@ namespace {
|
||||
**/
|
||||
inline QChar const ucs4_to_qchar(char_type const ucs4)
|
||||
{
|
||||
LASSERT(is_utf16(ucs4), /**/);
|
||||
LATTEST(is_utf16(ucs4));
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
} // anon namespace
|
||||
|
@ -65,8 +65,8 @@ bool GuiIdListModel::setData (QModelIndex const & index,
|
||||
}
|
||||
// If we assert here, it's because we're trying to set an
|
||||
// unrecognized role.
|
||||
LASSERT(false, return false);
|
||||
return false; // silence the warning
|
||||
LATTEST(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -672,7 +672,7 @@ char_type KeySymbol::getUCSEncoded() const
|
||||
return 0;
|
||||
|
||||
// UTF16 has a maximum of two characters.
|
||||
LASSERT(text_.size() <= 2, /**/);
|
||||
LASSERT(text_.size() <= 2, return 0);
|
||||
|
||||
if (lyxerr.debugging() && text_.size() > 1) {
|
||||
// We don't know yet how well support the full ucs4 range.
|
||||
|
@ -156,7 +156,7 @@ void GuiPainter::enterMonochromeMode(Color const & min, Color const & max)
|
||||
|
||||
void GuiPainter::leaveMonochromeMode()
|
||||
{
|
||||
LASSERT(!monochrome_min_.empty(), /**/);
|
||||
LASSERT(!monochrome_min_.empty(), return);
|
||||
monochrome_min_.pop();
|
||||
monochrome_max_.pop();
|
||||
}
|
||||
|
@ -1333,7 +1333,7 @@ void GuiView::removeWorkArea(GuiWorkArea * wa)
|
||||
|
||||
// It is not a tabbed work area (i.e., the search work area), so it
|
||||
// should be deleted by other means.
|
||||
LASSERT(found_twa, /* */);
|
||||
LASSERT(found_twa, return);
|
||||
|
||||
if (d.current_work_area_ == 0) {
|
||||
if (d.splitter_->count() != 0) {
|
||||
@ -2388,7 +2388,7 @@ bool GuiView::exportBufferAs(Buffer & b)
|
||||
|
||||
string s = fromqstr(filter);
|
||||
size_t pos = s.find(" (*.");
|
||||
LASSERT(pos != string::npos, /**/);
|
||||
LATTEST(pos != string::npos);
|
||||
string fmt_prettyname = s.substr(0, pos);
|
||||
string fmt_name;
|
||||
fname.set(fromqstr(result.second));
|
||||
@ -3215,7 +3215,7 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing(
|
||||
void GuiView::dispatchToBufferView(FuncRequest const & cmd, DispatchResult & dr)
|
||||
{
|
||||
BufferView * bv = currentBufferView();
|
||||
LASSERT(bv, /**/);
|
||||
LASSERT(bv, return);
|
||||
|
||||
// Let the current BufferView dispatch its own actions.
|
||||
bv->dispatch(cmd, dr);
|
||||
|
@ -279,7 +279,7 @@ QString GuiViewSource::title() const
|
||||
case LITERATE:
|
||||
return qt_("Literate Source");
|
||||
}
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
@ -1626,7 +1626,7 @@ GuiWorkArea * TabWorkArea::currentWorkArea()
|
||||
return 0;
|
||||
|
||||
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(currentWidget());
|
||||
LASSERT(wa, /**/);
|
||||
LATTEST(wa);
|
||||
return wa;
|
||||
}
|
||||
|
||||
@ -1655,7 +1655,7 @@ void TabWorkArea::closeAll()
|
||||
{
|
||||
while (count()) {
|
||||
GuiWorkArea * wa = workArea(0);
|
||||
LASSERT(wa, /**/);
|
||||
LASSERT(wa, return);
|
||||
removeTab(0);
|
||||
delete wa;
|
||||
}
|
||||
@ -1664,7 +1664,7 @@ void TabWorkArea::closeAll()
|
||||
|
||||
bool TabWorkArea::setCurrentWorkArea(GuiWorkArea * work_area)
|
||||
{
|
||||
LASSERT(work_area, /**/);
|
||||
LASSERT(work_area, return false);
|
||||
int index = indexOf(work_area);
|
||||
if (index == -1)
|
||||
return false;
|
||||
@ -1757,7 +1757,7 @@ void TabWorkArea::closeCurrentBuffer()
|
||||
wa = currentWorkArea();
|
||||
else {
|
||||
wa = workArea(clicked_tab_);
|
||||
LASSERT(wa, /**/);
|
||||
LASSERT(wa, return);
|
||||
}
|
||||
wa->view().closeWorkArea(wa);
|
||||
}
|
||||
@ -1770,7 +1770,7 @@ void TabWorkArea::hideCurrentTab()
|
||||
wa = currentWorkArea();
|
||||
else {
|
||||
wa = workArea(clicked_tab_);
|
||||
LASSERT(wa, /**/);
|
||||
LASSERT(wa, return);
|
||||
}
|
||||
wa->view().hideWorkArea(wa);
|
||||
}
|
||||
@ -1784,7 +1784,7 @@ void TabWorkArea::closeTab(int index)
|
||||
wa = currentWorkArea();
|
||||
else {
|
||||
wa = workArea(index);
|
||||
LASSERT(wa, /**/);
|
||||
LASSERT(wa, return);
|
||||
}
|
||||
wa->view().closeWorkArea(wa);
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ QString LayoutItemDelegate::underlineFilter(QString const & s) const
|
||||
layout_->filter();
|
||||
for (int i = 0; i < f.length(); ++i) {
|
||||
int p = s.indexOf(f[i], lastp + 1, Qt::CaseInsensitive);
|
||||
LASSERT(p != -1, /**/);
|
||||
LASSERT(p != -1, continue);
|
||||
if (lastp == p - 1 && lastp != -1) {
|
||||
// remove ")" and append "x)"
|
||||
r = r.left(r.length() - 4) + s[p] + "</u>";
|
||||
@ -382,7 +382,7 @@ void LayoutBox::Private::setFilter(QString const & s)
|
||||
// We do not call our implementation of showPopup because that
|
||||
// would reset the filter again. This is only needed if the user clicks
|
||||
// on the QComboBox.
|
||||
LASSERT(!inShowPopup_, /**/);
|
||||
LATTEST(!inShowPopup_);
|
||||
inShowPopup_ = true;
|
||||
p->QComboBox::showPopup();
|
||||
inShowPopup_ = false;
|
||||
@ -459,7 +459,7 @@ void LayoutBox::showPopup()
|
||||
|
||||
// call QComboBox::showPopup. But set the inShowPopup_ flag to switch on
|
||||
// the hack in the item delegate to make space for the headers.
|
||||
LASSERT(!d->inShowPopup_, /**/);
|
||||
LATTEST(!d->inShowPopup_);
|
||||
d->inShowPopup_ = true;
|
||||
QComboBox::showPopup();
|
||||
d->inShowPopup_ = false;
|
||||
|
@ -198,7 +198,7 @@ public:
|
||||
: kind_(kind), label_(label), submenuname_(submenu),
|
||||
tooltip_(tooltip), optional_(optional)
|
||||
{
|
||||
LASSERT(kind == Submenu || kind == Help || kind == Info, /**/);
|
||||
LATTEST(kind == Submenu || kind == Help || kind == Info);
|
||||
}
|
||||
|
||||
MenuItem(Kind kind,
|
||||
@ -1058,7 +1058,7 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
|
||||
action = LFUN_BUFFER_EXPORT;
|
||||
break;
|
||||
default:
|
||||
LASSERT(false, /* */);
|
||||
LATTEST(false);
|
||||
return;
|
||||
}
|
||||
sort(formats.begin(), formats.end(), Format::formatSorter);
|
||||
@ -1111,7 +1111,8 @@ void MenuDefinition::expandFormats(MenuItem::Kind const kind, Buffer const * buf
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
LASSERT(false, /* */);
|
||||
// we already asserted earlier in this case
|
||||
// LATTEST(false);
|
||||
continue;
|
||||
}
|
||||
if (!shortcut.empty())
|
||||
@ -2076,9 +2077,10 @@ MenuDefinition const & Menus::Impl::getMenu(QString const & name) const
|
||||
{
|
||||
const_iterator cit = find_if(menulist_.begin(), menulist_.end(),
|
||||
MenuNamesEqual(name));
|
||||
if (cit == menulist_.end())
|
||||
if (cit == menulist_.end()) {
|
||||
LYXERR0("No submenu named " << name);
|
||||
LASSERT(cit != menulist_.end(), /**/);
|
||||
LASSERT(false, { static const MenuDefinition m; return m; });
|
||||
}
|
||||
return (*cit);
|
||||
}
|
||||
|
||||
@ -2087,9 +2089,10 @@ MenuDefinition & Menus::Impl::getMenu(QString const & name)
|
||||
{
|
||||
iterator it = find_if(menulist_.begin(), menulist_.end(),
|
||||
MenuNamesEqual(name));
|
||||
if (it == menulist_.end())
|
||||
if (it == menulist_.end()) {
|
||||
LYXERR0("No submenu named " << name);
|
||||
LASSERT(it != menulist_.end(), /**/);
|
||||
LASSERT(false, { static MenuDefinition m; return m; });
|
||||
}
|
||||
return (*it);
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ static string const findTargetFormat(string const & from)
|
||||
FormatList const & formats = Cache::get().loadableFormats();
|
||||
|
||||
// There must be a format to load from.
|
||||
LASSERT(!formats.empty(), /**/);
|
||||
LASSERT(!formats.empty(), return string());
|
||||
|
||||
// Use the standard converter if we don't know the format to load
|
||||
// from.
|
||||
|
@ -261,7 +261,7 @@ static void build_script(string const & from_file,
|
||||
string const & to_format,
|
||||
ostream & script)
|
||||
{
|
||||
LASSERT(from_format != to_format, /**/);
|
||||
LASSERT(from_format != to_format, return);
|
||||
LYXERR(Debug::GRAPHICS, "build_script ... ");
|
||||
typedef Graph::EdgePath EdgePath;
|
||||
|
||||
|
@ -386,12 +386,6 @@ void Template::readTemplate(Lexer & lex)
|
||||
|
||||
case TO_END:
|
||||
return;
|
||||
|
||||
default:
|
||||
lex.printError("external::Template::readTemplate: "
|
||||
"Wrong tag: $$Token");
|
||||
LASSERT(false, /**/);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ Buffer & Inset::buffer()
|
||||
LYXERR0("Inset: " << this << " LyX Code: " << lyxCode()
|
||||
<< " name: " << iname);
|
||||
s << "LyX Code: " << lyxCode() << " name: " << iname;
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
throw ExceptionMessage(BufferException,
|
||||
from_ascii("Inset::buffer_ member not initialized!"), s.str());
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ using namespace lyx::support;
|
||||
namespace lyx {
|
||||
|
||||
/// Get information for \p code and command \p cmdName.
|
||||
/// Returns 0 if the combination is not known. [FIXME: 0?]
|
||||
/// Don't call this without first making sure the command name is
|
||||
/// acceptable to the inset.
|
||||
static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
|
||||
@ -82,10 +81,11 @@ static ParamInfo const & findInfo(InsetCode code, string const & cmdName)
|
||||
case TOC_CODE:
|
||||
return InsetTOC::findInfo(cmdName);
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
static ParamInfo pi;
|
||||
return pi; // to silence the warning
|
||||
static const ParamInfo pi;
|
||||
return pi;
|
||||
}
|
||||
|
||||
|
||||
@ -144,14 +144,16 @@ bool ParamInfo::operator==(ParamInfo const & rhs) const
|
||||
ParamInfo::ParamData const &
|
||||
ParamInfo::operator[](std::string const & name) const
|
||||
{
|
||||
LASSERT(hasParam(name), /**/);
|
||||
const_iterator it = begin();
|
||||
const_iterator last = end();
|
||||
for (; it != last; ++it) {
|
||||
if (it->name() == name)
|
||||
return *it;
|
||||
}
|
||||
return *it; // silence warning
|
||||
LATTEST(false);
|
||||
// we will try to continue in release mode
|
||||
static const ParamData pd("asdfghjkl", LYX_INTERNAL);
|
||||
return pd;
|
||||
}
|
||||
|
||||
|
||||
@ -214,9 +216,10 @@ string InsetCommandParams::getDefaultCmd(InsetCode code)
|
||||
case TOC_CODE:
|
||||
return InsetTOC::defaultCommand();
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
return string(); // silence the warning
|
||||
return string();
|
||||
}
|
||||
|
||||
|
||||
@ -249,10 +252,11 @@ bool InsetCommandParams::isCompatibleCommand(InsetCode code, string const & s)
|
||||
return InsetRef::isCompatibleCommand(s);
|
||||
case TOC_CODE:
|
||||
return InsetTOC::isCompatibleCommand(s);
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
default:
|
||||
LATTEST(false);
|
||||
// fall through in release mode
|
||||
}
|
||||
return false; // silence the warning
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -338,9 +342,8 @@ void InsetCommandParams::write(ostream & os) const
|
||||
|
||||
bool InsetCommandParams::writeEmptyOptional(ParamInfo::const_iterator ci) const
|
||||
{
|
||||
if (!ci->isOptional()) {
|
||||
LASSERT(false, /**/);
|
||||
}
|
||||
LASSERT(ci->isOptional(), return false);
|
||||
|
||||
++ci; // we want to start with the next one
|
||||
ParamInfo::const_iterator end = info_.end();
|
||||
for (; ci != end; ++ci) {
|
||||
@ -443,16 +446,14 @@ docstring InsetCommandParams::getFirstNonOptParam() const
|
||||
ParamInfo::const_iterator it =
|
||||
find_if(info_.begin(), info_.end(),
|
||||
not1(mem_fun_ref(&ParamInfo::ParamData::isOptional)));
|
||||
if (it == info_.end()) {
|
||||
LASSERT(false, return docstring());
|
||||
}
|
||||
LASSERT(it != info_.end(), return docstring());
|
||||
return (*this)[it->name()];
|
||||
}
|
||||
|
||||
|
||||
docstring const & InsetCommandParams::operator[](string const & name) const
|
||||
{
|
||||
static const docstring dummy; //so we don't return a ref to temporary
|
||||
static const docstring dummy;
|
||||
LASSERT(info_.hasParam(name), return dummy);
|
||||
ParamMap::const_iterator data = params_.find(name);
|
||||
if (data == params_.end() || data->second.empty())
|
||||
@ -463,7 +464,8 @@ docstring const & InsetCommandParams::operator[](string const & name) const
|
||||
|
||||
docstring & InsetCommandParams::operator[](string const & name)
|
||||
{
|
||||
LASSERT(info_.hasParam(name), /**/);
|
||||
LATTEST(info_.hasParam(name));
|
||||
// this will add the name in release mode
|
||||
return params_[name];
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ void InsetExternal::fileChanged() const
|
||||
return;
|
||||
|
||||
RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
|
||||
LASSERT(ptr, /**/);
|
||||
LASSERT(ptr, return);
|
||||
|
||||
ptr->removePreview(*buffer);
|
||||
add_preview_and_start_loading(*ptr, *this, *buffer);
|
||||
|
@ -388,7 +388,8 @@ docstring InsetInclude::screenLabel() const
|
||||
temp = listings_label_;
|
||||
break;
|
||||
case NONE:
|
||||
LASSERT(false, /**/);
|
||||
LASSERT(false, temp = buffer().B_("Unknown"));
|
||||
break;
|
||||
}
|
||||
|
||||
temp += ": ";
|
||||
@ -904,14 +905,13 @@ int InsetInclude::docbook(odocstream & os, OutputParams const & runparams) const
|
||||
|
||||
void InsetInclude::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
LATTEST(&buffer() == &features.buffer());
|
||||
|
||||
string incfile = to_utf8(params()["filename"]);
|
||||
string writefile;
|
||||
|
||||
LASSERT(&buffer() == &features.buffer(), /**/);
|
||||
|
||||
string const included_file =
|
||||
includedFileName(buffer(), params()).absFileName();
|
||||
|
||||
string writefile;
|
||||
if (isLyXFileName(included_file))
|
||||
writefile = changeExtension(included_file, ".sgml");
|
||||
else
|
||||
@ -966,7 +966,7 @@ void InsetInclude::collectBibKeys(InsetIterator const & /*di*/) const
|
||||
|
||||
void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
LASSERT(mi.base.bv, /**/);
|
||||
LBUFERR(mi.base.bv, _("Text metrics error."));
|
||||
|
||||
bool use_preview = false;
|
||||
if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
|
||||
@ -992,7 +992,7 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetInclude::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
LASSERT(pi.base.bv, /**/);
|
||||
LBUFERR(pi.base.bv, _("Painter has no BufferView!"));
|
||||
|
||||
bool use_preview = false;
|
||||
if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
|
||||
|
@ -862,7 +862,8 @@ void InsetSpace::string2params(string const & in, InsetSpaceParams & params)
|
||||
params.math = true;
|
||||
else {
|
||||
params.math = false;
|
||||
LASSERT(name == "space", /**/);
|
||||
// we can try to read this even if the name is wrong
|
||||
LATTEST(name == "space");
|
||||
}
|
||||
|
||||
// There are cases, such as when we are called via getStatus() from
|
||||
|
@ -232,8 +232,7 @@ docstring InsetTOC::xhtml(XHTMLStream &, OutputParams const & op) const
|
||||
string const & command = getCmdName();
|
||||
if (command != "tableofcontents" && command != "lstlistoflistings") {
|
||||
LYXERR0("TOC type " << command << " not yet implemented.");
|
||||
LASSERT(false, /* */);
|
||||
return docstring();
|
||||
LASSERT(false, return docstring());
|
||||
}
|
||||
|
||||
Toc const & toc = buffer().tocBackend().toc(cmd2type(command));
|
||||
|
@ -1527,14 +1527,13 @@ void Tabular::read(Lexer & lex)
|
||||
|
||||
l_getline(is, line);
|
||||
if (!prefixIs(line, "<lyxtabular ") && !prefixIs(line, "<Tabular ")) {
|
||||
LASSERT(false, /**/);
|
||||
return;
|
||||
LASSERT(false, return);
|
||||
}
|
||||
|
||||
int version;
|
||||
if (!getTokenValue(line, "version", version))
|
||||
return;
|
||||
LASSERT(version >= 2, /**/);
|
||||
LATTEST(version >= 2);
|
||||
|
||||
int rows_arg;
|
||||
if (!getTokenValue(line, "rows", rows_arg))
|
||||
@ -1867,8 +1866,8 @@ Tabular::idx_type Tabular::cellBelow(idx_type cell) const
|
||||
|
||||
Tabular::idx_type Tabular::cellIndex(row_type row, col_type column) const
|
||||
{
|
||||
LASSERT(column != npos && column < ncols()
|
||||
&& row != npos && row < nrows(), /**/);
|
||||
LASSERT(column != npos && column < ncols(), column = 0);
|
||||
LASSERT(row != npos && row < nrows(), row = 0);
|
||||
return cell_info[row][column].cellno;
|
||||
}
|
||||
|
||||
@ -2099,14 +2098,14 @@ void Tabular::setRowDescent(row_type row, int height)
|
||||
|
||||
int Tabular::rowAscent(row_type row) const
|
||||
{
|
||||
LASSERT(row < nrows(), /**/);
|
||||
LASSERT(row < nrows(), row = 0);
|
||||
return row_info[row].ascent;
|
||||
}
|
||||
|
||||
|
||||
int Tabular::rowDescent(row_type row) const
|
||||
{
|
||||
LASSERT(row < nrows(), /**/);
|
||||
LASSERT(row < nrows(), row = 0);
|
||||
return row_info[row].descent;
|
||||
}
|
||||
|
||||
@ -2123,16 +2122,16 @@ int Tabular::height() const
|
||||
|
||||
bool Tabular::isPartOfMultiColumn(row_type row, col_type column) const
|
||||
{
|
||||
LASSERT(row < nrows(), /**/);
|
||||
LASSERT(column < ncols(), /**/);
|
||||
LASSERT(row < nrows(), return false);
|
||||
LASSERT(column < ncols(), return false);
|
||||
return cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN;
|
||||
}
|
||||
|
||||
|
||||
bool Tabular::isPartOfMultiRow(row_type row, col_type column) const
|
||||
{
|
||||
LASSERT(row < nrows(), /**/);
|
||||
LASSERT(column < ncols(), /**/);
|
||||
LASSERT(row < nrows(), return false);
|
||||
LASSERT(column < ncols(), return false);
|
||||
return cell_info[row][column].multirow == CELL_PART_OF_MULTIROW;
|
||||
}
|
||||
|
||||
@ -3556,10 +3555,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
//lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
|
||||
// mi.base.textwidth << "\n";
|
||||
if (!mi.base.bv) {
|
||||
LYXERR0("need bv");
|
||||
LASSERT(false, /**/);
|
||||
}
|
||||
LBUFERR(mi.base.bv, _("Text metrics error."));
|
||||
|
||||
for (row_type r = 0; r < tabular.nrows(); ++r) {
|
||||
int maxasc = 0;
|
||||
@ -6102,7 +6098,8 @@ void InsetTabular::cutSelection(Cursor & cur)
|
||||
|
||||
bool InsetTabular::isRightToLeft(Cursor & cur) const
|
||||
{
|
||||
LASSERT(cur.depth() > 1, /**/);
|
||||
// LASSERT: It might be better to abandon this Buffer.
|
||||
LASSERT(cur.depth() > 1, return false);
|
||||
Paragraph const & parentpar = cur[cur.depth() - 2].paragraph();
|
||||
pos_type const parentpos = cur[cur.depth() - 2].pos();
|
||||
return parentpar.getFontSettings(buffer().params(),
|
||||
|
@ -125,7 +125,7 @@ void InsetText::setMacrocontextPositionRecursive(DocIterator const & pos)
|
||||
void InsetText::clear()
|
||||
{
|
||||
ParagraphList & pars = paragraphs();
|
||||
LASSERT(!pars.empty(), /**/);
|
||||
LBUFERR(!pars.empty(), _("Buffer corrupt!"));
|
||||
|
||||
// This is a gross hack...
|
||||
Layout const & old_layout = pars.begin()->layout();
|
||||
@ -874,9 +874,11 @@ bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
||||
// find text inset in old cursor
|
||||
Cursor insetCur = old;
|
||||
int scriptSlice = insetCur.find(this);
|
||||
LASSERT(scriptSlice != -1, /**/);
|
||||
// we can try to continue here. returning true means
|
||||
// the cursor is "now" invalid. which it was.
|
||||
LASSERT(scriptSlice != -1, return true);
|
||||
insetCur.cutOff(scriptSlice);
|
||||
LASSERT(&insetCur.inset() == this, /**/);
|
||||
LASSERT(&insetCur.inset() == this, return true);
|
||||
|
||||
// update the old paragraph's words
|
||||
insetCur.paragraph().updateWords();
|
||||
@ -887,7 +889,7 @@ bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
||||
|
||||
bool InsetText::completionSupported(Cursor const & cur) const
|
||||
{
|
||||
//LASSERT(&cur.bv().cursor().inset() != this, return false);
|
||||
//LASSERT(&cur.bv().cursor().inset() == this, return false);
|
||||
return text_.completionSupported(cur);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
|
||||
void InsetVSpace::read(Lexer & lex)
|
||||
{
|
||||
LASSERT(lex.isOK(), /**/);
|
||||
LASSERT(lex.isOK(), return);
|
||||
string vsp;
|
||||
lex >> vsp;
|
||||
if (lex)
|
||||
|
@ -76,7 +76,7 @@ namespace {
|
||||
|
||||
docstring const statusMessage(BufferView const * bv, string const & snippet)
|
||||
{
|
||||
LASSERT(bv, /**/);
|
||||
LASSERT(bv, return docstring());
|
||||
|
||||
Buffer const & buffer = bv->buffer();
|
||||
graphics::PreviewLoader const * loader = buffer.loader();
|
||||
@ -113,7 +113,7 @@ RenderPreview::getPreviewImage(Buffer const & buffer) const
|
||||
|
||||
void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
LASSERT(mi.base.bv, /**/);
|
||||
LBUFERR(mi.base.bv, _("Text metrics error."));
|
||||
|
||||
graphics::PreviewImage const * const pimage =
|
||||
getPreviewImage(mi.base.bv->buffer());
|
||||
@ -139,7 +139,7 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void RenderPreview::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
LASSERT(pi.base.bv, /**/);
|
||||
LBUFERR(pi.base.bv, _("Painter has no BufferView!"));
|
||||
|
||||
graphics::PreviewImage const * const pimage =
|
||||
getPreviewImage(pi.base.bv->buffer());
|
||||
|
@ -280,7 +280,8 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
||||
cap::replaceSelectionWithString(cur, replacestr);
|
||||
if (forward) {
|
||||
cur.pos() += replacestr.length();
|
||||
LASSERT(cur.pos() <= cur.lastpos(), /* */);
|
||||
LASSERT(cur.pos() <= cur.lastpos(),
|
||||
cur.pos() = cur.lastpos());
|
||||
}
|
||||
if (findnext)
|
||||
findOne(bv, searchstr, case_sens, whole, forward, false);
|
||||
@ -1057,7 +1058,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
|
||||
LYXERR(Debug::FIND, " with cur.lastpost=" << cur.lastpos() << ", cur.lastrow="
|
||||
<< cur.lastrow() << ", cur.lastcol=" << cur.lastcol());
|
||||
Buffer const & buf = *cur.buffer();
|
||||
LASSERT(buf.params().isLatex(), /* */);
|
||||
LBUFERR(buf.params().isLatex(), _("Buffer type mismatch."));
|
||||
|
||||
TexRow texrow;
|
||||
odocstringstream ods;
|
||||
@ -1134,7 +1135,7 @@ int findAdvFinalize(DocIterator & cur, MatchStringAdv const & match)
|
||||
cur.forwardPos();
|
||||
} while (cur && cur.depth() > d && match(cur) > 0);
|
||||
cur = old_cur;
|
||||
LASSERT(match(cur) > 0, /* */);
|
||||
LASSERT(match(cur) > 0, return 0);
|
||||
LYXERR(Debug::FIND, "Ok");
|
||||
|
||||
// Compute the match length
|
||||
@ -1278,7 +1279,8 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match)
|
||||
docstring stringifyFromForSearch(FindAndReplaceOptions const & opt,
|
||||
DocIterator const & cur, int len)
|
||||
{
|
||||
LASSERT(cur.pos() >= 0 && cur.pos() <= cur.lastpos(), /* */);
|
||||
LASSERT(cur.pos() >= 0 && cur.pos() <= cur.lastpos(),
|
||||
return docstring());
|
||||
if (!opt.ignoreformat)
|
||||
return latexifyFromCursor(cur, len);
|
||||
else
|
||||
@ -1363,7 +1365,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
|
||||
<< ", sel_len: " << sel_len << endl);
|
||||
if (sel_len == 0)
|
||||
return;
|
||||
LASSERT(sel_len > 0, /**/);
|
||||
LASSERT(sel_len > 0, return);
|
||||
|
||||
if (!matchAdv(sel_beg, sel_len))
|
||||
return;
|
||||
@ -1375,7 +1377,7 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
|
||||
string lyx = oss.str();
|
||||
Buffer repl_buffer("", false);
|
||||
repl_buffer.setUnnamed(true);
|
||||
LASSERT(repl_buffer.readString(lyx), /**/);
|
||||
LASSERT(repl_buffer.readString(lyx), return);
|
||||
if (opt.keep_case && sel_len >= 2) {
|
||||
if (cur.inTexted()) {
|
||||
if (firstUppercase(cur))
|
||||
|
@ -88,7 +88,7 @@ int InsetMath::plaintext(odocstringstream &,
|
||||
OutputParams const &, size_t) const
|
||||
{
|
||||
// all math plain text output shall take place in InsetMathHull
|
||||
LASSERT(false, /**/);
|
||||
LATTEST(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1302,7 +1302,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
docstring & special = colinfo_[cur.col()].special_;
|
||||
if (!special.empty()) {
|
||||
docstring::size_type i = special.rfind('|');
|
||||
LASSERT(i != docstring::npos, /**/);
|
||||
LASSERT(i != docstring::npos, break);
|
||||
special.erase(i, 1);
|
||||
}
|
||||
}
|
||||
@ -1311,7 +1311,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
docstring & special = colinfo_[cur.col()+1].special_;
|
||||
if (!special.empty()) {
|
||||
docstring::size_type i = special.find('|');
|
||||
LASSERT(i != docstring::npos, /**/);
|
||||
LASSERT(i != docstring::npos, break);
|
||||
special.erase(i, 1);
|
||||
}
|
||||
}
|
||||
|
@ -663,7 +663,7 @@ bool InsetMathHull::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
||||
|
||||
docstring InsetMathHull::label(row_type row) const
|
||||
{
|
||||
LASSERT(row < nrows(), /**/);
|
||||
LASSERT(row < nrows(), return docstring());
|
||||
if (InsetLabel * il = label_[row])
|
||||
return il->screenLabel();
|
||||
return docstring();
|
||||
@ -1020,7 +1020,7 @@ void InsetMathHull::glueall(HullType type)
|
||||
|
||||
void InsetMathHull::splitTo2Cols()
|
||||
{
|
||||
LASSERT(ncols() == 1, /**/);
|
||||
LASSERT(ncols() == 1, return);
|
||||
InsetMathGrid::addCol(1);
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
idx_type const i = 2 * row;
|
||||
@ -1033,7 +1033,7 @@ void InsetMathHull::splitTo2Cols()
|
||||
|
||||
void InsetMathHull::splitTo3Cols()
|
||||
{
|
||||
LASSERT(ncols() < 3, /**/);
|
||||
LASSERT(ncols() < 3, return);
|
||||
if (ncols() < 2)
|
||||
splitTo2Cols();
|
||||
InsetMathGrid::addCol(2);
|
||||
@ -1264,9 +1264,9 @@ void InsetMathHull::infoize(odocstream & os) const
|
||||
|
||||
void InsetMathHull::check() const
|
||||
{
|
||||
LASSERT(numbered_.size() == nrows(), /**/);
|
||||
LASSERT(numbers_.size() == nrows(), /**/);
|
||||
LASSERT(label_.size() == nrows(), /**/);
|
||||
LATTEST(numbered_.size() == nrows());
|
||||
LATTEST(numbers_.size() == nrows());
|
||||
LATTEST(label_.size() == nrows());
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +139,7 @@ void InsetMathNest::cursorPos(BufferView const & bv,
|
||||
// to touch all (math)inset's draw() methods. Right now, we'll store
|
||||
// absolute value, and make them here relative, only to make them
|
||||
// absolute again when actually drawing the cursor. What a mess.
|
||||
LASSERT(&sl.inset() == this, /**/);
|
||||
LASSERT(&sl.inset() == this, return);
|
||||
MathData const & ar = sl.cell();
|
||||
CoordCache const & coord_cache = bv.coordCache();
|
||||
if (!coord_cache.getArrays().has(&ar)) {
|
||||
@ -192,7 +192,7 @@ void InsetMathNest::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
|
||||
bool InsetMathNest::idxNext(Cursor & cur) const
|
||||
{
|
||||
LASSERT(&cur.inset() == this, /**/);
|
||||
LASSERT(&cur.inset() == this, return false);
|
||||
if (cur.idx() == cur.lastidx())
|
||||
return false;
|
||||
++cur.idx();
|
||||
@ -209,7 +209,7 @@ bool InsetMathNest::idxForward(Cursor & cur) const
|
||||
|
||||
bool InsetMathNest::idxPrev(Cursor & cur) const
|
||||
{
|
||||
LASSERT(&cur.inset() == this, /**/);
|
||||
LASSERT(&cur.inset() == this, return false);
|
||||
if (cur.idx() == 0)
|
||||
return false;
|
||||
--cur.idx();
|
||||
@ -226,7 +226,7 @@ bool InsetMathNest::idxBackward(Cursor & cur) const
|
||||
|
||||
bool InsetMathNest::idxFirst(Cursor & cur) const
|
||||
{
|
||||
LASSERT(&cur.inset() == this, /**/);
|
||||
LASSERT(&cur.inset() == this, return false);
|
||||
if (nargs() == 0)
|
||||
return false;
|
||||
cur.idx() = 0;
|
||||
@ -237,7 +237,7 @@ bool InsetMathNest::idxFirst(Cursor & cur) const
|
||||
|
||||
bool InsetMathNest::idxLast(Cursor & cur) const
|
||||
{
|
||||
LASSERT(&cur.inset() == this, /**/);
|
||||
LASSERT(&cur.inset() == this, return false);
|
||||
if (nargs() == 0)
|
||||
return false;
|
||||
cur.idx() = cur.lastidx();
|
||||
@ -1644,7 +1644,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
|
||||
cur.backspace();
|
||||
cur.niceInsert(MathAtom(new InsetMathComment(buf)));
|
||||
} else if (c == '#') {
|
||||
LASSERT(cur.activeMacro(), /**/);
|
||||
LASSERT(cur.activeMacro(), return false);
|
||||
cur.activeMacro()->setName(name + docstring(1, c));
|
||||
} else {
|
||||
cur.backspace();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "MathSupport.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
|
||||
#include "support/lassert.h"
|
||||
|
||||
@ -46,7 +47,7 @@ InsetMathScript::InsetMathScript(Buffer * buf, bool up)
|
||||
InsetMathScript::InsetMathScript(Buffer * buf, MathAtom const & at, bool up)
|
||||
: InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
|
||||
{
|
||||
LASSERT(nargs() >= 1, /**/);
|
||||
LATTEST(nargs() >= 1);
|
||||
cell(0).push_back(at);
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ MathData const & InsetMathScript::down() const
|
||||
{
|
||||
if (nargs() == 3)
|
||||
return cell(2);
|
||||
LASSERT(nargs() > 1, /**/);
|
||||
LBUFERR(nargs() > 1, _("Invalid number of math cells."));
|
||||
return cell(1);
|
||||
}
|
||||
|
||||
@ -98,21 +99,21 @@ MathData & InsetMathScript::down()
|
||||
{
|
||||
if (nargs() == 3)
|
||||
return cell(2);
|
||||
LASSERT(nargs() > 1, /**/);
|
||||
LBUFERR(nargs() > 1, _("Invalid number of math cells."));
|
||||
return cell(1);
|
||||
}
|
||||
|
||||
|
||||
MathData const & InsetMathScript::up() const
|
||||
{
|
||||
LASSERT(nargs() > 1, /**/);
|
||||
LBUFERR(nargs() > 1, _("Invalid number of math cells."));
|
||||
return cell(1);
|
||||
}
|
||||
|
||||
|
||||
MathData & InsetMathScript::up()
|
||||
{
|
||||
LASSERT(nargs() > 1, /**/);
|
||||
LBUFERR(nargs() > 1, _("Invalid number of math cells."));
|
||||
return cell(1);
|
||||
}
|
||||
|
||||
@ -221,7 +222,7 @@ int InsetMathScript::dy1(BufferView const & bv) const
|
||||
|
||||
int InsetMathScript::dx0(BufferView const & bv) const
|
||||
{
|
||||
LASSERT(hasDown(), /**/);
|
||||
LASSERT(hasDown(), return 0);
|
||||
Dimension const dim = dimension(bv);
|
||||
return hasLimits() ? (dim.wid - down().dimension(bv).width()) / 2 : nwid(bv);
|
||||
}
|
||||
@ -229,7 +230,7 @@ int InsetMathScript::dx0(BufferView const & bv) const
|
||||
|
||||
int InsetMathScript::dx1(BufferView const & bv) const
|
||||
{
|
||||
LASSERT(hasUp(), /**/);
|
||||
LASSERT(hasUp(), return 0);
|
||||
Dimension const dim = dimension(bv);
|
||||
return hasLimits() ? (dim.wid - up().dimension(bv).width()) / 2 : nwid(bv) + nker(&bv);
|
||||
}
|
||||
@ -438,9 +439,7 @@ Inset::idx_type InsetMathScript::idxOfScript(bool up) const
|
||||
return (cell_1_is_up_ == up) ? 1 : 0;
|
||||
if (nargs() == 3)
|
||||
return up ? 1 : 2;
|
||||
LASSERT(false, /**/);
|
||||
// Silence compiler
|
||||
return 0;
|
||||
LASSERT(false, return 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,8 +280,8 @@ void InsetMathSpace::write(WriteStream & os) const
|
||||
|
||||
InsetSpaceParams InsetMathSpace::params() const
|
||||
{
|
||||
LASSERT(space_info[space_].visible, /**/);
|
||||
InsetSpaceParams isp(true);
|
||||
LASSERT(space_info[space_].visible, return isp);
|
||||
isp.kind = space_info[space_].kind;
|
||||
isp.length = GlueLength(length_);
|
||||
return isp;
|
||||
|
@ -40,7 +40,7 @@ InsetMathSpecialChar::InsetMathSpecialChar(docstring const & name)
|
||||
else if (name == "textbackslash")
|
||||
char_ = '\\';
|
||||
else
|
||||
LASSERT(false, /**/);
|
||||
LASSERT(false, char_ = '?');
|
||||
} else
|
||||
char_ = name.at(0);
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ void InsetMathString::octave(OctaveStream & os) const
|
||||
}
|
||||
|
||||
|
||||
void InsetMathString::mathmlize(MathStream & /*os*/) const
|
||||
void InsetMathString::mathmlize(MathStream &) const
|
||||
{
|
||||
// useless, no doubt, but we should not be here
|
||||
LASSERT(false, /* */);
|
||||
LATTEST(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Text.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -109,7 +110,7 @@ vector<docstring> const & MacroData::defaults() const
|
||||
void MacroData::unlock() const
|
||||
{
|
||||
--lockCount_;
|
||||
LASSERT(lockCount_ >= 0, /**/);
|
||||
LASSERT(lockCount_ >= 0, lockCount_ = 0);
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +136,7 @@ void MacroData::updateData() const
|
||||
if (queried_)
|
||||
return;
|
||||
|
||||
LASSERT(buffer_ != 0, /**/);
|
||||
LBUFERR(buffer_, _("Corrupt macro data!"));
|
||||
|
||||
// Try to fix position DocIterator. Should not do anything in theory.
|
||||
pos_.fixIfBroken();
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "frontends/FontMetrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
@ -53,14 +54,14 @@ MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
|
||||
|
||||
MathAtom & MathData::operator[](pos_type pos)
|
||||
{
|
||||
LASSERT(pos < size(), /**/);
|
||||
LBUFERR(pos < size(), _("Invalid MathData."));
|
||||
return base_type::operator[](pos);
|
||||
}
|
||||
|
||||
|
||||
MathAtom const & MathData::operator[](pos_type pos) const
|
||||
{
|
||||
LASSERT(pos < size(), /**/);
|
||||
LBUFERR(pos < size(), _("Invalid MathData."));
|
||||
return base_type::operator[](pos);
|
||||
}
|
||||
|
||||
@ -73,7 +74,7 @@ void MathData::insert(size_type pos, MathAtom const & t)
|
||||
|
||||
void MathData::insert(size_type pos, MathData const & ar)
|
||||
{
|
||||
LASSERT(pos <= size(), /**/);
|
||||
LBUFERR(pos < size(), _("Invalid MathData."));
|
||||
base_type::insert(begin() + pos, ar.begin(), ar.end());
|
||||
}
|
||||
|
||||
@ -487,7 +488,7 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc,
|
||||
InsetMath * inset = operator[](i).nucleus();
|
||||
if (inset->asScriptInset())
|
||||
inset = inset->asScriptInset()->nuc()[0].nucleus();
|
||||
LASSERT(inset->asMacro(), /**/);
|
||||
LASSERT(inset->asMacro(), continue);
|
||||
inset->asMacro()->updateRepresentation(cur, mc, utype);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lassert.h"
|
||||
#include "support/textutils.h"
|
||||
|
||||
@ -215,7 +216,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
&& editing_[mi.base.bv]) {
|
||||
// Macro will be edited in a old-style list mode here:
|
||||
|
||||
LASSERT(macro_ != 0, /**/);
|
||||
LBUFERR(macro_, _("Text metrics error."));
|
||||
Dimension fontDim;
|
||||
FontInfo labelFont = sane_font;
|
||||
math_font_max_dim(labelFont, fontDim.asc, fontDim.des);
|
||||
@ -252,7 +253,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.wid += 2;
|
||||
metricsMarkers2(dim);
|
||||
} else {
|
||||
LASSERT(macro_ != 0, /**/);
|
||||
LBUFERR(macro_, _("Text metrics error."));
|
||||
|
||||
// calculate metrics, hoping that all cells are seen
|
||||
macro_->lock();
|
||||
@ -564,7 +565,7 @@ Inset * MathMacro::editXY(Cursor & cur, int x, int y)
|
||||
|
||||
void MathMacro::removeArgument(Inset::pos_type pos) {
|
||||
if (displayMode_ == DISPLAY_NORMAL) {
|
||||
LASSERT(size_t(pos) < cells_.size(), /**/);
|
||||
LASSERT(size_t(pos) < cells_.size(), return);
|
||||
cells_.erase(cells_.begin() + pos);
|
||||
if (size_t(pos) < attachedArgsNum_)
|
||||
--attachedArgsNum_;
|
||||
@ -579,7 +580,7 @@ void MathMacro::removeArgument(Inset::pos_type pos) {
|
||||
|
||||
void MathMacro::insertArgument(Inset::pos_type pos) {
|
||||
if (displayMode_ == DISPLAY_NORMAL) {
|
||||
LASSERT(size_t(pos) <= cells_.size(), /**/);
|
||||
LASSERT(size_t(pos) <= cells_.size(), return);
|
||||
cells_.insert(cells_.begin() + pos, MathData());
|
||||
if (size_t(pos) < attachedArgsNum_)
|
||||
++attachedArgsNum_;
|
||||
@ -593,7 +594,7 @@ void MathMacro::insertArgument(Inset::pos_type pos) {
|
||||
|
||||
void MathMacro::detachArguments(vector<MathData> & args, bool strip)
|
||||
{
|
||||
LASSERT(displayMode_ == DISPLAY_NORMAL, /**/);
|
||||
LASSERT(displayMode_ == DISPLAY_NORMAL, return);
|
||||
args = cells_;
|
||||
|
||||
// strip off empty cells, but not more than arity-attachedArgsNum_
|
||||
@ -614,7 +615,7 @@ void MathMacro::detachArguments(vector<MathData> & args, bool strip)
|
||||
|
||||
void MathMacro::attachArguments(vector<MathData> const & args, size_t arity, int optionals)
|
||||
{
|
||||
LASSERT(displayMode_ == DISPLAY_NORMAL, /**/);
|
||||
LASSERT(displayMode_ == DISPLAY_NORMAL, return);
|
||||
cells_ = args;
|
||||
attachedArgsNum_ = args.size();
|
||||
cells_.resize(arity);
|
||||
@ -647,7 +648,9 @@ bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur)
|
||||
// The macro name was changed
|
||||
Cursor inset_cursor = old;
|
||||
int macroSlice = inset_cursor.find(this);
|
||||
LASSERT(macroSlice != -1, /**/);
|
||||
// returning true means the cursor is "now" invalid,
|
||||
// which it was.
|
||||
LASSERT(macroSlice != -1, return true);
|
||||
inset_cursor.cutOff(macroSlice);
|
||||
inset_cursor.recordUndoInset();
|
||||
inset_cursor.pop();
|
||||
@ -701,7 +704,8 @@ void MathMacro::write(WriteStream & os) const
|
||||
}
|
||||
|
||||
// normal mode
|
||||
LASSERT(macro_, /**/);
|
||||
// we should be ok to continue even if this fails.
|
||||
LATTEST(macro_);
|
||||
|
||||
// optional arguments make macros fragile
|
||||
if (optionals_ > 0 && os.fragile())
|
||||
|
@ -846,7 +846,7 @@ void fixMacroInstances(Cursor & cur, DocIterator const & inset_pos,
|
||||
for (; sit != end; ++sit) {
|
||||
InsetMathHull * inset_hull =
|
||||
sit->nextInset()->asInsetMath()->asHullInset();
|
||||
LASSERT(inset_hull, /**/);
|
||||
LBUFERR(inset_hull, _("Error loading macro previews."));
|
||||
inset_hull->reloadPreview(*sit);
|
||||
}
|
||||
cur.screenUpdateFlags(Update::Force);
|
||||
|
@ -320,11 +320,13 @@ void docbookParagraphs(Text const & text,
|
||||
odocstream & os,
|
||||
OutputParams const & runparams)
|
||||
{
|
||||
LASSERT(runparams.par_begin <= runparams.par_end,
|
||||
{ os << "<!-- Docbook Output Error -->\n"; return; });
|
||||
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
ParagraphList::const_iterator par = paragraphs.begin();
|
||||
ParagraphList::const_iterator pend = paragraphs.end();
|
||||
|
||||
LASSERT(runparams.par_begin <= runparams.par_end, /**/);
|
||||
// if only part of the paragraphs will be outputed
|
||||
if (runparams.par_begin != runparams.par_end) {
|
||||
par = boost::next(paragraphs.begin(), runparams.par_begin);
|
||||
|
@ -1041,6 +1041,9 @@ void latexParagraphs(Buffer const & buf,
|
||||
OutputParams const & runparams,
|
||||
string const & everypar)
|
||||
{
|
||||
LASSERT(runparams.par_begin <= runparams.par_end,
|
||||
{ os << "% LaTeX Output Error\n"; return; } );
|
||||
|
||||
BufferParams const & bparams = buf.params();
|
||||
|
||||
bool const maintext = text.isMainText();
|
||||
@ -1078,7 +1081,6 @@ void latexParagraphs(Buffer const & buf,
|
||||
}
|
||||
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
LASSERT(runparams.par_begin <= runparams.par_end, /**/);
|
||||
|
||||
if (runparams.par_begin == runparams.par_end) {
|
||||
// The full doc will be exported but it is easier to just rely on
|
||||
|
@ -822,7 +822,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
|
||||
// One is that we are still in the environment in which we
|
||||
// started---which we will be if the depth is the same.
|
||||
if (par->params().depth() == origdepth) {
|
||||
LASSERT(bstyle == style, /* */);
|
||||
LATTEST(bstyle == style);
|
||||
if (lastlay != 0) {
|
||||
closeItemTag(xs, *lastlay);
|
||||
lastlay = 0;
|
||||
@ -964,7 +964,8 @@ void xhtmlParagraphs(Text const & text,
|
||||
}
|
||||
pit_type bpit = runparams.par_begin;
|
||||
pit_type const epit = runparams.par_end;
|
||||
LASSERT(bpit < epit, /* */);
|
||||
LASSERT(bpit < epit,
|
||||
{ xs << XHTMLStream::ESCAPE_NONE << "<!-- XHTML output error! -->\n"; return; });
|
||||
|
||||
OutputParams ourparams = runparams;
|
||||
ParagraphList::const_iterator const pend =
|
||||
|
@ -91,8 +91,9 @@ RowPainter::RowPainter(PainterInfo & pi,
|
||||
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
|
||||
//row_.dump();
|
||||
|
||||
LASSERT(pit >= 0, /**/);
|
||||
LASSERT(pit < int(text.paragraphs().size()), /**/);
|
||||
LBUFERR(pit >= 0, _("Unable to initialize row painter!"));
|
||||
LBUFERR(pit < int(text.paragraphs().size()),
|
||||
_("Unable to initialize row painter!"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ FileName::FileName(string const & abs_filename)
|
||||
: d(abs_filename.empty() ? new Private : new Private(abs_filename))
|
||||
{
|
||||
//LYXERR(Debug::FILES, "FileName(" << abs_filename << ')');
|
||||
LASSERT(empty() || isAbsolute(d->name), /**/);
|
||||
LATTEST(empty() || isAbsolute(d->name));
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ void FileName::set(string const & name)
|
||||
d->fi.setFile(toqstr(name));
|
||||
d->name = fromqstr(d->fi.absoluteFilePath());
|
||||
//LYXERR(Debug::FILES, "FileName::set(" << name << ')');
|
||||
LASSERT(empty() || isAbsolute(d->name), /**/);
|
||||
LATTEST(empty() || isAbsolute(d->name));
|
||||
}
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ void FileName::set(FileName const & rhs, string const & suffix)
|
||||
d->fi.setFile(QDir(rhs.d->fi.absoluteFilePath()), toqstr(suffix));
|
||||
d->name = fromqstr(d->fi.absoluteFilePath());
|
||||
//LYXERR(Debug::FILES, "FileName::set(" << d->name << ')');
|
||||
LASSERT(empty() || isAbsolute(d->name), /**/);
|
||||
LATTEST(empty() || isAbsolute(d->name));
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,7 +138,7 @@ docstring const getText(string const & m)
|
||||
// FIXME: gettext sometimes "forgets" the ucs4_codeset we set
|
||||
// in init(), which leads to severe message corruption (#7371)
|
||||
// We set it again here unconditionally. A real fix must be found!
|
||||
LASSERT(bind_textdomain_codeset(PACKAGE, ucs4_codeset), /**/);
|
||||
LATTEST(bind_textdomain_codeset(PACKAGE, ucs4_codeset));
|
||||
|
||||
char const * m_c = m.c_str();
|
||||
char const * trans_c = gettext(m_c);
|
||||
@ -204,7 +204,7 @@ docstring const Messages::get(string const & m) const
|
||||
pair<TranslationCache::iterator, bool> result =
|
||||
cache_.insert(make_pair(m, trans));
|
||||
|
||||
LASSERT(result.second, /**/);
|
||||
LASSERT(result.second, return from_utf8(m));
|
||||
|
||||
return result.first->second;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void init_package(string const & command_line_arg0,
|
||||
|
||||
Package const & package()
|
||||
{
|
||||
LASSERT(initialised_, /**/);
|
||||
LAPPERR(initialised_, _("Package not initialized."));
|
||||
return package_;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ Timeout & Timeout::setType(Type t)
|
||||
Timeout & Timeout::setTimeout(unsigned int msec)
|
||||
{
|
||||
// Can't have a timeout of zero!
|
||||
LASSERT(msec, /**/);
|
||||
LASSERT(msec, msec = 1000);
|
||||
|
||||
timeout_ms = msec;
|
||||
return *this;
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
/// Find the mapping for the first argument
|
||||
T2 const & find(T1 const & first) const
|
||||
{
|
||||
LASSERT(!map.empty(), /**/);
|
||||
LASSERT(!map.empty(), return default_t2);
|
||||
const_iterator it = map.begin();
|
||||
const_iterator end = map.end();
|
||||
for (; it != end; ++it)
|
||||
@ -75,7 +75,7 @@ public:
|
||||
/// Find the mapping for the second argument
|
||||
T1 const & find(T2 const & second) const
|
||||
{
|
||||
LASSERT(!map.empty(), /**/);
|
||||
LASSERT(!map.empty(), return default_t1);
|
||||
const_iterator it = map.begin();
|
||||
const_iterator end = map.end();
|
||||
for (; it != end; ++it)
|
||||
|
@ -40,7 +40,7 @@ docstring const from_ascii(char const * ascii)
|
||||
char_type *d = &s[0];
|
||||
while (--n >= 0) {
|
||||
d[n] = ascii[n];
|
||||
LASSERT(static_cast<unsigned char>(ascii[n]) < 0x80, /**/);
|
||||
LATTEST(static_cast<unsigned char>(ascii[n]) < 0x80);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
@ -51,7 +51,7 @@ docstring const from_ascii(string const & ascii)
|
||||
{
|
||||
int const len = ascii.length();
|
||||
for (int i = 0; i < len; ++i)
|
||||
LASSERT(static_cast<unsigned char>(ascii[i]) < 0x80, /**/);
|
||||
LATTEST(static_cast<unsigned char>(ascii[i]) < 0x80);
|
||||
return docstring(ascii.begin(), ascii.end());
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ string const to_ascii(docstring const & ucs4)
|
||||
string ascii;
|
||||
ascii.resize(len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
LASSERT(ucs4[i] < 0x80, /**/);
|
||||
LATTEST(ucs4[i] < 0x80);
|
||||
ascii[i] = static_cast<char>(ucs4[i]);
|
||||
}
|
||||
return ascii;
|
||||
@ -183,7 +183,7 @@ bool operator==(lyx::docstring const & l, char const * r)
|
||||
lyx::docstring::const_iterator it = l.begin();
|
||||
lyx::docstring::const_iterator end = l.end();
|
||||
for (; it != end; ++it, ++r) {
|
||||
LASSERT(static_cast<unsigned char>(*r) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(*r) < 0x80, return false);
|
||||
if (!*r)
|
||||
return false;
|
||||
if (*it != static_cast<lyx::docstring::value_type>(*r))
|
||||
@ -197,7 +197,7 @@ lyx::docstring operator+(lyx::docstring const & l, char const * r)
|
||||
{
|
||||
lyx::docstring s(l);
|
||||
for (char const * c = r; *c; ++c) {
|
||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, return l);
|
||||
s.push_back(*c);
|
||||
}
|
||||
return s;
|
||||
@ -208,7 +208,7 @@ lyx::docstring operator+(char const * l, lyx::docstring const & r)
|
||||
{
|
||||
lyx::docstring s;
|
||||
for (char const * c = l; *c; ++c) {
|
||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, return r);
|
||||
s.push_back(*c);
|
||||
}
|
||||
s += r;
|
||||
@ -218,7 +218,7 @@ lyx::docstring operator+(char const * l, lyx::docstring const & r)
|
||||
|
||||
lyx::docstring operator+(lyx::docstring const & l, char r)
|
||||
{
|
||||
LASSERT(static_cast<unsigned char>(r) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(r) < 0x80, return l);
|
||||
docstring s = l;
|
||||
s += docstring::value_type(r);
|
||||
return s;
|
||||
@ -227,7 +227,7 @@ lyx::docstring operator+(lyx::docstring const & l, char r)
|
||||
|
||||
lyx::docstring operator+(char l, lyx::docstring const & r)
|
||||
{
|
||||
LASSERT(static_cast<unsigned char>(l) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(l) < 0x80, return r);
|
||||
return lyx::docstring::value_type(l) + r;
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ lyx::docstring operator+(char l, lyx::docstring const & r)
|
||||
lyx::docstring & operator+=(lyx::docstring & l, char const * r)
|
||||
{
|
||||
for (char const * c = r; *c; ++c) {
|
||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(*c) < 0x80, return l);
|
||||
l.push_back(*c);
|
||||
}
|
||||
return l;
|
||||
@ -244,7 +244,7 @@ lyx::docstring & operator+=(lyx::docstring & l, char const * r)
|
||||
|
||||
lyx::docstring & operator+=(lyx::docstring & l, char r)
|
||||
{
|
||||
LASSERT(static_cast<unsigned char>(r) < 0x80, /**/);
|
||||
LASSERT(static_cast<unsigned char>(r) < 0x80, return l);
|
||||
l.push_back(r);
|
||||
return l;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace {
|
||||
*/
|
||||
inline char_type qchar_to_ucs4(QChar const & qchar)
|
||||
{
|
||||
LASSERT(is_utf16(static_cast<char_type>(qchar.unicode())), /**/);
|
||||
LASSERT(is_utf16(static_cast<char_type>(qchar.unicode())), return '?');
|
||||
return static_cast<char_type>(qchar.unicode());
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ inline char_type qchar_to_ucs4(QChar const & qchar)
|
||||
*/
|
||||
inline QChar const ucs4_to_qchar(char_type const ucs4)
|
||||
{
|
||||
LASSERT(is_utf16(ucs4), /**/);
|
||||
LASSERT(is_utf16(ucs4), return QChar('?'));
|
||||
return QChar(static_cast<unsigned short>(ucs4));
|
||||
}
|
||||
|
||||
@ -409,14 +409,14 @@ bool isAscii(string const & str)
|
||||
|
||||
char lowercase(char c)
|
||||
{
|
||||
LASSERT(isASCII(c), /**/);
|
||||
LASSERT(isASCII(c), return '?');
|
||||
return char(tolower(c));
|
||||
}
|
||||
|
||||
|
||||
char uppercase(char c)
|
||||
{
|
||||
LASSERT(isASCII(c), /**/);
|
||||
LASSERT(isASCII(c), return '?');
|
||||
return char(toupper(c));
|
||||
}
|
||||
|
||||
@ -824,7 +824,7 @@ template<typename String> inline
|
||||
String const subst_string(String const & a,
|
||||
String const & oldstr, String const & newstr)
|
||||
{
|
||||
LASSERT(!oldstr.empty(), /**/);
|
||||
LASSERT(!oldstr.empty(), return a);
|
||||
String lstr = a;
|
||||
size_t i = 0;
|
||||
size_t const olen = oldstr.length();
|
||||
@ -840,7 +840,7 @@ String const subst_string(String const & a,
|
||||
docstring const subst_string(docstring const & a,
|
||||
docstring const & oldstr, docstring const & newstr)
|
||||
{
|
||||
LASSERT(!oldstr.empty(), /**/);
|
||||
LASSERT(!oldstr.empty(), return a);
|
||||
docstring lstr = a;
|
||||
size_t i = 0;
|
||||
size_t const olen = oldstr.length();
|
||||
@ -909,7 +909,7 @@ int count_char(docstring const & str, docstring::value_type chr)
|
||||
|
||||
docstring const trim(docstring const & a, char const * p)
|
||||
{
|
||||
LASSERT(p, /**/);
|
||||
LASSERT(p, return a);
|
||||
|
||||
if (a.empty() || !*p)
|
||||
return a;
|
||||
@ -928,7 +928,7 @@ docstring const trim(docstring const & a, char const * p)
|
||||
|
||||
string const trim(string const & a, char const * p)
|
||||
{
|
||||
LASSERT(p, /**/);
|
||||
LASSERT(p, return a);
|
||||
|
||||
if (a.empty() || !*p)
|
||||
return a;
|
||||
@ -946,7 +946,7 @@ string const trim(string const & a, char const * p)
|
||||
|
||||
string const rtrim(string const & a, char const * p)
|
||||
{
|
||||
LASSERT(p, /**/);
|
||||
LASSERT(p, return a);
|
||||
|
||||
if (a.empty() || !*p)
|
||||
return a;
|
||||
@ -963,7 +963,7 @@ string const rtrim(string const & a, char const * p)
|
||||
|
||||
docstring const rtrim(docstring const & a, char const * p)
|
||||
{
|
||||
LASSERT(p, /**/);
|
||||
LASSERT(p, return a);
|
||||
|
||||
if (a.empty() || !*p)
|
||||
return a;
|
||||
@ -980,7 +980,7 @@ docstring const rtrim(docstring const & a, char const * p)
|
||||
|
||||
string const ltrim(string const & a, char const * p)
|
||||
{
|
||||
LASSERT(p, /**/);
|
||||
LASSERT(p, return a);
|
||||
if (a.empty() || !*p)
|
||||
return a;
|
||||
size_t l = a.find_first_not_of(p);
|
||||
@ -992,7 +992,7 @@ string const ltrim(string const & a, char const * p)
|
||||
|
||||
docstring const ltrim(docstring const & a, char const * p)
|
||||
{
|
||||
LASSERT(p, /**/);
|
||||
LASSERT(p, return a);
|
||||
if (a.empty() || !*p)
|
||||
return a;
|
||||
size_t l = a.find_first_not_of(from_ascii(p));
|
||||
@ -1119,7 +1119,7 @@ docstring const escape(docstring const & lab)
|
||||
// encode bigger values. Test for 2^24 because we
|
||||
// can encode that with the 6 hex digits that are
|
||||
// needed for 21 bits anyway.
|
||||
LASSERT(c < (1 << 24), /**/);
|
||||
LASSERT(c < (1 << 24), continue);
|
||||
enc += '=';
|
||||
enc += hexdigit[(c>>20) & 15];
|
||||
enc += hexdigit[(c>>16) & 15];
|
||||
@ -1327,7 +1327,7 @@ int findToken(char const * const str[], string const & search_token)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$d")));
|
||||
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
}
|
||||
@ -1336,7 +1336,7 @@ docstring bformat(docstring const & fmt, int arg1)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, long arg1)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$d")));
|
||||
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
}
|
||||
@ -1345,7 +1345,7 @@ docstring bformat(docstring const & fmt, long arg1)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, unsigned int arg1)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$d")));
|
||||
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
}
|
||||
@ -1354,7 +1354,7 @@ docstring bformat(docstring const & fmt, unsigned int arg1)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, docstring arg1)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
docstring const str = subst(fmt, from_ascii("%1$s"), arg1);
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
}
|
||||
@ -1363,7 +1363,7 @@ docstring bformat(docstring const & fmt, docstring arg1)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, char * arg1)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
docstring const str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
}
|
||||
@ -1372,8 +1372,8 @@ docstring bformat(docstring const & fmt, char * arg1)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%2$s")));
|
||||
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
|
||||
str = subst(str, from_ascii("%2$s"), arg2);
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
@ -1383,8 +1383,8 @@ docstring bformat(docstring const & fmt, docstring arg1, docstring arg2)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, docstring arg1, int arg2)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%2$d")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%2$d")));
|
||||
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
|
||||
str = subst(str, from_ascii("%2$d"), convert<docstring>(arg2));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
@ -1394,8 +1394,8 @@ docstring bformat(docstring const & fmt, docstring arg1, int arg2)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%2$s")));
|
||||
docstring str = subst(fmt, from_ascii("%1$s"), from_ascii(arg1));
|
||||
str = subst(fmt, from_ascii("%2$s"), arg2);
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
@ -1405,8 +1405,8 @@ docstring bformat(docstring const & fmt, char const * arg1, docstring arg2)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1, int arg2)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$d")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%2$d")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$d")));
|
||||
LATTEST(contains(fmt, from_ascii("%2$d")));
|
||||
docstring str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
|
||||
str = subst(str, from_ascii("%2$d"), convert<docstring>(arg2));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
@ -1416,9 +1416,9 @@ docstring bformat(docstring const & fmt, int arg1, int arg2)
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, docstring arg1, docstring arg2, docstring arg3)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%3$s")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%2$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%3$s")));
|
||||
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
|
||||
str = subst(str, from_ascii("%2$s"), arg2);
|
||||
str = subst(str, from_ascii("%3$s"), arg3);
|
||||
@ -1430,10 +1430,10 @@ template<>
|
||||
docstring bformat(docstring const & fmt,
|
||||
docstring arg1, docstring arg2, docstring arg3, docstring arg4)
|
||||
{
|
||||
LASSERT(contains(fmt, from_ascii("%1$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%2$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%3$s")), /**/);
|
||||
LASSERT(contains(fmt, from_ascii("%4$s")), /**/);
|
||||
LATTEST(contains(fmt, from_ascii("%1$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%2$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%3$s")));
|
||||
LATTEST(contains(fmt, from_ascii("%4$s")));
|
||||
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
|
||||
str = subst(str, from_ascii("%2$s"), arg2);
|
||||
str = subst(str, from_ascii("%3$s"), arg3);
|
||||
|
@ -227,7 +227,7 @@ void init(int argc, char * argv[])
|
||||
|
||||
string utf8_argv(int i)
|
||||
{
|
||||
LASSERT(i < argc_, /**/);
|
||||
LASSERT(i < argc_, return "");
|
||||
return to_utf8(from_local8bit(argv_[i]));
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ void init(int argc, char * argv[])
|
||||
|
||||
string utf8_argv(int i)
|
||||
{
|
||||
LASSERT(i < argc_, /**/);
|
||||
LASSERT(i < argc_, return "");
|
||||
return to_utf8(from_local8bit(argv_[i]));
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void init(int argc, char * argv[])
|
||||
wchar_t ** envp = 0;
|
||||
int newmode = 0;
|
||||
__wgetmainargs(&argc_, &argv_, &envp, -1, &newmode);
|
||||
LASSERT(argc == argc_, /**/);
|
||||
LATTEST(argc == argc_);
|
||||
|
||||
// If Cygwin is detected, query the cygdrive prefix.
|
||||
// The cygdrive prefix is needed for translating windows style paths
|
||||
@ -212,7 +212,7 @@ void init(int argc, char * argv[])
|
||||
|
||||
string utf8_argv(int i)
|
||||
{
|
||||
LASSERT(i < argc_, /**/);
|
||||
LASSERT(i < argc_, return "");
|
||||
return fromqstr(QString::fromWCharArray(argv_[i]));
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ static QString const get_long_path(QString const & short_path)
|
||||
long_path.resize(result);
|
||||
result = GetLongPathNameW((wchar_t *) short_path.utf16(),
|
||||
&long_path[0], long_path.size());
|
||||
LASSERT(result <= long_path.size(), /**/);
|
||||
LATTEST(result <= long_path.size());
|
||||
}
|
||||
|
||||
return (result == 0) ? short_path : QString::fromWCharArray(&long_path[0]);
|
||||
@ -339,7 +339,7 @@ static QString const get_short_path(QString const & long_path, file_access how)
|
||||
short_path.resize(result);
|
||||
result = GetShortPathNameW((wchar_t *) long_path.utf16(),
|
||||
&short_path[0], short_path.size());
|
||||
LASSERT(result <= short_path.size(), /**/);
|
||||
LATTEST(result <= short_path.size());
|
||||
}
|
||||
|
||||
return (result == 0) ? long_path : QString::fromWCharArray(&short_path[0]);
|
||||
@ -514,7 +514,7 @@ string const GetFolderPath::operator()(folder_id _id) const
|
||||
id = CSIDL_APPDATA;
|
||||
break;
|
||||
default:
|
||||
LASSERT(false, /**/);
|
||||
LASSERT(false, return string());
|
||||
}
|
||||
HRESULT const result = (folder_path_func_)(0, id, 0,
|
||||
SHGFP_TYPE_CURRENT,
|
||||
|
@ -46,7 +46,7 @@ docstring const user_name()
|
||||
return from_local8bit(name);
|
||||
#else
|
||||
struct passwd * pw = getpwuid(geteuid());
|
||||
LASSERT(pw, /**/);
|
||||
LASSERT(pw, return docstring());
|
||||
|
||||
const string gecos = pw->pw_gecos;
|
||||
const size_t pos = gecos.find(",");
|
||||
|
Loading…
Reference in New Issue
Block a user