[PyKDE] KMimeType.findByPath return value

Daniel Naber daniel.naber at t-online.de
Fri Jan 3 16:22:01 GMT 2003

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() ) {
  } else {
    printf("not isValid()");

The output is correct:


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.



More information about the PyQt mailing list