[PyKDE] KMimeType.findByPath return value

Jim Bublitz jbublitz at nwinternet.com
Fri Jan 3 21:17:00 GMT 2003


On 03-Jan-03 Daniel Naber wrote:
> On Thursday 02 January 2003 21:52, you wrote:
 
>> Can you use KTrader instead?
 
> Not really, it seems the name() problem also appears with
> KMimeType.findByURL() and findByPath(), these also
> sometimes(?!) return random characters. Sometimes
> the first call to those functions works, but the second returns
> crap or crashes. This  only happens if I click on the same file
> a second time in my GUI, the result is then different. I cannot
> reproduce this with a test case where the function is simply 
> called twice - this works.
 
>> If you can try an equivalent C++ version, that would be helpful.
 
> This seems to work:
 
>   QString name =
> KMimeType::findByURL(KURL("/home/dnaber/desktopdig/test/test1.html
> "))->name();
>   printf("name=%s\n", name.latin1());
 
>   KService::Ptr ptr = KServiceTypeProfile::preferredService(name,
> "Application");
>   QString name2 = ptr->name();
>   printf("name2=%s\n", name2.latin1());
>   if( ptr->isValid() ) {
>     printf("isValid");
>   } else {
>     printf("not isValid()");
>   }
 
> The output is correct:
 
> name=text/html
> name2=Konqueror
> isValid
 
> For now I will avoid all the problems by disabling the feature
> that I'm trying to implememt (namely a security warning like
> "Do you want to open the file with %s"  % offer.name()).
> Nonetheless, it would be great to get this fixed, as it's
> important for the software's security. Thanks for all your
> support so far.

Thanks for the C++ test - that's a big help. It appears that the
problem is with PyKDE. I'll get to it as soon as I can - hopefully
within the next week.

I wasn't able to get any result back for name() - no crash at that
point in the program, but a crash on exit. There are several pieces
of handwritten code to handle the SharedPtr template stuff for
those classes and the error is probably somewhere in that code,
possibly an incorrect assignment or something getting freed in the
wrong place, Both Python and the SharedPtr stuff use reference
counting.


Jim




More information about the PyQt mailing list