[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: KDE/kdelibs/plasma
From:       Michel Hermier <michel.hermier () gmail ! com>
Date:       2008-12-10 12:45:10
Message-ID: 493FB9D6.8010909 () gmail ! com
[Download RAW message or body]

Aaron J. Seigo a écrit :
> SVN commit 894424 by aseigo:
>
> don't crash when a runner that doesn't exist is requested
> BUGS:170989,177162
>
>
>  M  +9 -2      runnermanager.cpp  
>
>
> --- trunk/KDE/kdelibs/plasma/runnermanager.cpp #894423:894424
> @@ -346,7 +346,11 @@
>          d->loadRunners();
>      }
>  
> -    return d->runners.value(name);
> +    if (d->runners.contains(name)) {
> +        return d->runners.value(name);
> +    }
> +
> +    return 0;
>  }
>   
I think this is wrong and suboptimal, you could have used:
return d->runners.value(name, 0)
instead if you really intended to force a null pointer on value not 
found instead of going thought the hash 2 times.
Thought the default constructed value should already be a 0 for pointer. 
So the first part is not necessary and should not crash.

Cheers,
   Michel

>  
>  RunnerContext *RunnerManager::searchContext() const
> @@ -428,7 +432,10 @@
>  
>      //if the name is not empty we will launch only the specified runner
>      if (!runnerName.isEmpty()) {
> -        runable.append(runner(runnerName));
> +        AbstractRunner *r = runner(runnerName);
> +        if (r) {
> +            runable.append(r);
> +        }
>      } else {
>          runable = d->runners.values();
>      }
>   

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic