QMovie is not animated while its state is in Running in pyqt? - qt

I set gif as a QMovie to a QLabel.
Sometimes the movie works well, sometimes bad.
And I've checked the QMovie.state() to find it's running while the gif is frozen.
And I've checked the lastError() & lastErrorString() function, for the former, the value is 0 which seems to means file not found error; the latter is Unknown Error.
Actually I did nothing but to setMovie() and movie.start(), very confused

Related

Qt 6 crash in QPlainText::setExtraSelections after QPlainText::setDocument

I'm trying to set up a text widget that highlights the searched word, when I open a new file with QPlainText::setDocument, then immediately use QPlainText::setExtraSelections I get a SIGSEV crash in:
QTextDocumentPrivate::rootFrame
QTextDocumentPrivate::frameAt
QTextCursorPrivate::complexSelectionTable
QTextCursor::hasComplexSelection
QWidgetTextControl::selectionRect
QWidgetTextControl::setExtraSelections
QTextDocumentPrivate is causing a SIGSEV because it is a null this pointer. But this doesn't happen if no word is set before the document is loaded.
I must be supposed to do something to force it to generate the QTextDocumentPrivate. But I have no idea what that is.
Actually, this happens because QPlainText::setDocument does not remove the prior results of QPlainText::setExtraSelections. So when setting the new selections tries to remove the previous things selected, they all have invalid pointers and that causes the crash.
To fix it call: textEdit->setExtraSelections({}); to clear out the selections prior to calling QPlainText::setDocument.

Code Composer Studio MSPFR6989 variables&expressions won’t come up

I am using CCS to program a MSPFR6989 and I’ve debugged and the code is working but I can’t get variables or registers to come up. It remains blank. enter image description here
use double click onto your variables and choose watch expression. You can find your variables under expression from now. If it shows you its name but a red error message try step by step debugging, works for me everytime.

Window setBackGround: causes runtime errors

I added a background color to the window of a well-running simple draw project and build succeeded. Then the fun began: runtime errors appeared in the console window. I found no help in Apple docs and Google. When the same happened in another draw project, I knew I had to ask for help.
Here's what happened each time I did a build & debug and stop -- runs 1) through 4). "continue" means I clicked the Continue icon. It kept on erring in no consistent order.
1)Program received signal:“EXC_BAD_ACCESS". spinning ball. paths OK.
continue. “EXC_BAD_ACCESS. spinning ball. paths disappear. background appears.
2)continue, 6 times. “EXC_BAD_ACCESS”. spinning ball. paths disappear. background appears.
3)immediately:
2012-12-26 09:53:18.265 bezier triangle[388:a0f] -[NSCFArray stroke]: unrecognized selector sent to instance 0x1005184f0
2012-12-26 09:53:18.268 bezier triangle[388:a0f] -[NSCFArray stroke]: unrecognized selector sent to instance 0x1005184f0
2012-12-26 09:53:37.846 bezier triangle[388:a0f] -[NSCFArray stroke]: unrecognized selector sent to instance 0x1005184f0
2012-12-26 09:53:37.847 bezier triangle[388:a0f] -[NSCFArray stroke]: unrecognized selector sent to instance 0x1005184f0
no continue icon. paths OK. no background.
4)continue, 6 times. “EXC_BAD_ACCESS”. spinning ball. no paths. no background.
The NSWindow class creates a couple of Bezier paths in initWithRect: and draws them in drawRect:. It ran well.
I got the setBackGround: code from Apple's Window Programming Guide and pasted it into the previously empty AppDelegate.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Background color
[window setOpaque:NO]; // YES by default
NSColor *semiTransparentBlue =
[NSColor colorWithDeviceRed:0.0 green:0.0 blue:1.0 alpha:0.5];
[window setBackgroundColor:semiTransparentBlue];
window.backgroundColor = NSColor.blueColor;
}
Setting breakpoints showed that the runtime errors occur after this code finishes.
Thinking that the problems might have something to do with the timing of its execution, I moved this code to initWithRect and then into awakeFromNib. These didn't work. I wish I could find some example that shows how to implement this. All help will be appreciated.
No, setBackground: did not cause the runtime errors.
In the paths code, the paths weren't being allocated and inited properly, although the project ran correctly until the setBackground: code was added. Strange!
I'm sorry I didn't enclose the paths code in my question because it was too long.
I found my mistakes by starting a new project and building it up slowly, a piece at a time.

Why does my QPainter instance only draw when I use a specific .png?

I'm creating a simple "frogger" type game with Qt Creator.
I managed to get a player that works with 4 directional keys, and a car that moves on its own across the screen. I have separate Player, Car, and Frogger class.
The Frogger class paints the images in paintEvent:
painter.drawImage(player->getRect(), player->getImage());
painter.drawImage(car->getRect(), car->getImage());
But I'm encountering a problem with trying to load a different image for the car. If I use image.load("player.png"); for both the car and the player constructors, I can see the car moving across the screen as a player image, and the player which moves according to my keys.
However if I replace the image with anything else (all images are in the same folder; I also tried adding it to Qt Creator under "Other files") such as "car.png," it doesn't seem to show up. I tried it with other images, but those don't show up for player either. Any ideas on why this might happen? I commented out my autoMove() function and nothing changes, so I don't think it's related to how I implement my move. Any ideas on what I might be missing?
I guess you can reduce the possible error locations to the procedure when you load the image. Try to confirm this by checking the return value of QImage::load:
QString path = "player.png";
bool loadSuccess = image.load(path);
qDebug() << "Image" << path << "loaded? =>" << loadSuccess;
If this will print false, check if Qt can find exactly the same path when just passing to QFile:
if(!loadSuccess)
qDebug() << " File exists? =>" << QFile::exists(path);
If this will print true, the image format can't be read by Qt. Possibly you use a non-standard PNG encoding. Are the images all from the same source? (Edited by the same image editor for example)
However, if you still get the errors even when the first debug output above always prints true, the error is somewhere else. Then it could help to give us more code of how you use the images.

SecurityError: Error #2000: No active security context

I recently had this vague error happen to me with the use of LocalConnection.
It happened every time I tried to connect and send data to another swf.
Doing an internet search came up with little results pertaining to LocalConnection and this error and the response some people had were just ridiculous.
Apparently this error pertains to image loading and fileReference also, just not in this case.
My sending code works fine, even the event.level returned as status which means the other swf got the message, however a trace in the other swf callback function did not show, telling me the callback never triggered.
Image loading error
I got nailed on this one again with loading images.
The answer has been updated to include the fix for this also.
As it turns out the fix is simple.
The connection name was too long.
I cut the name down to 30 characters and it started working immediately.
I also want to add that if there is an error in the callback function you will get this error.
IMAGE LOADING ERROR
Well this error popped up on me again, but this time when I was loading images.
// bad code
imageObj.source = partialURL1 + partialURL2 + partialURL3;
//good code
var someURL:String = partialURL1 + partialURL2 + partialURL3
imageObj.source = someURL;
It seems you can not append the URL on the same line you assign it. Looks like a debugger bug. Even with the bad code HTTPFox was showing the images where loading, but the program would crap out somewhere after the source assignment, probably on the onloaded callback. I stopped looking into the matter when I found the source assignment fixed it.
I've had this error too, and for me the errorous code was
someobject.misspelledVariable.toString();
Where someobject was sent through a earlier localConnection and misspelledVariable is of course undefined.
Changing misspelledVariable to a correct one solved my problem. Strange error though...

Resources