Skip to main content

Ralsina.Me — Roberto Alsina's website

Confused by QMimeSourceFactory

Ok, here it goes. If you are not flu­ent in Qt pro­gram­ming the fol­low­ing en­try will make no sense what­so­ev­er :-)

If you set the con­tents of a QTextBrowser, and the con­tent is HTM­L, it will call its QMime­Source­Fac­to­ry's data() method to get MimeOb­jects rep­re­sent­ing, for ex­am­ple, im­ages in the HTM­L.

So far so good.

How­ev­er, I am mist­i­fied by this: While it's do­ing that, you can change the con­tents, and it will go along it's mer­ry way, ex­cept that old data() calls are still in progress.

In oth­er word­s, it acts as if it's mul­ti­thread­ed. Usu­al­ly, in Qt, this is be­cause some­one is call­ing QAp­p::pro­ces­sEv­ents, and then you have mul­ti­ple func­tions run­ning and yield­ing to each oth­er in the Qt event loop.

That is sure­ly what's hap­pene­ing, but... how the hell does one stop the old data() call­s????

The pro­ces­sEv­ents call is not made by me, it's done in­ter­nal­ly by some method in the QTextBrows­er.... so, right now, in KRsN, some­times you are down­load­ing im­ages for old stuff you saw min­utes ago!


Contents © 2000-2023 Roberto Alsina