UI refresh in background thread while [NSTask waitUntilExit]

2011-04-26 Thread Vera Tkachenko
Hello,

In my app I need to determine if some app if properly codesigned. To do this I 
just invoke /usr/bin/codesign and analyse return value. To invoke it I use 
NSTask and launch it in background thread. Everything works fine excepts 
strange crash I get sometimes from our customers. While NSTask is waiting for 
command to finish (waitUntilExit) UI starts to update in background thread... 
which causes crashes. I now that's improper to do any UI related stuff in 
background threads. And I don't force UI update explicitly.

But why it's get updated while waiting?

Part of stack trace of crashed thread:

skipped and crash here
19  com.apple.AppKit0x915e8d40 -[NSWindow displayIfNeeded]  
 204
20  com.apple.Foundation0x93b6d9d5 __NSFireDelayedPerform   537
21  com.apple.CoreFoundation0x95634adb __CFRunLoopRun   8059
22  com.apple.CoreFoundation0x95632464 CFRunLoopRunSpecific   452
23  com.apple.CoreFoundation0x95632291 CFRunLoopRunInMode   97
24  com.apple.Foundation0x93be6805 -[NSConcreteTask 
waitUntilExit]   273
skipped

NSTask launching code:

// create task and pipe objects
NSTask *task = [[NSTask alloc] init];
NSPipe *outputPipe = [[NSPipe alloc] init];
NSPipe *errorPipe = [[NSPipe alloc] init];

// setup binary and arguments
[task setLaunchPath:cmd];
[task setStandardOutput:outputPipe];
// and all error output goes to our pipe, not console
[task setStandardError:errorPipe];
[task setArguments:args];

// launch task
[task launch];

[task waitUntilExit];

[[errorPipe fileHandleForReading] closeFile];
[[outputPipe fileHandleForReading] closeFile];
terminationStatus = [task terminationStatus];
[task terminate]; // just in case


Thanks for your help,
Vera Tkachenko___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: isDeletableFileAtPath: returns YES for locked files???

2011-04-14 Thread Vera Tkachenko

 Is it normal that NSFileManager's isDeletableFileAtPath: returns YES for a 
 locked file? Based on the result it returns, when I try to send it a 
 removeItemAtPath:error:, it fails and the error localized description is 
 '„This is a test.docx‰ couldn‚t be removed because you don‚t have permission 
 to access it.'. That seems wrong to me. First, isDeletableFileAtPath: 
 shouldn't return YES for a locked file.
 
 Comments?
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin   
 http://www.nemesys-soft.com/
 Logiciels Nemesys Software
 laur...@nemesys-soft.com

After unsuccessful experience with isDeletableFileAtPath: I've come up with 
trying to remove file at first and if failed try to unlock file if it's locked 
and try to remove it again. But I agree, isDeletableFileAtPath: behavior is 
incorrect in this case.

--  
Thanks,
Vera Tkachenko
Developer @macpaw___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


confstr + [NSFileManager stringWithFileSystemRepresentation:length:] crash on Leopard

2010-08-04 Thread Vera Tkachenko
Hello,

in my application I need to obtain system cache directory (not 
~/Library/Caches). To perform this I use code borrowed from WebKit (that why 
I think it's correct :) )

char cacheDirectory[MAXPATHLEN];
size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, 
MAXPATHLEN);
if (cacheDirectoryLen)
leoUserCacheDir = [[[NSFileManager defaultManager] 
stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1] 
retain];

It works OK but sometimes (it happens for some users) this simple and 
straightforward code crashes. Here is a crash sample:

Thread 0 Crashed:
0   libSystem.B.dylib   0x0ebb __memcpy   1819 
(cpu_capabilities.h:246)
1   com.apple.CoreFoundation0x91dd1cba __CFStringDecodeByteStream3  
 2794
2   com.apple.CoreFoundation0x91db8fa9 
__CFStringCreateImmutableFunnel3   409
3   com.apple.CoreFoundation0x91dba20e CFStringCreateWithBytes   94
4   com.apple.Foundation0x925dd238 -[NSFileManager 
stringWithFileSystemRepresentation:length:]   72
skipped app backtrace

And from this crash I can't figure out what's wrong with this user's systems...

Any advice gratefully received.

--  
Thanks in advance,
Vera Tkachenko___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Creating of Open with menu like in Finder

2010-07-27 Thread Vera Tkachenko
Hello,

I want to build exactly the same menu as Finder's 'Open With' menu. Is there an 
easy way to do this instead of creating this menu manually using LaunchServices?

