the attached patch should do it...
On 03/16/2011 03:20 PM, Vishesh Handa wrote:
>
>
> On Wed, Mar 16, 2011 at 7:37 PM, Sebastian Trüg <[email protected]
> <mailto:[email protected]>> wrote:
>
> OK, so we only need a stopQuery() in the setQuery method, right? IMHO
> that is much cleaner and easier to understand than setting current query
> to 0.
>
>
> That too won't work. Here is why -
>
> You run a query A, it finishes executing itself and then deletes itself.
> You then run query B, it will try to stop query A by deleting it. But
> since it has already been deleted - Crash.
>
> The only way I could think of solving this was by checking if the query
> we were getting results for was the m_currentQuery, and otherwise
> deleting it. That code was removed in the patch provided.
>
>
> On 03/16/2011 02:58 PM, Vishesh Handa wrote:
> > This patch ( now committed ) is not that useful.
> >
> > The only thing it does is sets the time elapsed when you click the
> "Stop
> > Query" button. And it removes the old code which allowed you to
> > automatically stop the old query if you ran a new one.
> >
> > When a query finishes execution, or is closed, it automatically
> deletes
> > itself and therefore disconnects itself from all signals and slots.
> >
> > I know the setting of 'd->m_currentQuery = 0' was not completely
> > obvious. But it did what it was supposed to. The query if it was still
> > being executed would have been deleted when more results were received
> > in slotNextResultReady()
> >
> > I'll either revert this patch or fix it.
> >
> > On Wed, Mar 16, 2011 at 4:37 PM, Who Knows <[email protected]
> <mailto:[email protected]>
> > <mailto:[email protected] <mailto:[email protected]>>> wrote:
> >
> > The previous patch affected the copyright somehow so i am
> sending a
> > new one.
> >
> >
> > - Smit Shah (My real name)
> >
> > _______________________________________________
> > Nepomuk mailing list
> > [email protected] <mailto:[email protected]>
> <mailto:[email protected] <mailto:[email protected]>>
> > https://mail.kde.org/mailman/listinfo/nepomuk
> >
> >
> >
> >
> > --
> > Vishesh Handa
> >
> >
> >
> > _______________________________________________
> > Nepomuk mailing list
> > [email protected] <mailto:[email protected]>
> > https://mail.kde.org/mailman/listinfo/nepomuk
> _______________________________________________
> Nepomuk mailing list
> [email protected] <mailto:[email protected]>
> https://mail.kde.org/mailman/listinfo/nepomuk
>
>
>
>
> --
> Vishesh Handa
diff --git a/querymodel.cpp b/querymodel.cpp
index 6e67d7a..92874e0 100644
--- a/querymodel.cpp
+++ b/querymodel.cpp
@@ -68,7 +68,8 @@ public:
Nepomuk::QueryModel::Private::Private(Nepomuk::QueryModel* parent)
- : q( parent )
+ : q( parent ),
+ m_currentQuery(0)
{
}
@@ -197,6 +198,7 @@ QVariant Nepomuk::QueryModel::headerData( int section,
Qt::Orientation orientati
void Nepomuk::QueryModel::setQuery( const QString& query )
{
+ stopQuery();
d->m_query = query;
d->updateQuery();
reset();
@@ -247,6 +249,8 @@ void
Nepomuk::QueryModel::slotNextResultReady(Soprano::Util::AsyncQuery* query)
void Nepomuk::QueryModel::slotQueryFinished(Soprano::Util::AsyncQuery* query)
{
+ d->m_currentQuery = 0;
+
//FIXME: This doesn't work!
Soprano::Model* model = ResourceManager::instance()->mainModel();
kDebug() << model->lastError().message();
@@ -268,6 +272,7 @@ void Nepomuk::QueryModel::stopQuery()
if(d->m_currentQuery) {
d->m_currentQuery->close();
d->m_currentQuery->disconnect(this);
+ d->m_currentQuery = 0;
d->m_queryTime = d->m_queryTimer.elapsed();
emit queryFinished();
}
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk