diff --git a/src/ksanewidget.h b/src/ksanewidget.h --- a/src/ksanewidget.h +++ b/src/ksanewidget.h @@ -211,7 +211,8 @@ /** This method can be used to write many parameter values at once. * @param opts is a QMap with the parameter names and values. - * @return This function returns the number of successful writes. */ + * @return This function returns the number of successful writes + * or -1 if scanning is in progress. */ int setOptVals(const QMap &opts); /** This function reads one parameter value into a string. @@ -223,7 +224,8 @@ /** This function writes one parameter value into a string. * @param optname is the name of the parameter to write. * @param value is the string representation of the value. - * @return this function returns true if the write was successful. */ + * @return this function returns true if the write was successful and + * false if it was unsuccessful or scanning is in progress. */ bool setOptVal(const QString &optname, const QString &value); /** This function sets the label on the final scan button diff --git a/src/ksanewidget.cpp b/src/ksanewidget.cpp --- a/src/ksanewidget.cpp +++ b/src/ksanewidget.cpp @@ -718,6 +718,11 @@ int KSaneWidget::setOptVals(const QMap &opts) { + if (d->m_scanThread->isRunning() || + d->m_previewThread->isRunning()) { + return -1; + } + QString tmp; int i; int ret = 0; @@ -766,6 +771,11 @@ bool KSaneWidget::setOptVal(const QString &option, const QString &value) { + if (d->m_scanThread->isRunning() || + d->m_previewThread->isRunning()) { + return false; + } + KSaneOption *opt; if ((opt = d->getOption(option)) != nullptr) {