author | llornkcor <llornkcor> | 2002-07-16 23:46:36 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-16 23:46:36 (UTC) |
commit | 238f77dac6c82b420e2e6334fabf9b7744abd844 (patch) (side-by-side diff) | |
tree | 23771c76cb5ffa8da248ae4977ec13e36c5cb62f | |
parent | 6d5261a534612f0f993caca801e7c7e1a5c74f32 (diff) | |
download | opie-238f77dac6c82b420e2e6334fabf9b7744abd844.zip opie-238f77dac6c82b420e2e6334fabf9b7744abd844.tar.gz opie-238f77dac6c82b420e2e6334fabf9b7744abd844.tar.bz2 |
fix for initial start crash when there's no config file
-rw-r--r-- | noncore/apps/opie-reader/QTReader.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index fc9cffb..6335ea2 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp @@ -628,96 +628,97 @@ void QTReader::paintEvent( QPaintEvent * ) // // Called when the widget has been resized. // Moves the button group to the upper right corner // of the widget. /* void QTReader::resizeEvent( QResizeEvent * ) { // qDebug("resize:(%u,%u)", width(), height()); // bgroup->move( width()-bgroup->width(), 0 ); } */ // // Create and display our widget. // /* int main( int argc, tchar **argv ) { QApplication app( argc, argv ); QTReader draw; app.setMainWidget( &draw ); draw.setCaption("Qt Example - Drawdemo"); draw.show(); return app.exec(); } */ bool QTReader::locate(unsigned long n) { //printf("Locate\n"); buffdoc.locate(n); // qDebug("&buffdoc.located"); fillbuffer(); // qDebug("&Buffer filled"); update(); // qDebug("&Located"); return true; } unsigned int QTReader::screenlines() { // int linespacing = (tight) ? m_ascent : m_ascent+m_descent; // return (height()-m_descent)/(m_linespacing); return (height()-2)/(m_linespacing); }; bool QTReader::fillbuffer() { + if (buffdoc.empty()) return false; //printf("Fillbuffer\n"); m_scrolldy = 0; int ch; bool ret = false; int delta = screenlines(); // qDebug("fillbuffer:%u-%u",delta,numlines); if (delta != numlines) { if (textarray != NULL) { for (int i = 0; i < numlines; i++) delete textarray[i]; delete [] textarray; delete [] locnarray; } numlines = delta; textarray = new CBuffer*[numlines]; locnarray = new size_t[numlines]; for (int i = 0; i < numlines; i++) textarray[i] = new CBuffer; } // qDebug("fillbuffer:pagepos:%u",pagepos); unsigned int oldpagepos = pagepos; // if (textarray != NULL) // pagepos = locnarray[0]; // else pagepos = locate(); for (int i = 0; i < delta; i++) { locnarray[i] = locate(); ch = getline(textarray[i]); // if (ch == EOF) { if (!ch) { if (i == 0) { locate(oldpagepos); return false; } else { ret = true; for (int j = i+1; j < delta; j++) { locnarray[j] = locnarray[j-1]; (*(textarray[j]))[0] = '\0'; } break; } } |