summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/osplitter.cpp2
-rw-r--r--library/qpeapplication.cpp10
-rw-r--r--noncore/applets/pcmcia/pcmcia.cpp6
-rw-r--r--noncore/apps/checkbook/mainwindow.cpp7
-rw-r--r--noncore/apps/opie-console/procctl.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katedocument.cpp123
-rw-r--r--noncore/settings/sysinfo/devicesinfo.cpp2
-rw-r--r--noncore/todayplugins/stockticker/libstocks/http.c2
8 files changed, 83 insertions, 74 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp
index 78e919a..5d1e2cf 100644
--- a/libopie2/opieui/big-screen/osplitter.cpp
+++ b/libopie2/opieui/big-screen/osplitter.cpp
@@ -206,49 +206,49 @@ void OSplitter::removeWidget( OSplitter* split)
* @param label The label of the possible Tab
*/
void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label )
{
#ifdef DEBUG
if (!wid )
return;
#endif
OSplitterContainer cont;
cont.widget = wid;
cont.icon =icon;
cont.name = label;
m_container.append( cont );
/*
*
*/
if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) )
setTabWidget( m_parentTab );
else
{
if (m_hbox )
addToBox( cont );
- else
+ else if (m_tabWidget)
addToTab( cont );
}
}
/**
* Removes the widget from the tab widgets if necessary.
* OSplitter drops ownership of this widget and the widget
* will be reparented i tto 0.
* The widget will not be deleted.
*
* @param w The widget to be removed
*/
void OSplitter::removeWidget( QWidget* w)
{
ContainerList::Iterator it;
for ( it = m_container.begin(); it != m_container.end(); ++it )
if ( (*it).widget == w )
break;
if (it == m_container.end() )
return;
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 34f5e6a..d959c7a 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1748,54 +1748,54 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
Sets widget \a mw as the mainWidget() and shows it. For small windows,
consider passing TRUE for \a nomaximize rather than the default FALSE.
\sa showMainDocumentWidget()
*/
void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
{
// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
d->show(mw, nomaximize );
}
/*!
Sets widget \a mw as the mainWidget() and shows it. For small windows,
consider passing TRUE for \a nomaximize rather than the default FALSE.
This calls designates the application as
a \link docwidget.html document-oriented\endlink application.
The \a mw widget \e must have this slot: setDocument(const QString&).
\sa showMainWidget()
*/
void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
{
- if ( mw && argc() == 2 )
- Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
+ if ( mw ) {
+ if ( argc() == 2 )
+ Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
-
-// setMainWidget(mw); see above
- d->show(mw, nomaximize );
+ d->show(mw, nomaximize );
+ }
}
/*!
If an application is started via a \link qcop.html QCop\endlink
message, the application will process the \link qcop.html
QCop\endlink message and then quit. If the application calls this
function while processing a \link qcop.html QCop\endlink message,
after processing its outstanding \link qcop.html QCop\endlink
messages the application will start 'properly' and show itself.
\sa keepRunning()
*/
void QPEApplication::setKeepRunning()
{
if ( qApp && qApp->inherits( "QPEApplication" ) ) {
QPEApplication * qpeApp = ( QPEApplication* ) qApp;
qpeApp->d->keep_running = TRUE;
}
}
/*!
Returns TRUE if the application will quit after processing the
current list of qcop messages; otherwise returns FALSE.
diff --git a/noncore/applets/pcmcia/pcmcia.cpp b/noncore/applets/pcmcia/pcmcia.cpp
index 187adc6..c639002 100644
--- a/noncore/applets/pcmcia/pcmcia.cpp
+++ b/noncore/applets/pcmcia/pcmcia.cpp
@@ -215,48 +215,54 @@ void PcmciaManager::cardMessage( const QCString & msg, const QByteArray & )
++it;
continue;
}
else
{
theCard = it.current();
QString cardName = theCard->productIdentity();
for ( int i = 0; i < nCards; ++i )
{
QString cardSection = QString( "Card_%1" ).arg( i );
cfg.setGroup( cardSection );
QString name = cfg.readEntry( "name" );
odebug << "pcmcia: comparing card '" << cardName << "' with known card '" << name << "'" << oendl;
if ( cardName == name )
{
newCard = false;
odebug << "pcmcia: we have seen this card before" << oendl;
executeAction( theCard, "insert" );
break;
}
}
if ( !newCard ) ++it; else break;
}
}
+
+ if ( !theCard ) {
+ owarn << "pcmcia: Finished working through cards in PCMCIA system but I do not have a valid card handle" << oendl;
+ return;
+ }
+
if ( newCard )
{
odebug << "pcmcia: unconfigured card detected" << oendl;
QString newCardName = theCard->productIdentity();
int result = QMessageBox::information( qApp->desktop(),
tr( "PCMCIA/CF Subsystem" ),
tr( "<qt>You have inserted the card<br/><b>%1</b><br/>This card is not yet configured. Do you want to configure it now?</qt>" ).arg( newCardName ),
tr( "Yes" ), tr( "No" ), 0, 0, 1 );
odebug << "pcmcia: result = " << result << oendl;
if ( result == 0 )
{
configure( theCard );
}
else
{
odebug << "pcmcia: user doesn't want to configure " << newCardName << " now." << oendl;
}
}
else // it's an already configured card
{
odebug << "pcmcia: doing nothing... why do we come here?" << oendl;
}
}
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp
index d9e2047..8e2e2e3 100644
--- a/noncore/apps/checkbook/mainwindow.cpp
+++ b/noncore/apps/checkbook/mainwindow.cpp
@@ -222,86 +222,85 @@ void MainWindow::slotNew()
cb->setFilename( tempFilename );
cb->write();
// Add to listbox
checkbooks->inSort( cb );
addCheckbook( cb );
}
delete currcb;
}
// --- slotEdit ---------------------------------------------------------------
void MainWindow::slotEdit()
{
// get name and open it
QListViewItem *curritem = cbList->currentItem();
if ( !curritem )
return;
openBook( curritem );
}
// --- openBook ---------------------------------------------------------------
void MainWindow::openBook(QListViewItem *curritem)
{
+ if ( !curritem ) return;
// find book in List
QString currname=curritem->text(posName);
CBInfo *cb = checkbooks->first();
while ( cb ) {
if ( cb->name() == currname )
break;
cb = checkbooks->next();
}
if ( !cb ) return;
//
buildFilename( currname );
float currbalance = cb->balance();
bool currlock = !cb->password().isNull();
if ( currlock )
{
Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) );
if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() )
{
delete pw;
return;
}
delete pw;
}
_cfg.setLastBook( currname );
Checkbook *currcb = new Checkbook( this, cb, &_cfg );
if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted )
{
QString newname = cb->name();
if ( currname != newname )
{
// Update name if changed
- if( curritem ) {
- curritem->setText( posName, newname );
- cbList->sort();
- }
+ curritem->setText( posName, newname );
+ cbList->sort();
_cfg.setLastBook( newname );
// Remove old file
QFile f( tempFilename );
if ( f.exists() )
f.remove();
// Get new filename
buildFilename( newname );
cb->setFilename( tempFilename );
}
cb->write();
// Update lock if changed
if ( _cfg.getShowLocks() && !cb->password().isNull() != currlock )
{
if ( !cb->password().isNull() )
curritem->setPixmap( 0, lockIcon );
else
curritem->setPixmap( 0, nullIcon );
}
// Update balance if changed
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index a44529b..5239e26 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -28,49 +28,52 @@ void ProcCtl::add(pid_t pi, int fd ) {
con->prev = m_last;
m_last = con;
}
void ProcCtl::remove( pid_t pi ) {
/*
* We first check if the last item
* is equal to pi the we
*
*/
ProcContainer* con;
if (m_last->pid == pi ) {
con = m_last;
m_last = con->prev;
delete con;
return;
}
con = m_last;
ProcContainer* forw = 0l;
while (con ) {
/* remove it */
if ( pi == con->pid ) {
- forw->prev = con->prev;
+ if (forw)
+ forw->prev = con->prev;
+ else
+ forw = con->prev;
delete con;
return;
}
forw = con;
con = con->prev;
}
}
void ProcCtl::remove( ProcContainer con ) {
remove( con.pid );
}
int ProcCtl::status(pid_t pid )const{
ProcContainer *con = m_last;
while (con) {
if (con->pid == pid )
return con->status;
con = con->prev;
}
return -1;
}
void ProcCtl::signal_handler(int) {
int status;
signal( SIGCHLD, signal_handler );
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp
index b82a86a..692fd46 100644
--- a/noncore/apps/tinykate/libkate/document/katedocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp
@@ -1994,261 +1994,261 @@ void KateDocument::updateViews(KateView *exclude) {
}
QColor &KateDocument::cursorCol(int x, int y) {
int attr;
Attribute *a;
TextLine::Ptr textLine = getTextLine(y);
attr = textLine->getRawAttr(x);
a = &m_attribs[attr & taAttrMask];
if (attr & taSelected) return a->selCol; else return a->col;
}
void KateDocument::paintTextLine(QPainter &paint, int line, int xStart, int xEnd, bool showTabs)
{
paintTextLine (paint, line, 0, xStart, xEnd, showTabs);
}
void KateDocument::paintTextLine(QPainter &paint, int line, int y, int xStart, int xEnd, bool showTabs)
{
TextLine::Ptr textLine;
int len;
const QChar *s;
int z, x;
QChar ch;
- Attribute *a = 0L;
+ Attribute *attrptr = 0L;
int attr, nextAttr;
int xs;
int xc, zc;
if (line > lastLine()) {
paint.fillRect(0, y, xEnd - xStart,fontHeight, colors[0]);
return;
}
textLine = getTextLine(line);
len = textLine->length();
s = textLine->getText();
// skip to first visible character
x = 0;
z = 0;
do {
xc = x;
zc = z;
if (z == len) break;
ch = s[z];//textLine->getChar(z);
if (ch == '\t') {
x += m_tabWidth - (x % m_tabWidth);
} else {
- a = &m_attribs[textLine->getAttr(z)];
-
- if (a->bold && a->italic)
- x += myFontMetricsBI.width(ch);
- else if (a->bold)
- x += myFontMetricsBold.width(ch);
- else if (a->italic)
- x += myFontMetricsItalic.width(ch);
- else
- x += myFontMetrics.width(ch);
+ attrptr = &m_attribs[textLine->getAttr(z)];
+
+ if (attrptr->bold && attrptr->italic)
+ x += myFontMetricsBI.width(ch);
+ else if (attrptr->bold)
+ x += myFontMetricsBold.width(ch);
+ else if (attrptr->italic)
+ x += myFontMetricsItalic.width(ch);
+ else
+ x += myFontMetrics.width(ch);
}
z++;
} while (x <= xStart);
// draw background
xs = xStart;
attr = textLine->getRawAttr(zc);
while (x < xEnd)
{
nextAttr = textLine->getRawAttr(z);
if ((nextAttr ^ attr) & taSelected)
{
if (attr & taSelected)
paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[1]);
else
paint.fillRect(xs - xStart, y, x - xs, fontHeight, colors[0]);
xs = x;
attr = nextAttr;
}
if (z == len) break;
ch = s[z];//textLine->getChar(z);
if (ch == '\t')
x += m_tabWidth - (x % m_tabWidth);
else
{
- a = &m_attribs[textLine->getAttr(z)];
+ attrptr = &m_attribs[textLine->getAttr(z)];
- if (a->bold && a->italic)
+ if (attrptr->bold && attrptr->italic)
x += myFontMetricsBI.width(ch);
- else if (a->bold)
+ else if (attrptr->bold)
x += myFontMetricsBold.width(ch);
- else if (a->italic)
+ else if (attrptr->italic)
x += myFontMetricsItalic.width(ch);
else
x += myFontMetrics.width(ch);
}
z++;
}
if (attr & taSelected)
paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[1]);
else
paint.fillRect(xs - xStart, y, xEnd - xs, fontHeight, colors[0]);
len = z; //reduce length to visible length
// draw text
x = xc;
z = zc;
y += fontAscent;// -1;
attr = -1;
while (z < len) {
ch = s[z];//textLine->getChar(z);
if (ch == '\t') {
if (z > zc) {
//this should cause no copy at all
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
QString s = str.string();
paint.drawText(x - xStart, y, s);
- if (a->bold && a->italic)
- x += myFontMetricsBI.width(s);
- else if (a->bold)
- x += myFontMetricsBold.width(s);
- else if (a->italic)
- x += myFontMetricsItalic.width(s);
- else
- x += myFontMetrics.width(s);
+ if (attrptr && attrptr->bold && attrptr->italic)
+ x += myFontMetricsBI.width(s);
+ else if (attrptr && attrptr->bold)
+ x += myFontMetricsBold.width(s);
+ else if (attrptr && attrptr->italic)
+ x += myFontMetricsItalic.width(s);
+ else
+ x += myFontMetrics.width(s);
}
zc = z +1;
if (showTabs) {
nextAttr = textLine->getRawAttr(z);
if (nextAttr != attr) {
attr = nextAttr;
- a = &m_attribs[attr & taAttrMask];
-
- if (attr & taSelected) paint.setPen(a->selCol);
- else paint.setPen(a->col);
-
- if (a->bold && a->italic)
- paint.setFont(myFontBI);
- else if (a->bold)
- paint.setFont(myFontBold);
- else if (a->italic)
- paint.setFont(myFontItalic);
- else
- paint.setFont(myFont);
+ attrptr = &m_attribs[attr & taAttrMask];
+
+ if (attr & taSelected) paint.setPen(attrptr->selCol);
+ else paint.setPen(attrptr->col);
+
+ if (attrptr->bold && attrptr->italic)
+ paint.setFont(myFontBI);
+ else if (attrptr->bold)
+ paint.setFont(myFontBold);
+ else if (attrptr->italic)
+ paint.setFont(myFontItalic);
+ else
+ paint.setFont(myFont);
}
-// paint.drawLine(x - xStart, y -2, x - xStart, y);
-// paint.drawLine(x - xStart, y, x - xStart + 2, y);
paint.drawPoint(x - xStart, y);
paint.drawPoint(x - xStart +1, y);
paint.drawPoint(x - xStart, y -1);
}
x += m_tabWidth - (x % m_tabWidth);
} else {
nextAttr = textLine->getRawAttr(z);
if (nextAttr != attr) {
if (z > zc) {
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
QString s = str.string();
paint.drawText(x - xStart, y, s);
- if (a->bold && a->italic)
- x += myFontMetricsBI.width(s);
- else if (a->bold)
- x += myFontMetricsBold.width(s);
- else if (a->italic)
- x += myFontMetricsItalic.width(s);
- else
- x += myFontMetrics.width(s);
+ if (attrptr->bold && attrptr->italic)
+ x += myFontMetricsBI.width(s);
+ else if (attrptr->bold)
+ x += myFontMetricsBold.width(s);
+ else if (attrptr->italic)
+ x += myFontMetricsItalic.width(s);
+ else
+ x += myFontMetrics.width(s);
zc = z;
}
attr = nextAttr;
- a = &m_attribs[attr & taAttrMask];
-
- if (attr & taSelected) paint.setPen(a->selCol);
- else paint.setPen(a->col);
-
- if (a->bold && a->italic)
- paint.setFont(myFontBI);
- else if (a->bold)
- paint.setFont(myFontBold);
- else if (a->italic)
- paint.setFont(myFontItalic);
- else
- paint.setFont(myFont);
+ attrptr = &m_attribs[attr & taAttrMask];
+
+ if (attr & taSelected) paint.setPen(attrptr->selCol);
+ else paint.setPen(attrptr->col);
+
+ if (attrptr->bold && attrptr->italic)
+ paint.setFont(myFontBI);
+ else if (attrptr->bold)
+ paint.setFont(myFontBold);
+ else if (attrptr->italic)
+ paint.setFont(myFontItalic);
+ else
+ paint.setFont(myFont);
}
}
z++;
}
if (z > zc) {
QConstString str((QChar *) &s[zc], z - zc /*+1*/);
paint.drawText(x - xStart, y, str.string());
}
}
// Applies the search context, and returns whether a match was found. If one is,
// the length of the string matched is also returned.
bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) {
int line, col;
int searchEnd;
int bufLen, tlen;
QChar *t;
TextLine::Ptr textLine;
int pos, newPos;
if (searchFor.isEmpty()) return false;
bufLen = 0;
t = 0L;
line = sc.cursor.y;
col = sc.cursor.x;
if (!(sc.flags & KateView::sfBackward)) {
//forward search
if (sc.flags & KateView::sfSelected) {
if (line < selectStart) {
line = selectStart;
col = 0;
}
searchEnd = selectEnd;
} else searchEnd = lastLine();
while (line <= searchEnd) {
textLine = getTextLine(line);
tlen = textLine->length();
if (tlen > bufLen) {
delete [] t;
bufLen = (tlen + 255) & (~255);
t = new QChar[bufLen];
- }
+ } else if (!t)
+ t = new QChar[bufLen];
+
memcpy(t, textLine->getText(), tlen*sizeof(QChar));
if (sc.flags & KateView::sfSelected) {
pos = 0;
do {
pos = textLine->findSelected(pos);
newPos = textLine->findUnselected(pos);
memset(&t[pos], 0, (newPos - pos)*sizeof(QChar));
pos = newPos;
} while (pos < tlen);
}
QString text(t, tlen);
if (sc.flags & KateView::sfWholeWords) {
// Until the end of the line...
while (col < tlen) {
// ...find the next match.
col = sc.search(text, col);
if (col != -1) {
// Is the match delimited correctly?
if (((col == 0) || (!m_highlight->isInWord(t[col]))) &&
((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) {
goto found;
}
else {
@@ -2267,49 +2267,50 @@ bool KateDocument::doSearch(SConfig &sc, const QString &searchFor) {
col = sc.search(text, col);
if (col != -1)
goto found;
}
col = 0;
line++;
}
} else {
// backward search
if (sc.flags & KateView::sfSelected) {
if (line > selectEnd) {
line = selectEnd;
col = -1;
}
searchEnd = selectStart;
} else searchEnd = 0;
while (line >= searchEnd) {
textLine = getTextLine(line);
tlen = textLine->length();
if (tlen > bufLen) {
delete [] t;
bufLen = (tlen + 255) & (~255);
t = new QChar[bufLen];
- }
+ } else if (!t)
+ t = new QChar[bufLen];
memcpy(t, textLine->getText(), tlen*sizeof(QChar));
if (sc.flags & KateView::sfSelected) {
pos = 0;
do {
pos = textLine->findSelected(pos);
newPos = textLine->findUnselected(pos);
memset(&t[pos], 0, (newPos - pos)*sizeof(QChar));
pos = newPos;
} while (pos < tlen);
}
if (col < 0 || col > tlen) col = tlen;
QString text(t, tlen);
if (sc.flags & KateView::sfWholeWords) {
// Until the beginning of the line...
while (col >= 0) {
// ...find the next match.
col = sc.search(text, col);
if (col != -1) {
// Is the match delimited correctly?
if (((col == 0) || (!m_highlight->isInWord(t[col]))) &&
((col + sc.matchedLength == tlen) || (!m_highlight->isInWord(t[col + sc.matchedLength])))) {
goto found;
diff --git a/noncore/settings/sysinfo/devicesinfo.cpp b/noncore/settings/sysinfo/devicesinfo.cpp
index 164d608..428cfd4 100644
--- a/noncore/settings/sysinfo/devicesinfo.cpp
+++ b/noncore/settings/sysinfo/devicesinfo.cpp
@@ -244,49 +244,49 @@ void UsbCategory::populate()
int usbcount = 0;
UsbDevice* lastDev = 0;
UsbDevice* dev = 0;
while ( !usbinfo.atEnd() )
{
QString line = usbinfo.readLine();
odebug << "got line '" << line << "'" << oendl;
if ( line.startsWith( "T:" ) )
{
sscanf(line.local8Bit().data(), "T: Bus=%2d Lev=%2d Prnt=%2d Port=%d Cnt=%2d Dev#=%3d Spd=%3f MxCh=%2d", &_bus, &_level, &_parent, &_port, &_count, &_device, &_speed, &_channels);
if ( !_level )
{
odebug << "adding new bus" << oendl;
dev = new UsbDevice( this, QString( "Generic USB Hub Device" ) );
lastDev = dev;
}
else
{
odebug << "adding new dev" << oendl;
dev = new UsbDevice( lastDev, QString( "Generic USB Hub Device" ) );
lastDev = dev;
}
}
- else if ( line.startsWith( "S: Product" ) )
+ else if ( dev && line.startsWith( "S: Product" ) )
{
int dp = line.find( '=' );
dev->setText( 0, dp != -1 ? line.right( line.length()-1-dp ) : "<unknown>" );
}
else
{
continue;
}
}
}
//=================================================================================================
Device::Device( Category* parent, const QString& name )
:OListViewItem( parent, name )
{
devinfo = static_cast<QWidget*>( listView()->parent() );
}
Device::Device( Device* parent, const QString& name )
:OListViewItem( parent, name )
{
devinfo = static_cast<QWidget*>( listView()->parent() );
}
diff --git a/noncore/todayplugins/stockticker/libstocks/http.c b/noncore/todayplugins/stockticker/libstocks/http.c
index 2f38f8a..cc78ab7 100644
--- a/noncore/todayplugins/stockticker/libstocks/http.c
+++ b/noncore/todayplugins/stockticker/libstocks/http.c
@@ -189,49 +189,49 @@ libstocks_return_code http_get(char *http_file, char *http_server, char **pdata)
free(data);
data = temp;
}
}
}
/* close socket */
#ifdef __UNIX__
close(s);
#elif __WINDOWS__
closesocket(s);
#endif
#ifdef DEBUG
printf("%s\n", data);
#endif
/* get headers to test status line */
/* and to split headers and content */
temp = data;
header_founded = 0;
while( !header_founded )
{
- if (*temp==0) return ERRRHEA;
+ if (!temp || *temp==0) return ERRRHEA;
if( *temp==0x0A )
{
/* test if it is the header end */
temp ++;
if (*temp == 0x0D) temp++;
if (*temp == 0x0A) header_founded = 1;
}
else
temp++;
}
*temp = 0;
temp++;
sscanf(data,"HTTP/1.%*d %03d",&error_code);
if (error_code != 200)
{
#ifdef DEBUG
printf(" HTTP error code : %d\n", error_code);
#endif
free(data);
return ERRPAHD;