QTMovie initWithMovie:timeRange:error: fails under 10.7 but not 10.6 - qtkit

I have a QTMovie object created from a file. I check that it's a valid movie with which can be played or written to file nicely.
Then this line fails with error:
Error code: -50 domain: NSOSStatusErrorDomain description: The operation couldn’t be completed. (OSStatus error -50.)
(Read permission?)
It happens when the movie is longer than ~15 seconds (this varies). The timerange is verified to be correct and should not result in this error anyway.
[[QTMovie alloc] initWithMovie:movie timeRange:range error:&error];
The line spawns the 32bit process QTKitServer for a couple of seconds, until it fails.
The error only occurs in Lion but not Snow Leopard.
Any ideas?

Solved it, I used the editing functions of QTMovie, either use deleteSegment: of the old movie or create a new movie and use insertSegmentOfMovie:movie to insert the segment from the old to the new movie. Remember to set the editable attribute to yes :)
[movie setAttribute:[NSNumber numberWithBool:YES]
forKey:QTMovieEditableAttribute];

Related

PdhAddCounter no longer works in Windows 10 with new SDK 10.0.22621.0

C++, Visual Studio 2019, Windows 10, SDK 10.0.22621.0
As part of my app's log file, I have collected a few bits of information about the user's computer.
I would start the query with:
static PDH_HQUERY cpuQuery;
static PDH_HCOUNTER cpuTotal;
PDH_STATUS status;
status = PdhOpenQuery(NULL, NULL, &cpuQuery);
and then get the bits of information starting with:
status = PdhAddCounter(cpuQuery, L"\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
if (status != ERROR_SUCCESS) {
csData += _T("GetCPURAMStatsinThread - status Add Counter Processor Time Error 2 and return *********\n");
log_write(csData);
return -1;
}
I just noticed that I am now getting the error from PdhAddCounter as:
0xC0000BB8 (PDH_CSTATUS_NO_OBJECT) The specified object is not found on the system.
The only thing that I can think of that has changed since this used to work was that I updated to SDK 10.0.22621.0. I believe that it worked with 10.0.17763.0.
I have not been paying attention to these lines in the log file, but when a customer had a problem that had to do with how many cores his CPU had, and how many virtual processors it had, then that is when I realized that these lines have been erroring out.
I have a laptop that had Windows 7, but I upgraded it to Windows 10, and ran the app on that, and it did not error out. So, does this mean an issue with the Windows 10 update, or the SDK update?
Per my comments above with #Tony Lee I used the MS sample code to browse the counters on my local computer. There was a Processor Information selection vs my original Processor under which there was a Processor Time selection. In the choice box below that there was an all instances choice and a _Total choice. When I selected the _Total choice the buffer in the sample code stayed as NULL but if I selected the all instances the buffer filled with:
L"\Processor Information(*)\% Processor Time"
Plugging that string into PdhAddEnglishCounter() worked...
Edit it also worked with PdhAddCounter()
Using Processor instead of Processor Information and (_Total) Instead of (*) used to work in Windows 10. No telling why things have changed at least on some computer.
Ed
EDIT Important note. First is that the new code above also works on the laptop on which the original code worked. Second note is that I just realized that the desktop on which the original code failed is Windows 10 Home whereas the laptop on which the original code worked is Windows 10 Pro. That maybe the difference. Regardless, the new code works on both Home and Pro.
EDIT 2 The new code also ran fine on Windows 11 Home. I also see that my customer in whose log file I noticed the error line was on Windows 11 Home. That would insinuate that the Pro version still works with the legacy (see next comment by Tony Lee) Processor while the Home versions do not work with the legacy Processor but only with the new Processor Information

iCloud NSDocument save warnings - caused by lastUsedDate file attribute?

I have an app that uses NSPersistentDocument (without autosaving) on OS X and UIDocument (also without autosaving) on iOS. The file representation is Binary Core Storage. This app has been working fine since iOS 7 + macOS 10.10.
If I open a document on OS X 10.13, and another device (macOS 10.13 or iOS 11) opens the same file, on the next save I get a warning "This document's file has been changed by another application since you opened or saved it.". The warning is spurious, because only an open has occured on another device - not a save.
In looking for a possible reason for this notification, I notice that when an iCloud file open occurs on one device, an extended attribute named com.apple.lastuseddate#PS is updated. I have confirmed this extended attribute is updated on both iOS 11 and macOS 10.13. This extended attribute doesn't appear to have been used in prior versions of iOS or macOS. I wonder if the updating of file metadata is triggering this spurious warning.
(I suspect this attribute may related to NSFileProvider on iOS 11 as there is a new method setLastUsedDate:forItemIdentifier:completionHandler: and FinderSync on macOS 10.13 as setLastUsedDate:forItemWithURL:completion: is also new.)
My question is - do others see this new behavior? Is it causing others such annoying side effects?
I have studied this problem further. I have determined what seems to be going on, and also workaround. NOTE this only applies to NSPersistentDocument - without autosaving.
Firstly an important note on file timestamps and file system type. HFS+ timestamps have a resolution on one second. APFS timestamps have a resolution of 1 nanosecond.
My problems only started to manifest itself when the OS X App's iCloud container was migrated to APFS.
Here is a typical sequence (I've used OS X and iOS as example devices - but the same sequence happens regardless OS type for the 'other' iCloud connected device):
Open a file on OS X in the iCloud app container.
Make a change and save the change to the file, at this point the file modification date on APFS will have a fractional second component.
Open the same file on another device - say iOS (after allowing a moment for iCloud to propagate the changes). The modification date on opening the file on iOS has the fractional seconds component truncated.
Soon afterwards, back on OS X, the modification date of the recently saved file will have the fractional seconds component truncated (by iCloud processes beyond my control - presentedItemDidChange is called at this time).
If another change is saved to the OS X file, the change warning "This document's file has been changed by another application since you opened or saved it." will appear. This is because of a mismatch between the NSDocument self.fileModificationDate from the last save (which contains a fractional seconds component) and the file modification date (which has had the fractional seconds component truncated).
The implications are:
when iCloud exchanges timestamp metadata between hosts, the resolution is in seconds.
when a file is opened, and the timestamp metadata is conveyed to other devices, it is in truncated form. It is also written back to the file on the device that wrote the file last.
The workaround I have employed (which is only necessary because I am using NSPersistentDocument without autoSaving) is to set self.fileModificationDate to the fractional seconds truncated version (yes it is read-write), if and only if self.fileModificationDate matches the file modification date ignoring fractional seconds. If this is done, the warning doesn't appear - and no harm is done (as the file had not been modified):
// saving file changes
NSDate *modDate = nil;
[self.fileURL getResourceValue:&modDate forKey:NSURLContentModificationDateKey error:NULL];
if (modDate && self.fileModificationDate) {
NSTimeInterval delta = [modDate timeIntervalSinceDate:self.fileModificationDate];
if (fabs(delta) > 0.0 && [modDate ss_isEqualToDateInSeconds:self.fileModificationDate])
self.fileModificationDate = modDate.ss_dateWithDateInSeconds;
}
[self saveDocumentWithDelegate:self
didSaveSelector:#selector(documentSaved:didSave:contextInfo:)
contextInfo:nil];
As I said at the outset — surprising behaviour. It would be nice if it was documented. Because my use of NSDocument is non-standard, I don't know if others may have this problem.

Cocos2dx Update and Thread 1: EXC_BAD_ACCESS

After updating Cocos2dx and Xcode I started receiving the error: Thread1:EXC_BAD_ACCESS (code=1, address=0x0). It happens when I set the position but I think it has to do with the png image:
auto backgroundSprite=Sprite::create("thing.png");
backgroundSprite->setPosition(Vec2(visibleSize.width /2 +origin.x,visibleSize.height / 2 + origin.y));
I have tried to add this code and image to a different project and it works fine. I have also tried to switch the image file to something else but it didn't work.
If you're running on desktop, make sure that Target Membership is checked for your thing.png and also check form Xcode IDE, file is available in Resource.
Go to build settings and set: Remove Text Metadata From PNG Files = No
Looks like you've got nullptr as backgroundSprite. Check it before calling setPosition.

SWIFT 3 unexpectedly found nil while unwrapping an Optional value (works perfect in simulator)

My code works perfectly in simulator, but it pops this "fatal error: unexpectedly found nil while unwrapping an Optional value" warning when I tried to run it on my iPhone and iPad.
Strange thing is, this error didn't occur when I tried to get the value of a variable, it happened when I tried to create an object with the values I got:
"pName" and "pQuestion" are the variables with values, but as you can see, once I tried to give these value to the attributes of my object, they just became nil.
This bit of the code really behaved in the simulator, somehow it just keeps acting out on a real device.
What Swift is telling you is totally correct. Your question variable is nil when you are assigning values to it.
Don't you wanna initialise it before you start putting values into it?
I think what you are looking for is
let question = Question(name: pName, question: pQuestion)
So, I think I know whats wrong with my code.
Like Hunaid Hassan said, my current code will just get nil out of the object.
The reason my original code didn't work is because, one of the attributes is a Date variable, and because I'm in Australia, when the app runs on a real device the Date I get will be nil because I didn't set the locale.
Here's my original code:
enter image description here
And here's the fix I found to set the locale:
enter image description here
ref: https://stackoverflow.com/a/26154583/7578872

Timed Indexed Color sets in CPN Tools that results in Unhandled Exception Error

I am using CPN Tools to model a distributed system. CPN Tools uses CPN ML an extension of SML. The project homepage is: cpntools.org
I started with a simple model and when I try to make a particular indexed color set timed, I get an "Internal error". There is another indexed colorset within my Petri-net model that is timed and works correctly. I am not sure how I can troubleshoot since I don't understand the error message. Could you help me interpret the error message or give me some hints on what I could be doing wrong?
The model is:
http://imgur.com/JUjPRHK
The declarations of the model are:
http://imgur.com/DvvpyvH
The error message is:
Internal error: Compile error when generating code. Caught error.../compiler/TopLevel/interact/evalloop.sml:296.17-296.20../compiler/TopLevel/interact/evalloop.sml:44.55../compiler/TopLevel/interact/evalloop.sml:66.19-66.27
structure CPN`TransitionID1413873858 = struct ... end (* see simulator debug info for full code *)
simglue.sml:884.12-884.43
"
Thank you~
I know this is an old question, but I run in the same problem and wasted too much time on this, so maybe it will help someone else in the future.
I didn't understand exactly the reason for this, but it seems the problem appears when you play with time values on an arch that ends to a transition (I was updating an integer value to the current time, using IntInf.toInt(time())). Now, if I move the code on the outgoing arch of that transition (that is: the one that ends in a place) there is no error.