Thanks,
Vera Tkachenko___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


AuthorizationCreate return code -67049

2009-12-23 Thread Vera Tkachenko
Hello everyone!

In my application I need to execute command with privileges using 
AuthorizationExecuteWithPrivileges.
To obtain authorization reference from system I use the following code

const AuthorizationRights* kNoRightsSpecified = NULL;
OSStatus err = AuthorizationCreate(kNoRightsSpecified, 
AuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, authorizationRef); 
if (err == errAuthorizationSuccess) {
NSLog(@Authorization created. Will try to copy 
rights);
copy rights
}
else {
NSLog(@Authorized Failed: error %i , err);
}

And sometimes get the following error from users:

Authorized Failed: error -67049

So, AuthorizationCreate returns -67049 and I can't find this error code in 
documentation/headers.
Does anyone know where to find explanation for this error code?

Thanks,
Vera Tkachenko___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Can't trap uncaught exceptions on Snow Leopard

2009-12-17 Thread Vera Tkachenko

On 17 груд. 2009, at 16:44, Oleg Krupnov wrote:

 On Leopard, I used to override [NSApp reportException:] method to
 track all uncaught exceptions that occur in my app.
 
 ...
 
 How to work around this and receive the uncaught exceptions somehow?
 
 Thanks!



You can take a look at this project  for examples of source code - 
http://github.com/tcurdt/feedbackreporter

Thanks,
Vera Tkachenko

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Strange problem of first access to variable

2009-01-07 Thread Vera Tkachenko

Hello to everyone )
Don't even know how to explain correctly problem I have. I was using  
Debug mode for developing/testing but before release switched to  
Release mode to test it.
The problem is that in release mode the following code doesn't work -  
files seems  to be null.


- (void) processFiles: (NSArray *) files
{
NSLog(@hideFiles - filesToHide %@ count %i, files, [files count]);
NSEnumerator * enumerator = [files objectEnumerator];
skipped
}

It happens so because all NSLog turned off in release (have special  
macro for this) and files isn't accessed (as done in debug mode) in  
NSLog call before enumerator attempts.


Could you point me where to find the answer - smth with incorrect  
files variable initialization/declaration? Have no idea what's wrong.


I'm sure, that the answer should be very simple... cause the defect is  
very strange :)


--  
With regards, Vera Tkachenko

[v...@tkachenko.kiev.ua]
[ICQ#230923300]
[web http://vera.org.ua]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Strange problem of first access to variable

2009-01-07 Thread Vera Tkachenko

Graham,

thanks for the quick reply.
I agree that the problem isn't solved correctly by using NSLog - this  
is just the only method found by me to solve issue. I just thought  
that symptoms of the problem (need to access variable before it can be  
used normally) is known.
files passed to processFiles is obtained using [filesController  
selectedObjects], where filesController is of type NSArrayController.


7 Січ 2009, в 15:05, Graham Cox написал(а):



On 7 Jan 2009, at 11:58 pm, Vera Tkachenko wrote:

Could you point me where to find the answer - smth with incorrect  
files variable initialization/declaration? Have no idea what's  
wrong.



There's no way to answer this with the information given.

Since files is passed in to your method, the problem is likely to  
lie with where it has come from. It sounds to me like the NSLog  
issue is not the cause of the problem, at least in this location.  
Who creates the array or where do you get it? Show us that bit.


--Graham






--  
With regards, Vera Tkachenko

[v...@tkachenko.kiev.ua]
[ICQ#230923300]
[web http://vera.org.ua]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Strange problem of first access to variable

2009-01-07 Thread Vera Tkachenko
Sorry for unnecessary noise - problem was caused by release mode  
specific problem quite uncorrelated to this issue.


--  
With regards, Vera Tkachenko

[v...@tkachenko.kiev.ua]
[ICQ#230923300]
[web http://vera.org.ua]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Archiving NSError

2008-11-16 Thread Vera Tkachenko

Hello to mac developers :)
If I don't misunderstand things NSError objects can be archived  
because NSError implements NSCoding protocol.

I try to archive it as follows:

NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
	NSError * error = [[NSError alloc] initWithDomain: @TestDomain  
code: 1 userInfo: nil];


[dict setObject:error forKey:@Error];
[dict setObject:@OperationName forKey:@Operation];
[dict writeToFile:@/Users/ivira/temp atomically:YES];

Without placing error into dict it work's ok. What am I doing wrong?

--  
With regards, Vera Tkachenko

[ICQ#230923300]
[web http://vera.org.ua]




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]