Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse

> On 22 Oct 2016, at 23:26, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Oct 22, 2016, at 2:21 PM, Jean Suisse <jean.li...@gmail.com 
>> <mailto:jean.li...@gmail.com>> wrote:
>> 
>> I don’t know if it’s so irrelevant, because in the backtrace the swift code 
>> calls -[NSURLDirectoryEnumerator nextObject]. Maybe the ObjC code doesn’t. 
>> Hence my question.
> 
> Obj-C for…in loops use NSFastEnumeration, which is equivalent to calling 
> nextObject, just faster.
> 
> My point is that the crash is not in the enumerator at all, but in the glue 
> where the value it returns is translated into Swift. There seems to be some 
> bug there, specifically with handling dates.

Agreed. Though in the smallest version I ask no date. 
So I filed bug #28905225

Jean

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse

> On 22 Oct 2016, at 23:15, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Oct 22, 2016, at 12:11 PM, Jean Suisse <jean.li...@gmail.com 
>> <mailto:jean.li...@gmail.com>> wrote:
>> 
>> To refine, what difference is there between ObjC’s 
>>  for (NSURL* file in enumerator)
>> and swift’s
>>  while let file = enumerator?.nextObject() as? URL
> 
> That’s irrelevant. Look at the backtrace of the crash — the problem has to do 
> with Foundation.DateComponents. Apparently the ObjC-Swift bridge is trying to 
> translate a date value from the enumeration result, and crashing due to a bug.
> 
> —Jens

I don’t know if it’s so irrelevant, because in the backtrace the swift code 
calls -[NSURLDirectoryEnumerator nextObject]. Maybe the ObjC code doesn’t. 
Hence my question.
You asked me if the ObjC equivalent would crash. Here is the code I came up 
with. It is only relevant if that code actually runs the same API. That’s the 
origin of my question.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse

> On 22 Oct 2016, at 21:24, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Oct 22, 2016, at 11:42 , Jean Suisse <jean.li...@gmail.com 
> <mailto:jean.li...@gmail.com>> wrote:
>> 
>> My app should get an access denied error (the enumerator should be nil for 
>> instance). It shouldn’t crash.
> 
> It can’t return nil, because that is used to signal the end of the 
> enumeration. I agree it’s nasty if it crashes, though.

I am not talking about enumerator?.nextObject() but about 
manager.enumerator(at: includingPropertiesForKeys: options:), which in the API 
return an optional FileManager.DirectoryEnumerator?, which I expect to be nil 
when there is nothing to enumerate. 

However, the doc states:

Returns: An NSDirectoryEnumerator object that enumerates the contents 
of the directory at url. If url is a filename, the method returns an enumerator 
object that enumerates no files—the first call to nextObject()returns nil.

So, why make it an optional value at all?

> 
>> Though it looks like I am trying to access "/.DocumentRevisions-V100/“, it 
>> is not what I am trying to achieve. 
>> 
>> At some point my app needs to enumerate user-selected directories. The issue 
>> is I get a crash when directories such as "/.DocumentRevisions-V100/“ are 
>> present.
>> I cannon reasonably maintain a list of “don’t enumerate” directories.
> 
> It’s still not quite clear what your real code is trying to do. If you were 
> enumerating the *root* directory *shallowly* (.skipsSubdirectoryDescendants), 
> and you hit this directory, you should *not* try to descend explicitly into 
> this directory (or any directory whose name begins with a period, I suppose) 
> as your sample code does. If you were doing a deep enumeration from the root 
> directory, you wouldn’t be executing shallow enumeration code as in your 
> sample code.

Yes, I enumerate shallowly. Yes I hit the directory. And yes, the user may take 
an action that will lead my app to try enumerating directories such as 
"/.DocumentRevisions-V100/“ shallowly.
The finder doesn’t crash when I try to open .DocumentRevisions-V100. Neither 
should my app.

> Can you use the .skipsHiddenFiles option for your real enumerator? That will 
> skip files and directories whose name starts with a period.

I could. But I still may hit directories that the user does not have the 
permission to access. .DocumentRevisions-V100 is really just for the example.

> 
>> To refine, what difference is there between ObjC’s 
>>  for (NSURL* file in enumerator)
>> 
>> and swift’s
>> 
>>  while let file = enumerator?.nextObject() as? URL
>> ?
> 
> You’re comparing unlike things. Regardless of language, “for … in” and “while 
> … nextObject” use different mechanisms for maintaining state between 
> iterations. What does the Swift version of the “for … in” loop do?

Jens asked if an equivalent in ObjC would crash. That’s what I came up with. 
The for … in loop performs gathers data about the file and folders, puts them 
in an array, returns it to the caller function, then the app continues 
interacting with the user.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
I forgot the code:

NSURL* directoryURL = [NSURL 
URLWithString:@"/.DocumentRevisions-V100/"];
NSFileManager* manager = [NSFileManager defaultManager];
NSArray* keys = @[NSURLNameKey, NSURLIsDirectoryKey];

NSDirectoryEnumerator* enumerator = [manager 
enumeratorAtURL:directoryURL includingPropertiesForKeys:keys 
options:NSDirectoryEnumerationSkipsSubdirectoryDescendants 
errorHandler:^BOOL(NSURL *url, NSError *error){return true; }];

for (NSURL* file in enumerator)
{

}


> On 22 Oct 2016, at 21:11, Jean Suisse <jean.li...@gmail.com> wrote:
> 
> Jens,
> 
> The code below doesn’t crash.
> To refine, what difference is there between ObjC’s 
>   for (NSURL* file in enumerator)
> 
> and swift’s
> 
>   while let file = enumerator?.nextObject() as? URL
> ?
> 
> Jean
> 
> 
> 
> 
>> On 22 Oct 2016, at 20:55, Jens Alfke <j...@mooseyard.com 
>> <mailto:j...@mooseyard.com>> wrote:
>> 
>> 
>>> On Oct 22, 2016, at 11:42 AM, Jean Suisse <jean.li...@gmail.com 
>>> <mailto:jean.li...@gmail.com>> wrote:
>>> 
>>> To add a little more information: it happens when encountering any 
>>> directory that the user can’t read.
>>> My app should get an access denied error (the enumerator should be nil for 
>>> instance). It shouldn’t crash.
>> 
>> Try writing the same code in Objective-C and see what happens. (That could 
>> be a workaround: implement this piece of functionality in Obj-C and then 
>> call into it from your main Swift code.)
>> 
>> —Jens
>> 
> 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Jens,

The code below doesn’t crash.
To refine, what difference is there between ObjC’s 
for (NSURL* file in enumerator)

and swift’s

while let file = enumerator?.nextObject() as? URL
?

Jean




> On 22 Oct 2016, at 20:55, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Oct 22, 2016, at 11:42 AM, Jean Suisse <jean.li...@gmail.com> wrote:
>> 
>> To add a little more information: it happens when encountering any directory 
>> that the user can’t read.
>> My app should get an access denied error (the enumerator should be nil for 
>> instance). It shouldn’t crash.
> 
> Try writing the same code in Objective-C and see what happens. (That could be 
> a workaround: implement this piece of functionality in Obj-C and then call 
> into it from your main Swift code.)
> 
> —Jens
> 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
To add a little more information: it happens when encountering any directory 
that the user can’t read.
My app should get an access denied error (the enumerator should be nil for 
instance). It shouldn’t crash.


> On 22 Oct 2016, at 20:37, Jean Suisse <jean.li...@gmail.com> wrote:
> 
> Well, I was afraid of that. 
> Unfortunately, below is the smallest sample of code possible… still crashes. 
> Looks like I may have to check the directory rights before even attempting to 
> enumerate it.
> Expected result in the present case is: “the while loop doesn’t run because 
> the directory isn’t accessible to the current user”.
> 
> 
> let directoryURL = URL(fileURLWithPath: "/.DocumentRevisions-V100/")
> let manager= FileManager.default
> 
> let keys = [URLResourceKey.nameKey, URLResourceKey.isDirectoryKey]
> 
> let enumerator = manager.enumerator(at: directoryURL, 
> includingPropertiesForKeys: keys, options: [.skipsSubdirectoryDescendants])
> {
>   url, error -> Bool in
>   return true
> }
> 
> // this will
> while let file = enumerator?.nextObject() as? URL
> {
>   // ...
> }
> 
> 
> 
>> On 22 Oct 2016, at 20:32, Jens Alfke <j...@mooseyard.com 
>> <mailto:j...@mooseyard.com>> wrote:
>> 
>> Smells like an OS bug, or a bug in the ObjC-to-Swift bindings. Try to build 
>> a minimal test to reproduce it, i.e. narrow down which of the 
>> URLResourceKeys triggers the crash, and which specific file being returned 
>> by the enumerator. Then see what if anything is unusual about that file. 
>> Then probably file a bug report with Apple…
>> 
>> As for working around it, perhaps the resource key causing the crash is one 
>> you don’t need and can omit? (It’s hard to imagine needing all of those 
>> attributes…)
>> 
>> —Jens
> 


---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Well, I was afraid of that. 
Unfortunately, below is the smallest sample of code possible… still crashes. 
Looks like I may have to check the directory rights before even attempting to 
enumerate it.
Expected result in the present case is: “the while loop doesn’t run because the 
directory isn’t accessible to the current user”.


let directoryURL = URL(fileURLWithPath: "/.DocumentRevisions-V100/")
let manager  = FileManager.default

let keys = [URLResourceKey.nameKey, URLResourceKey.isDirectoryKey]

let enumerator = manager.enumerator(at: directoryURL, 
includingPropertiesForKeys: keys, options: [.skipsSubdirectoryDescendants])
{
url, error -> Bool in
return true
}

// this will
while let file = enumerator?.nextObject() as? URL
{
// ...
}



> On 22 Oct 2016, at 20:32, Jens Alfke  wrote:
> 
> Smells like an OS bug, or a bug in the ObjC-to-Swift bindings. Try to build a 
> minimal test to reproduce it, i.e. narrow down which of the URLResourceKeys 
> triggers the crash, and which specific file being returned by the enumerator. 
> Then see what if anything is unusual about that file. Then probably file a 
> bug report with Apple…
> 
> As for working around it, perhaps the resource key causing the crash is one 
> you don’t need and can omit? (It’s hard to imagine needing all of those 
> attributes…)
> 
> —Jens

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Dear Quincey,

Thank you for your reply. I have posted the code including the line below. It 
got deleted by mistake.

Though it looks like I am trying to access "/.DocumentRevisions-V100/“, it is 
not what I am trying to achieve. 

At some point my app needs to enumerate user-selected directories. The issue is 
I get a crash when directories such as "/.DocumentRevisions-V100/“ are present.
I cannon reasonably maintain a list of “don’t enumerate” directories.

Thus, my question is not “how can I enumerate "/.DocumentRevisions-V100/“” but 
how can I not crash when encountering it ?



Best regards,
Jean




let directoryURL = URL(fileURLWithPath: "/.DocumentRevisions-V100/")
let manager  = FileManager.default

let keys = [URLResourceKey.nameKey, URLResourceKey.isDirectoryKey, 
URLResourceKey.isSymbolicLinkKey,
URLResourceKey.isVolumeKey, 
URLResourceKey.isPackageKey,URLResourceKey.isSystemImmutableKey,
URLResourceKey.isUserImmutableKey, 
URLResourceKey.isHiddenKey, URLResourceKey.volumeURLKey,
URLResourceKey.fileSizeKey, 
URLResourceKey.fileAllocatedSizeKey, URLResourceKey.totalFileSizeKey,
URLResourceKey.totalFileAllocatedSizeKey, 
URLResourceKey.contentModificationDateKey,
URLResourceKey.isAliasFileKey, 
URLResourceKey.creationDateKey]


let enumerator = manager.enumerator(at: directoryURL, 
includingPropertiesForKeys: keys, options: [.skipsSubdirectoryDescendants])
{
url, error -> Bool in
print(error.localizedDescription)
return true
}

// this will
while let file = enumerator?.nextObject() as? URL
{
// ...
}
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

EXC_BAD_INSTRUCTION when enumerating /.DocumentRevisions-V100/

2016-10-22 Thread Jean Suisse
Dear All,

Running the code below, I get EXC_BAD_INSTRUCTION error. My questions are:

1. Why ?
2. How can I prevent it ?

Best regards,
Jean

CODE

let directoryURL = URL(fileURLWithPath: "/.DocumentRevisions-V100/")
let manager  = FileManager.default

let keys = [URLResourceKey.nameKey, URLResourceKey.isDirectoryKey, 
URLResourceKey.isSymbolicLinkKey,
URLResourceKey.isVolumeKey, 
URLResourceKey.isPackageKey,URLResourceKey.isSystemImmutableKey,
URLResourceKey.isUserImmutableKey, 
URLResourceKey.isHiddenKey, URLResourceKey.volumeURLKey,
URLResourceKey.fileSizeKey, 
URLResourceKey.fileAllocatedSizeKey, URLResourceKey.totalFileSizeKey,
URLResourceKey.totalFileAllocatedSizeKey, 
URLResourceKey.contentModificationDateKey,
URLResourceKey.isAliasFileKey, 
URLResourceKey.creationDateKey]
{
url, error -> Bool in
print(error.localizedDescription)
return true
}

while let file = enumerator?.nextObject() as? URL   // 
EXC_BAD_INSTRUCTION HERE 
{
// ...
}


ERROR
=

The error occurs on the line:

while let file = enumerator?.nextObject() as? URL

STACK TRACE
===

0 static DateComponents._unconditionnalyBridgeFromObjectiveC(NSDateComponents?) 
-> DateComponents
1 thunk
2 -[NSURLDirectoryEnumerator nextObject]
3 AppDelegate.applicationDidFinishLaunching(Notification) -> () 


EXAMPLE APP
===

Just past the code in a Swift Cocoa App in applicationDidFinishLaunching and 
run.




___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse

>> Additionally, I was unable to find any leaks with Instruments (but I barely 
>> know how to use it)
> 
> Probably the next step would be to learn more about Instruments.

I was a little to harsh when I said that. I know everything I got from the WWDC 
videos. But I need more practice. And more knowledge.
For instance, I don’t know how to tell when memory is wasted by to manny heap 
allocations which fragments the heap. So I had to find an other way to check 
this possibility and rule it out (I suppressed allocations by building object 
servers in charge of dealing and recycling them so all allocations occur at 
launch.

>> and the amount of memory reported by Instruments is far less than the one 
>> reported by Activity monitor
> 
> There are several different memory usage figures that count different things. 
> (Virtual memory is complicated…) I don’t even know what exactly the column 
> names in Activity Monitor (“Memory”, “Private Memory”, etc.) correspond to 
> anymore. Generally I look mostly at “Private Memory” which I believe is RPRVT 
> — this is memory used only by this process and not shared with any others, 
> which mostly means heap space. (“Memory” includes things like framework code 
> and shared address space, which are used across multiple processes.)

Well, Xcode and Activity monitor agree. Instruments only show like 100 MB when 
they report GBs. But I may fail to read it correctly.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse

> On 16 sept. 2015, at 18:58, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Sep 16, 2015, at 04:00 , Jean Suisse <jean.li...@gmail.com> wrote:
>> 
>> Does anyone know what to try / measure / observe to get more clues?
> 
> It seems you’re “losing” free memory fast enough for this to be visible using 
> heap generations in Instruments’ Allocations. The difficulty with marking 
> generations is that you’d really like the app (at least its memory-wasting 
> activities) to go quiescent long enough and often enough to let you set marks 
> when it’s not doing anything.
> 
> You could do this by changing your timer to fire (say) every minute instead 
> of every second. In Instruments, wait until you see a UI update, then wait 
> about 30 more seconds, then mark the generation. Do this several times, and 
> you should be able find out exactly what’s being leaked. (“Why” might be 
> harder.)


I did that. All I see is that the memory is taken (not leaked) after 
__CFRunLoopDoObservers and CA::Transaction::commit().

Bytes Used  Count   Symbol Name
  30.61 MB  97.0%   11645   start
  30.61 MB  97.0%   11645   main
  30.61 MB  97.0%   11645NSApplicationMain
  30.61 MB  97.0%   11645 -[NSApplication run]
  30.59 MB  96.9%   11644  -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:]
  30.59 MB  96.9%   11643   _DPSNextEvent
  30.59 MB  96.9%   11643
_BlockUntilNextEventMatchingListInModeWithFilter
  30.59 MB  96.9%   11643 ReceiveNextEventCommon
  30.59 MB  96.9%   11643  RunCurrentEventLoopInMode
  30.59 MB  96.9%   11643   CFRunLoopRunSpecific
  29.27 MB  92.7%   161  __CFRunLoopDoObservers
  29.27 MB  92.7%   161   
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
  29.27 MB  92.7%   161
CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
  28.93 MB  91.6%   139 CA::Transaction::commit()
  28.93 MB  91.6%   139  
CA::Context::commit_transaction(CA::Transaction*)
  28.92 MB  91.6%   22
CA::Layer::layout_and_display_if_needed(CA::Transaction*)
  28.92 MB  91.6%   22 
CA::Layer::display_if_needed(CA::Transaction*)
  28.92 MB  91.6%   22  -[_NSViewBackingLayer display]
  28.92 MB  91.6%   22   _NSBackingLayerDisplay
  28.92 MB  91.6%   22CA::Layer::display_()
  28.92 MB  91.6%   22 x_blame_allocations
  28.92 MB  91.6%   22  
___ZN2CA5Layer8display_Ev_block_invoke
  28.92 MB  91.6%   22   CABackingStoreUpdate_
  28.76 MB  91.1%   2 
CA::Render::Shmem::new_bitmap(unsigned int, unsigned int, unsigned int, 
unsigned int)
  28.76 MB  91.1%   2  
CA::Render::Shmem::new_shmem(unsigned long)
  28.76 MB  91.1%   2   vm_allocate
  28.76 MB  91.1%   2mach_vm_allocate

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse
> What makes you think that:
> 
> (a) this is a lot of activity?


It is not a lot of activity. I am not trying to do performance optimization. 
Right now, the app is taking 3 % CPU on the latest 13” MBP Retina.
I am trying to find why my app can’t run for two days without exhausting the 16 
GB RAM it has.

> (b) your monolithic replacement runs faster than this?

I don’t know, but as long as it runs reasonably I am not sure I care. The MAC 
is dedicated to the project. There is no user to complain. All I can tell is 
that there is no visible jump in CPU consumption.

> In design terms, you have two instances of the MVC pattern, not one. You have 
> inputs (V-1) updating a model (M), and you have UI elements (V-2) tracking 
> the same model (M). So you have two design problems: input to model, and 
> model to UI. It’s much harder to try to solve inputs-to-UI in a single 
> coordinated step — nor do I think you need to.
> 
> I know nothing of the details of your app, of course, but if, for example, 
> only 20% of the inputs change every second, then suppressing input-to-model 
> updates entirely, at the source, seems like a good approach to performance 
> problems, without involving the UI. Separately, if the overall rate of UI 
> updates is very high (in particular if it’s over 100% per second), then using 
> a timer to limit the model-to-UI update rate sounds like a simple approach, 
> without involving the inputs.

Well, at this point it is better for me to say more.

It is a scientific data acquisition app. Basically, I mad many electronic 
boards performing various tasks (actuation & measurements mainly). These 
electronic boards have been incorporated in nice boxes to build what I will 
call hereafter “instruments”.
These instruments either communicate wirelessly or not, depending on their 
physical location, and use different protocol (buses, interfaces) according to 
their nature. All these instruments together allow me to cover a large area and 
monitor around 150 parameters every second. 

The application does that. Of these 150 variables, a little above 100 are 
displayed on a UI that is refreshed every second.
This in itself is a challenge and I had to add some piece of electronics, work 
on the (custom) protocol and on the firmware of the boards to get it to work 
reliably. Especially for the wireless part. One solution was to have distinct 
data buses (distinct communication interfaces).

Now, this job is done and the design of the app reflects some of these 
constraints.

First, I have a communication interface server which ensures that there is only 
one instance representing each data bus connection. Same for the electronic 
board server. It ensures that that there is only one object for each physical 
board and communication interface (so dealing with concurrency is dead simple). 
Then I have actuator objects, sensor objects, instruments objects all 
requesting their electronic board on their bus to these object servers. I 
manipulate the instruments objects. Communication follows. Communication is 
slow. It is expected.

Then, I have one dispatch source that takes care of synchronization & 
timestamps. Four that trigger data collection from the devices through the 4 
buses (1 wireless, 2 RS-485, one GPIB), one that collects measured values 
during the last cycle, takes care of the processing & on the disk storage. And 
now, one extra that sync the UI.

Everything works fine with no leaks, except for that last part. This is where 
the issue lies. The timer dispatch source that syncs the UI is dead simple. It 
only sends updateUI to each object representing an instruments.

These objects are declared as:

@interface MyInstrument : JSScientificInstrument
{
double aMeasuredValue;
}

@property (readwrite)   double  theMeasured Value;  // IB binding 
NSTextField with NSFormatter

@end

And implemented as :

- (void)updateUI
{
assert([NSThread isMainThread]);
self.theMeasuredValue = self->aMeasuredValue;
}

Somewhere in those lines is the issue. If I only comment "self.theMeasuredValue 
= ... “, the issue disappears, despite the fact that I am only transferring a 
double through a setter bound to the UI.

I believe it is somewhere in the way GCD, appkit, Core Animation, cocoa 
bindings are implemented. So at this stage I am looking to pinpoint the issue 
and find a workaround.



 















> On 16 sept. 2015, at 23:54, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Sep 16, 2015, at 14:28 , Jean Suisse <jean.li...@gmail.com> wrote:
>> 
>> I thought of that at first, to solve the uncommitted CA transactions issues. 
>> But the syntax is ugly.
> 
> Sure, but in modern Cocoa programming it’s a standard pattern, so it’s not 
> unreasonable to grin and bear it.
> 
> (It’s about a million times less ugly in Swif

Re: Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse
Thanks for your reply.

> 
> I don't see why you're using a strong reference from the weak reference 
> inside your timer. You may be confusing ARC with that and your etc code. 
> Change your code to just use weakself rather than strongself when calling 
> updateUI. If there's a strong reference needed, try using self only. Also, is 
> it possible your function never ends? Check your etc code there.

I read about it in the section "Use Lifetime Qualifiers to Avoid Strong 
Reference Cycles” of the "Transitioning to ARC Release Notes” :

MyViewController *myController = [[MyViewController alloc] init…];
// ...
MyViewController * __weak weakMyController = myController;
myController.completionHandler =  ^(NSInteger result) {
MyViewController *strongMyController = weakMyController;
if (strongMyController) {
// ...
[strongMyController dismissViewControllerAnimated:YES completion:nil];
// ...
}
else {
// Probably nothing...
}
};

and decided to go with it.

That said, I do not really need that much in my app, because I know for a fact 
that self will live as long as the app runs. So I could go with weak only or 
even with __unsafe_unretained.
I tried. It does not change anything.

The “etc” only describes identical lines repeated. There isn’t anything more.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse
I have been looking at this issue for several weeks now. I could easily do what 
you suggest, or I could design the app with the “resume on re-launch” 
functionality and have it quit periodically based on memory criteria.

Both are last resort to me. 
I would rather like to figure out what in GCD / Appkit / Core Animation / cocoa 
bindings is preventing my app from running smoothly for years at a time.

That said, since the UI is causing the mess, having it disconnected from the 
rest is a more elegant way to proceed than having it exit regularly.




> On 17 sept. 2015, at 00:00, Kevin Meaney <k...@yvs.eu.com> wrote:
> 
> I can't help but think that there should be a way to use xpc services as a 
> nice solution to this problem.
> 
> Unfortunately xpc services are mostly designed around the idea that if the 
> service dies the app can restart it when it needs. Whereas you need the 
> service running your experiment and collecting data to stay running even if 
> the app displaying the results dies. When the user restarts the application 
> it connects to the still running service.
> 
> Kevin
> 
> Sent from my iPad
> 
>> On 16 Sep 2015, at 22:28, Jean Suisse <jean.li...@gmail.com> wrote:
>> 
>> 
>>> But I agree that this all (meaning the contortions to get updates onto the 
>>> main thread) seems like too much flash and not enough bang. The easiest way 
>>> would be to dispatch the original update code in blocks onto the main 
>>> thread asynchronously, thus serializing them and generating KVO 
>>> notifications safely. 
>> 
>> I thought of that at first, to solve the uncommitted CA transactions issues. 
>> But the syntax is ugly. And I didn’t want to post blocks from all over the 
>> place to the main thread (I have 100+ NSTextfields with number formatters 
>> updated every second… meaning as many blocks...).
>> So I went for the updateUI solution, which is cleaner: It only requires me 
>> to duplicate instance variables. 
>> 
>> At this point, I would like to add that instance variables (and their 
>> UI–bound property counterpart) are mostly double with a few int, so  they 
>> aren’t retained objects subjects to leaks.
>> 
>>> When I think about it in those terms, it’s clear (to me, at least) that the 
>>> *real* problem is one of coalescing a potentially large number of updates 
>>> over time. In other words, this thread is really about premature 
>>> optimization and its ugly consequences.
>> 
>> The issue, to me, is to get my app to run for a few days without crashing. 
>> The only way I have to make it work, currently, is by not updating the UI.
>> This is a shame considering the time I spent arranging all those textfields 
>> in a nice fashion to make it easily readable despite the large number of 
>> displayed values (and also, IB gets really really slow with that many 
>> controls on a view, making the design part a real pain).
>> 
>> ___
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/ktam%40yvs.eu.com
>> 
>> This email sent to k...@yvs.eu.com


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse
Thanks for your reply. 
If I understand you correctly, I am already doing all that by having one 
updateUI function per instrument, which does:

self.myProperty = self->myStorageVariable

on every variables.
All updateUI selectors are sent to all instruments, at the same time, from the 
main thread by a timer dispatch source, once every second.



> On 17 sept. 2015, at 16:18, Gary L. Wade  wrote:
> 
> Also, in case you're pulling multiple values per instrument object in your 
> new timer (e.g., temperature, time, frequency, etc.), and these may be 
> updating on background threads, a simple way to get these is to pull all the 
> values needed into local variables in a synchronize block based on the 
> particular instrument object. Just be sure to do the same on your background 
> threads when updating them; using the synchronize block to set multiple 
> values at once is better than using multiple atomic properties.
> 
> This also helps present a more unified front for your data per instrument 
> since individual updates may show a temperature from the last reading and a 
> frequency from this reading whereas a single full-pull will show the user 
> only the one reading.
> --
> Gary L. Wade (Sent from my iPad)
> http://www.garywade.com/
> 
>> On Sep 17, 2015, at 6:47 AM, Gary L. Wade  
>> wrote:
>> 
>> Okay, so what it appears you have is over 100 timers being fired whose only 
>> purpose is to transfer a single value from one variable to another so that 
>> bindings will hear that change and update your UI.
>> 
>> A better approach is to remove bindings completely, make a single timer on 
>> the main queue that fires every quarter-second (I believe that was your 
>> interval from another email), which is associated with the view/window 
>> controller that manages all your text fields and instrument objects, have 
>> that timer use a single cached formatter and loops through all your 100+ 
>> objects, getting their values, formatting them, and setting each appropriate 
>> text field's string value.
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/erwin.namal%40gmail.com
> 
> This email sent to erwin.na...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse

> On 17 sept. 2015, at 16:00, Jean Suisse <jean.li...@gmail.com> wrote:
> 
> Thanks. But I already have one single timer dispatch source that updates all 
> the UI only by transferring double / int values from instance variables to 
> bound properties. The timer fires every second and causes the whole 100+ 
> fields to be updated. This, however, does not prevent KVO to operate for each 
> setter being called.
> More information in my first post where you can see the implementation of the 
> timer dispatch source and of the updateUI functions and in a previous e-mail 
> I sent today. Data format varies based on the data being displayed (I use the 
> formatters to display the correct physical unit for each measurement).
> 
> The program is running now. Last time I check, the issue is solved just by 
> adding this code in the UI update loop.
> 
>> NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined 
>> location:NSZeroPoint modifierFlags:0 timestamp:[NSDate 
>> timeIntervalSinceReferenceDate] windowNumber:0 context:nil subtype:0 data1:0 
>> data2:0];
>>  [NSApp postEvent:event atStart:YES];
> 
> I start more and more to believe in Sandy McGuffog & Jonathan Taylor’s 
> hypothesis :
> 
>>> As I understand it (and as discussed on this list some while back I think) 
>>> pools may not always be drained when you expect.
> 
>>  // Create a periodic timer that "tickles" the main event loop to drain 
>> autorelease pools.
>>  // Response from cocoa-dev discussion was that:
>>  //   This is a long-standing problem with AppKit. According to the 
>> documentation,
>>  //   "The Application Kit creates an autorelease pool on the main 
>> thread at the
>>  //   beginning of every cycle of the event loop, and drains it at 
>> the end, thereby
>>  //   releasing any autoreleased objects generated while processing 
>> an event."
>>  //   However, this is somewhat misleading. The "end" of the event 
>> loop cycle is
>>  //   immediately before the beginning. Thus, for example, if your app 
>> is in the background
>>  //   and not receiving events, then the autorelease pool will not be 
>> drained. That's why
>>  //   your memory drops significantly when you click the mouse or switch 
>> applications.
> 
>> Based on that, where you’re losing memory is to bitmapped backed CALayers 
>> that aren’t being released. Depending on the size of the bitmap, they can be 
>> big - MBs each. They are being allocated in the Kernel, so aren’t showing in 
>> instruments. Why they aren’t being released, I couldn’t say. Maybe a retain 
>> loop, maybe an animation that never finishes, etc, etc. But I’d starting 
>> looking (a) by removing any Core animation you can, and (b) I’d look at any 
>> NSWindows/NSViews/NSControllers that aren’t being released when you close 
>> all visible windows.
> 
> 
> Cheers,
> Jean
> 
>> On 17 sept. 2015, at 15:47, Gary L. Wade <garyw...@desisoftsystems.com 
>> <mailto:garyw...@desisoftsystems.com>> wrote:
>> 
>> Okay, so what it appears you have is over 100 timers being fired whose only 
>> purpose is to transfer a single value from one variable to another so that 
>> bindings will hear that change and update your UI.
>> 
>> A better approach is to remove bindings completely, make a single timer on 
>> the main queue that fires every quarter-second (I believe that was your 
>> interval from another email), which is associated with the view/window 
>> controller that manages all your text fields and instrument objects, have 
>> that timer use a single cached formatter and loops through all your 100+ 
>> objects, getting their values, formatting them, and setting each appropriate 
>> text field's string value.
>> --
>> Gary L. Wade (Sent from my iPad)
>> http://www.garywade.com/ <http://www.garywade.com/>
>> 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse

> On 17 sept. 2015, at 14:58, Jean Suisse <jean.li...@gmail.com> wrote:
> 
> Thank you for this advice!
> 
> My app has tabbed views that are implemented through the toolbar. When I 
> switch view, some memory indeed gets released. Sometimes a little, sometimes 
> way much more, but never everything.
> 
> However, I am investigating Jonathan Taylor’s suggestion (see below). Looks 
> like gold. I have added
> 
>> NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined 
>> location:NSZeroPoint modifierFlags:0 timestamp:[NSDate 
>> timeIntervalSinceReferenceDate] windowNumber:0 context:nil subtype:0 data1:0 
>> data2:0];
>>  [NSApp postEvent:event atStart:YES];
> 
> in my UI update loop. No more leak in simulation mode (with fake 
> Instruments). These afternoon (it is 3 pm for me) I plan to test it on the 
> prototype. Result in two hours time.
> There seems to be more than what Jonny describes, because switching app or 
> views isn’t enough for me.
> 
> Meanwhile, I am interested in learning how to drop Core Animation. I don’t 
> feel like I’m using it (NSTextFiels updates on the UI).
> 
> Cheers,
> Jean
> ---
> Jean Suisse
> Institut de Chimie Moléculaire de l’Université de Bourgogne
> (ICMUB) — UMR 6302
> 
> 
> 
>> On 16 sept. 2015, at 20:29, Jonathan Taylor wrote:
>> 
>> Hi Jean,
>> 
>> A wild guess that might or might not have any relevance to your problem: I 
>> see that you are wrapping your blocks with an autorelease pool, and that 
>> reminded me of a problem I dealt with a while back. 
>> 
>> As I understand it (and as discussed on this list some while back I think) 
>> pools may not always be drained when you expect. I'm not sure if that 
>> applies to explicitly generated ones, but it certainly seems to apply to 
>> little snippets of callback code (e.g. UI accessors) that may be called from 
>> within the main event loop. I have a dim recollection there may be some 
>> funny stuff with GCD-related code as well.
>> 
>> Anyway, I have the following little bit of code in my application. I don't 
>> remember all the details now, so the comment itself (and perhaps a trawl 
>> through the list archives for that text) will have to serve as an 
>> explanation:
>> 
>>  // Create a periodic timer that "tickles" the main event loop to drain 
>> autorelease pools.
>>  // Response from cocoa-dev discussion was that:
>>  //   This is a long-standing problem with AppKit. According to the 
>> documentation,
>>  //   "The Application Kit creates an autorelease pool on the main 
>> thread at the
>>  //   beginning of every cycle of the event loop, and drains it at 
>> the end, thereby
>>  //   releasing any autoreleased objects generated while processing 
>> an event."
>>  //   However, this is somewhat misleading. The "end" of the event 
>> loop cycle is
>>  //   immediately before the beginning. Thus, for example, if your app 
>> is in the background
>>  //   and not receiving events, then the autorelease pool will not be 
>> drained. That's why
>>  //   your memory drops significantly when you click the mouse or switch 
>> applications.
>>  [JDispatchTimer allocRepeatingTimerOnQueue:dispatch_get_main_queue() 
>> atInterval:5.0 withHandler:^{
>>  NSEvent *event = [NSEvent 
>> otherEventWithType:NSApplicationDefined location:NSZeroPoint modifierFlags:0 
>> timestamp:[NSDate timeIntervalSinceReferenceDate] windowNumber:0 context:nil 
>> subtype:0 data1:0 data2:0];
>>  [NSApp postEvent:event atStart:YES];
>>  }];
>> 
>> 
>> I wonder if that would be any help with your case - either for the exact 
>> reasons I encountered, or for some reason along similar lines. It just might 
>> be a wild stab in the dark at a quick (but obscure) fix, but if it doesn't 
>> help then I guess you'll have to start exploring things with Instruments as 
>> others have suggested.
>> 
>> Cheers
>> Jonny
> 
> 
> 
>> On 17 sept. 2015, at 14:15, Sandy McGuffog <mcguff...@gmail.com 
>> <mailto:mcguff...@gmail.com>> wrote:
>> 
>> Based on that, where you’re losing memory is to bitmapped backed CALayers 
>> that aren’t being released. Depending on the size of the bitmap, they can be 
>> big - MBs each. They are being allocated in the Kernel, so aren’t showing in 
>> instruments. Why they aren’t being released, I couldn’t say. Maybe a retain 
>> loop, maybe an ani

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse
OK, I understand. That was an exemple. The 100+ variables are spread on four 
Instruments. So I call 4 updateUI functions sequentially. There is no 
difference with having everything in a single function.

Since I chose to use bindings directly on the instruments properties for this 
project (not very elegant), I have indeed a strong coupling between the view 
and the instruments. Initially, the UI was designed for the instruments (the 
model isn’t flexible and the App will run for two years before being thrown 
away…). So I tied the UI directly to the instrument’s properties. That was a 
little to fast to be good and updates did occur from background threads. Having 
intermediary variables and updating the UI in one shot from the main thread 
every second was the quickest option to get everything up and running again… 
but then the app started eating memory like crazy.

I could spend time decoupling the view from the instruments, but at some point 
I would still have to update the UI and I get back the memory issues.
These, which were qualified by others as “long standing bug in appkit” are now 
solved by the hack described before.

I am still interested in understanding what happens with CA Layers in the 
kernel.



> On 17 sept. 2015, at 16:34, Gary L. Wade <garyw...@desisoftsystems.com> wrote:
> 
> Yes, I saw that code, but it only set a single variable and appeared to only 
> be associated with a single instrument. If you have 100+ instruments, that 
> would be 100+ separate updates. You know your code better than I and may be 
> simplifying things for us, but I've seen cases sounding very much like yours 
> where bindings is not the right solution. From how I read this, you are 
> tightly coupling your view to your model. Consider decoupling your 
> view-updating code like I suggested and you should see a significant change 
> without a hack.
> --
> Gary L. Wade (Sent from my iPad)
> http://www.garywade.com/
> 
>> On Sep 17, 2015, at 7:00 AM, Jean Suisse <jean.li...@gmail.com> wrote:
>> 
>> Thanks. But I already have one single timer dispatch source that updates all 
>> the UI only by transferring double / int values from instance variables to 
>> bound properties. The timer fires every second and causes the whole 100+ 
>> fields to be updated. This, however, does not prevent KVO to operate for 
>> each setter being called.
>> More information in my first post where you can see the implementation of 
>> the timer dispatch source and of the updateUI functions and in a previous 
>> e-mail I sent today. Data format varies based on the data being displayed (I 
>> use the formatters to display the correct physical unit for each 
>> measurement).


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-17 Thread Jean Suisse
From what you write, that’s already what I do.

> Just as I thought. You're overloading the system by tightly coupling your 
> model and your view. Let your instruments (models) do their work, and let 
> your controller consult them when ready and update the view; don't use your 
> controller to tell the models to update the views.

That’s the job of the data collecting threads. I have one timer dispatch source 
per communication interface that tells the instruments objects to gather data 
from the physical instruments. This runs every second or so. It’s hard to tell 
because communication can be over wired lines or wireless.

Then I have one timer dispatch source that collects data gathered from the 
instrument objects, process them and put them in their respective data files. 
This timer fires exactly once every second.

One one timer dispatch source deals with synchronization issue. It fires 
exactly once every second, returns ASAP.

On UI update dispatch source that should ideally collects data gathered from 
the instrument objects and display them. And there is a slight shade of gray. 
Instead of having an other object owning the properties bound to the UI  and 
doing displayObject.boundProperty = instrument.valueProperty, the properties 
bound to the UI are members of the instrument object. So what happens is I do 
instrument.boundProperty = instrument.valueProperty.

Finalizing the decoupling would not solve the memory display issue, since it’s 
a bug in appkit itself. It would just make things a little bit cleaner.




___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-16 Thread Jean Suisse
Dear All,

I have an app that uses Cocoa and dispatch sources leaking a lot (ca. 5GB / 
17h). The origin seems to come from a combination of dispatch sources, Bindings 
& Core Animation. Below is a brief description of the app, what issues I 
encounter and the related code.

DESCRIPTION OF THE APPLICATION
I have a scientific data acquisition App that is expected to run continuously 
for a year and collect data every second from 144 sensors. The app is written 
in Objective-C, targets MAC OS, and uses GCD a lot. Basically, I start several 
dispatch queues running blocks to deal with scientific instruments connected to 
different data buses. I use appropriate synchronization tools or locking 
mechanisms to run everything safely and deal with concurrency.

ISSUES
At first, I did bind the 115 textfields (most having number formatters) on the 
main view directly to the properties of the class instances representing 
different physical scientific instruments. The issue was that it caused the UI 
being refreshed from various threads while my app was operating (timer dispatch 
sources manipulating the objects to collect data from instruments causing UI 
refresh through bindings). I got the message "CoreAnimation: warning, deleted 
thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in 
environment to log backtraces” a lot.

So, I made a simple function (refreshUI) which transfers the data from 
non-bound properties of the objects to bound-properties of the objects like 
this :


// [myInstrument updateUI];
- (void)updateUI
{
assert([NSThread isMainThread]);

// LEFT:  property of the object tied to the UI through bindings made 
in IB
// RIGHT: as a quick fix: variable member of the object updated using a 
background thread.
self.lastPT100Temperature   = self->l_PT100Temperature;
self.lastPAAtmosphericPressure  = self->l_PAAtmosphericPressure;

// etc...
}

This function is called once every second on the main thread like this :

- (void)startUIAutoUpdate
{
// @property (strong) dispatch_source_t uiRefreshTimer;
self.uiRefreshTimer = 
dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, 
dispatch_get_main_queue());
dispatch_source_set_timer(self.uiRefreshTimer, DISPATCH_TIME_NOW, 1.0 * 
NSEC_PER_SEC, 0.25 * NSEC_PER_SEC);

__weak typeof(self) weakself = self;
dispatch_source_set_event_handler(self.uiRefreshTimer,  
^{
@autoreleasepool
{
__strong typeof(weakself) strongself = weakself;

[strongself.myInstrument updateUI];
// etc...
}
};

dispatch_resume(self.uiRefreshTimer);
}

OBSERVATIONS
The app starts by taking around 25 MB of memory (reported by Activity monitor). 
After 17h, I see around 5GB of memory used. After a few days… the app crashes. 
On the other hand, if I comment the family of lines "[strongself.myInstrument 
updateUI]", the app can run for a month using only 25-35 MB of memory. Data are 
still collected every second and stored on disk of course, but not shown on 
screen.

If I prevent my app from trying to communicate with the instruments (by not 
instantiating the objects representing the communication interface) I can make 
it run faster and take thousands of dummy data points a second (and store them 
on the disk). The leaking issue is a little increased, but not by a factor of 
1000. Only by a factor of 30 to 60. This is consistent with a UI refresh issue.

Additionally, I was unable to find any leaks with Instruments (but I barely 
know how to use it) and the amount of memory reported by Instruments is far 
less than the one reported by Activity monitor (but still, the system starts 
swapping a lot after a while, so Activity monitor must be right). But 
interestingly, when switching apps with CMD-TAB, Instruments shows memory jumps 
(memory brutally decreases).

QUESTION
Well, I feel a little lost at this point. I lack the know-how to further 
investigate the issue. Does anyone know what to try / measure / observe to get 
more clues?

Best Regards,
Jean
---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Lost memory, GCD, dispatch sources, Cocoa bindings & User interface

2015-09-16 Thread Jean Suisse
Hi Jonny,

I also have a feeling the issue lies somewhere between the dispatch mechanism 
and Core Animation. I have seen some funny things too. For instance, I can’t 
run a serial queue for months. Some objects escape the autorelease pool created 
in the block (and seemingly encompassing everything in it) and are only 
released when the queue is empty. Looks like for some reason GCD waits for the 
queue to be idle to release certain objects (which are probably not mine).

Workarounds : I don’t post all blocks on the queue. Just enough to run for a 
few hours. The last blocks on the queue triggers the next few blocks to be 
posted on a second queue and so on...
OR the last block on the queue posts a block on the main thread, which kills 
the queue after the posting block has exited. Re-creates the queue and posts 
the next blocks.

What catches my attention in you message is: memory drops significantly when 
you click the mouse or switch applications.

I have observed this behavior. One of my app, which runs for months, eventually 
crashes and suffers the same issue as described here. I have observed that:

– When switching apps with CMD-TAB, I can have huge drops in consumed memory 
(hundreds of MB). Sometimes, hitting CMD-TAB causes the app not to continue 
eating memory. Sometimes, it causes the app to start eating memory again. BUT, 
when the “right” CMD–TAB that prevents the app from eating memory occurs, it is 
not a permanent fix. The app will resume eating memory by itself when left 
alone.
– The amount of memory eaten is not related to the rate at which my app runs 
its measurements cycles (so my code does not leak), but only when this rate is 
too fast for UI update to keep up (thus pointing towards UI update-related 
problem).
– The app doesn’t have memory issues if I run it without actually unpacking the 
NIB containing the view that displays the results (the view is just an instance 
of NSView holding labels with number formatters, mostly).

Unfortunately, what makes the app so hard to debug in Instruments, is that by 
running, it creates and destroys billions of objects quickly (I do data 
processing, store data points in text files, perform operations on strings, 
etc.). Instruments just can’t cope with it, slows down quickly, takes GB of 
memory space… etc.


What I can tell so far is that 

1. the memory is not being leaked (no leaks reported by instruments) but 97.0 % 
of the memory (heap marks 6 seconds appart) occupied is taken after:

Bytes Used  Count   Symbol Name
 690.19 KB  98.1%   9478   __CFRunLoopDoObservers

…….

Bytes Used  Count   Symbol Name
 682.42 KB  97.0%   9319 
CA::Layer::display_()

More Specifically:

Bytes Used  Count   Symbol Name
 679.89 KB  96.6%   9265
 -[NSView(NSInternal) 
_recursive:displayRectIgnoringOpacity:inGraphicsContext:CGContext:topView:shouldChangeFontReferenceColor:]
 349.53 KB  49.6%   5164
  -[NSControl drawRect:]
 203.28 KB  28.9%   3035
  -[NSView(NSInternal) 
_setupFontSmoothingForLayerDrawingIntoContext:previousColor:previousFlag:]
 126.80 KB  18.0%   1060
  -[NSMatrix drawRect:]

2. I did show all the incriminated code in my first post.
And I can’t think how self.myProperty = self->myInstanceVariable can 
leak under ARC.

3. Running without UI shows no issue.
4. The UI is only a bunch of NSTextFields with bindings.

I will try to “tickle” the main loop into draining autoreleased objects and 
report back.

Thanks,
Jean


> On 16 sept. 2015, at 20:29, Jonathan Taylor  
> wrote:
> 
> Hi Jean,
> 
> A wild guess that might or might not have any relevance to your problem: I 
> see that you are wrapping your blocks with an autorelease pool, and that 
> reminded me of a problem I dealt with a while back. 
> 
> As I understand it (and as discussed on this list some while back I think) 
> pools may not always be drained when you expect. I'm not sure if that applies 
> to explicitly generated ones, but it certainly seems to apply to little 
> snippets of callback code (e.g. UI accessors) that may be called from within 
> the main event loop. I have a dim recollection there may be some funny stuff 
> with GCD-related code as well.
> 
> Anyway, I have the following little bit of code in my application. I don't 
> remember all the details now, so the comment itself (and perhaps a trawl 
> through the list archives for that text) will have to serve as an explanation:
> 
>   // Create a periodic timer that "tickles" the main event loop to drain 
> autorelease pools.
>   // Response from cocoa-dev discussion was that:
>   //   This is a 

Re: Lost memory, GCD, dispatch sources, ?Cocoa bindings & User interface

2015-09-16 Thread Jean Suisse

> But I agree that this all (meaning the contortions to get updates onto the 
> main thread) seems like too much flash and not enough bang. The easiest way 
> would be to dispatch the original update code in blocks onto the main thread 
> asynchronously, thus serializing them and generating KVO notifications 
> safely. 

I thought of that at first, to solve the uncommitted CA transactions issues. 
But the syntax is ugly. And I didn’t want to post blocks from all over the 
place to the main thread (I have 100+ NSTextfields with number formatters 
updated every second… meaning as many blocks...).
So I went for the updateUI solution, which is cleaner: It only requires me to 
duplicate instance variables. 

At this point, I would like to add that instance variables (and their UI–bound 
property counterpart) are mostly double with a few int, so  they aren’t 
retained objects subjects to leaks.

> When I think about it in those terms, it’s clear (to me, at least) that the 
> *real* problem is one of coalescing a potentially large number of updates 
> over time. In other words, this thread is really about premature optimization 
> and its ugly consequences.

The issue, to me, is to get my app to run for a few days without crashing. The 
only way I have to make it work, currently, is by not updating the UI.
This is a shame considering the time I spent arranging all those textfields in 
a nice fashion to make it easily readable despite the large number of displayed 
values (and also, IB gets really really slow with that many controls on a view, 
making the design part a real pain).

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Creating pdf document

2014-08-16 Thread Jean Suisse
Dear All,

I have a goods management cocoa application which needs to generate pdf 
documents. It isn’t a document-based app, it doesn’t use core data and the data 
that should be printed are not laid out in any of the views displayed to the 
user.

In short, I would need to generate a pdf document with nice headers and footers 
on each page, a title and some information on the first page, then a multi-page 
section containing some of the database displayed as a table, followed by a 
summary with some text and numbers at the end.

I have little experience with the cocoa printing system (basically, I know how 
to print a view) and the main issues I face are :

– alignment of the text (left, right, …) on the page… I would like to select 
the paper format and the orientation. This is not an issue since the app 
development is strongly tied to laws and regulation, limiting the user’s choice 
to A4 paper, both orientations, is acceptable.
– drawing the table so that it is well cut at the bottom of the page. If 
possible I would like to replicate the header of the table on each new page.

Before I even start developing this part of the app, what advices would you 
give me to speed up the process ? Is there some kind of template system that I 
can use, to visually build the document and define the position of the cotent? 
Should I build a view, then print it ? Is it more efficient to work directly on 
the pdf?

Thank you for your help,
Jean
---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302






___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Creating pdf document

2014-08-16 Thread Jean Suisse
Thank you Jonathan Mitchell, Edward Taffel, and Joel Norvell for your replies. 

I asked the question before catching a train, hoping to have some thoughts to 
read when arriving home. However, during the 3.5 hour-long journey, I had some 
time to think about it and found a simple solution: I realized that the king of 
the layout is probably is a web browser and that a web browser can print 
content really well.

The solution isn’t not pure cocoa, but it works pretty well for me and solves 
all the issues I had, especially about the layout and the template. That said, 
I am still interested by reading your thoughts (though I will probably keep 
this solution anyway because it gives me the option to offer template edition 
features to the user).

So I made an HTML template to be loaded in a web view :

 [webView setFrameLoadDelegate: self];
 [[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL 
 fileURLWithPath:templateURL]]];

Then the web view is printed (hitting have as pdf does the job):

- (void)webView:(WebView*)webView didFinishLoadForFrame:(WebFrame *)frame
{
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];

[printInfo setPaperSize:NSMakeSize(595.22, 841.85)];
[printInfo setTopMargin:0.0];
[printInfo setLeftMargin:0.0];
[printInfo setRightMargin:0.0];
[printInfo setBottomMargin:0.0];

NSPrintOperation *printOp = [NSPrintOperation 
printOperationWithView:[[[printView mainFrame] frameView] documentView] 
printInfo:printInfo];
[printOp setShowsPrintPanel: YES];
[printOp runOperation];
}


It took me some time to figure out that the printing had to be done in 
didFinishLoadForFrame – I am no webkit expert.

Code is ARC, and reveals a non-programming related “issue” I have had for a 
long time using preview: if the background is transparent, then it is 
represented by two-color squares in preview. The document displayed is ugly and 
I can barely read the text. So to create this document, I used 0 margins, and 
wrapped the html in a DIV with the appropriate padding to emulate the margin 
(could have done so with margin too probably). Just remove the lines about the 
margins to see what I am talking about (content is on a white background 
surrounded by an ugly transparent margin).

Thank you for your feedback,
Jean

On Aug 16, 2014, at 19:25 , Joel Norvell framewor...@yahoo.com wrote:

 Hi Jonathan,
 
 Thanks for the great PDFKit layout recipe on cocoa-dev, today!
 
 I've done a number of things with PDFKit, but not the type of layout you 
 described.
 
 So now, if I ever need to, I'll have a path to follow :-)
 
 Gratefully yours,
 Joel
 
 P.S. And thank you Jean Suisse for asking such an interesting question!

On Aug 16, 2014, at 18:50 , edward taffel etaf...@me.com wrote:

 a cocoa solution may yet be forthcoming, but—if you enjoy pdf, qua pdf, i 
 should investigate CGPDFContextCreate.
 
 regards,
 edaward

On Aug 16, 2014, at 18:12 , Jonathan Mitchell jonat...@mugginsoft.com wrote:

 
 On 16 Aug 2014, at 11:18, Jean Suisse jean.li...@gmail.com wrote:
 
 Dear All,
 
 I have a goods management cocoa application which needs to generate pdf 
 documents. It isn’t a document-based app, it doesn’t use core data and the 
 data that should be printed are not laid out in any of the views displayed 
 to the user.
 
 In short, I would need to generate a pdf document with nice headers and 
 footers on each page, a title and some information on the first page, then a 
 multi-page section containing some of the database displayed as a table, 
 followed by a summary with some text and numbers at the end.
 
 I have little experience with the cocoa printing system (basically, I know 
 how to print a view) and the main issues I face are :
 
 – alignment of the text (left, right, …) on the page… I would like to select 
 the paper format and the orientation. This is not an issue since the app 
 development is strongly tied to laws and regulation, limiting the user’s 
 choice to A4 paper, both orientations, is acceptable.
 – drawing the table so that it is well cut at the bottom of the page. If 
 possible I would like to replicate the header of the table on each new page.
 
 Before I even start developing this part of the app, what advices would you 
 give me to speed up the process 
 
 Is there some kind of template system that I can use, to visually build the 
 document and define the position of the cotent?
 Unfortunately not
 
 Should I build a view, then print it ?
 I would say it depends on the complexity of the desired output.
 
 Is it more efficient to work directly on the pdf?
 In my case I had to target a complex official pdf.
 Creating an actual NSView would have been tedious and fragile.
 It was much easier to use a existing pdf generated in say InDesign and write 
 the required text to it.
 
 I would:
 Declare a PDFDocument subclass.
 In the document - (Class)pageClass return a custom PDFPage class.
 You may have to be creative with PDFPage

Re: MODERATOR: (Temporary) End of Thread (was Re: I can't use man command to find c api manuals in Mavericks GM)

2013-10-22 Thread Jean Suisse
Actually, it sounds like it's available from the app store now.

Jean

On Oct 22, 2013, at 20:56 , Chris Hanson c...@me.com wrote:

 Until OS X Mavericks becomes available to everyone via the App Store, it's 
 still under NDA. Once it's available it can be discussed here, until then it 
 can't.
 
  -- Chris, Cocoa-Dev co-mod
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: developer.apple.com under maintenance for a few days now?

2013-07-23 Thread Jean Suisse
And on top of everything, I just got an email from my web host telling me that 
they too were hacked a few days ago...
The attacker first got access to an administrator's mailbox, used it to get to 
an other employee's VPN and then to breach one of their sysadmin account. 
Result: their Europe database dumped. In full. To the last bit of it.

Three major players within a few days. What are the odds?

On Jul 23, 2013, at 7:51 AM, Jean Suisse wrote:

 I believe we all got it. Personally, I'd rather like they take as much time 
 as needed on this one.
 Same happened to ubuntuforums.org (http://ubuntuforums.org/announce.html), 
 which is still down, except that it seems the attacker(s) got the as salted 
 hashes as well.
 
 On Jul 22, 2013, at 2:59 AM, Caylan Larson wrote:
 
 I just received an email from apple indicating the Dev site was a victim of 
 a hack. 
 


---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: developer.apple.com under maintenance for a few days now?

2013-07-22 Thread Jean Suisse
I believe we all got it. Personally, I'd rather like they take as much time as 
needed on this one.
Same happened to ubuntuforums.org (http://ubuntuforums.org/announce.html), 
which is still down, except that it seems the attacker(s) got the as salted 
hashes as well.

On Jul 22, 2013, at 2:59 AM, Caylan Larson i...@caylan.net wrote:

 I just received an email from apple indicating the Dev site was a victim of a 
 hack. 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: developer.apple.com under maintenance for a few days now?

2013-07-21 Thread Jean Suisse
Dear Laurent,

Every now and then such questions arise (for developer, bug reporter, etc.).
To answer you: it seems to be down for you only (I just tested).

Also, there is a nice free online service for answering such questions 
(downforme.org):
http://downforme.org/is-developer.apple.com-down-today-for-everyone

Have a nice sunday,
Jean

---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


On Jul 21, 2013, at 4:10 PM, Laurent Daudelin wrote:

 Is it only me or has developer.apple.com and devforums.apple.com been 
 inaccessible for maintenance for several days now?
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin   
 http://www.nemesys-soft.com/
 Logiciels Nemesys Software
 laur...@nemesys-soft.com
 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: developer.apple.com under maintenance for a few days now?

2013-07-21 Thread Jean Suisse
Indeed. You're right. I can't log in. 
Given their statement about expiring memberships, they are probably expecting 
the maintenance to take a long while.

---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


On Jul 21, 2013, at 4:23 PM, David Delmonte wrote:

 hmm. the referenced site shows developer.apple.com being up. This is correct. 
 However, if you select any of the dev groups (iOS, OSX, Safari), they are not 
 up.
 
 
 On Jul 21, 2013, at 5:18 PM, Jean Suisse wrote:
 
 Dear Laurent,
 
 Every now and then such questions arise (for developer, bug reporter, etc.).
 To answer you: it seems to be down for you only (I just tested).
 
 Also, there is a nice free online service for answering such questions 
 (downforme.org):
 http://downforme.org/is-developer.apple.com-down-today-for-everyone
 
 Have a nice sunday,
 Jean
 
 ---
 Jean Suisse
 Institut de Chimie Moléculaire de l’Université de Bourgogne
 (ICMUB) — UMR 6302
 
 
 On Jul 21, 2013, at 4:10 PM, Laurent Daudelin wrote:
 
 Is it only me or has developer.apple.com and devforums.apple.com been 
 inaccessible for maintenance for several days now?
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin 
 http://www.nemesys-soft.com/
 Logiciels Nemesys Software  
 laur...@nemesys-soft.com
 
 
 __
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Jiggling Shadow Offset

2013-05-22 Thread Jean Suisse
On 22 mai 2013, at 01:52, Seth Willits sli...@araelium.com wrote:

 Changing the blur radius has no affect on the offset. It still behaves the 
 same way. I'm not sure why you think 0.5 would be any different.

I believed that using 0.5 would solve the issue… because I have been there 
before. I should have mentioned that first, sorry.
IMHO, what you are observing is a plain bug because there is no way using a 
blur radius of 0.5 can yield an always visible shadow when using a bigger 1.0 
fails to do so.
Yet, as you can see in the video I sent you, it works perfectly.

Jean
Tests have been performed on a regular up-to-date 10.8.3 MBP equipped with a 
13 display.

 
 On May 21, 2013, at 3:44 PM, Jean Suisse wrote:
 
 Have you tried replacing 
 
 shadow.shadowBlurRadius = 1.0;
 
 With:
 
 shadow.shadowBlurRadius = 0.5;
 
 It should work as expected.
 
 Jean
 
 On 22 mai 2013, at 00:11, Seth Willits sli...@araelium.com wrote:
 
 What bit of obviousness am I missing here?
 http://www.sethwillits.com/temp/ShadowOffset.mov
 


---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Jiggling Shadow Offset

2013-05-21 Thread Jean Suisse
Have you tried replacing 

shadow.shadowBlurRadius = 1.0;

With:

shadow.shadowBlurRadius = 0.5;

It should work as expected.

Jean
---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


On 22 mai 2013, at 00:11, Seth Willits sli...@araelium.com wrote:

 
 What bit of obviousness am I missing here?
 http://www.sethwillits.com/temp/ShadowOffset.mov
 
 
 --
 Seth Willits
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?

2013-05-15 Thread Jean Suisse
Thanks for your replies.
Unfortunately, I can't easily avoid 
initWithHTML:dataUsingEncoding:documentAttributes: 
But I can postpone it long enough to move its execution to an other thread 
(serial dispatch queue).
That solves the issue.

Jean

On 8 mai 2013, at 21:14, Jens Alfke j...@mooseyard.com wrote:

 
 On May 7, 2013, at 3:52 PM, Ken Thomases k...@codeweavers.com wrote:
 
 Yes, it can.  Under the hood, NSAttributedString is using WebKit for HTML 
 rendering.  In part that means that, when invoked from a background thread, 
 it has to shunt the work to the main thread.  But it also means the main 
 thread may have to run the run loop during the call.  It's a nuisance, but 
 it's necessary since HTML can have references to external resources that 
 need to be loaded.
 
 I’ve had trouble with this method in the past, for exactly that reason — you 
 can get weird reentrancy problems from runloop sources like timers being 
 invoked while in the middle of the call. (It’s also pretty slow.)
 
 IMHO it’s best to avoid this method if you can. For example, the last time 
 this came up all I needed was the plain text, so I wrote a little string 
 transformer to strip out HTML tags and expand HTML entities. For more 
 involved work you could use NSXMLParser (with the “tidy” option) to parse the 
 HTML into a DOM and then walk through that.
 
 —Jens


---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?

2013-05-15 Thread Jean Suisse
Right. I dispatch the block on the main thread to solve the reentrancy issues 
as stated below. The serial queue is involved elsewhere.


On 15 mai 2013, at 16:12, Ken Thomases wrote:

 On May 15, 2013, at 8:58 AM, Jean Suisse wrote:
 
 Thanks for your replies.
 Unfortunately, I can't easily avoid 
 initWithHTML:dataUsingEncoding:documentAttributes: 
 But I can postpone it long enough to move its execution to an other thread 
 (serial dispatch queue).
 That solves the issue.
 
 I doubt it will.  If that method is invoked from a background thread, it will 
 shunt the work to the main thread anyway.  In other words, it always does its 
 work on the main thread.
 
 Regards,
 Ken
 


On 8 may 2013, at 01:06, Jean Suisse wrote:

 Thanks for this suggestion. Actually, once identified, I fixed the bug fairly 
 quickly by postponing the task (dispatched a block on the main thread for 
 that).
 The bug was caused by two successive events arriving in a short timeframe so 
 that the stack looked like that:
 
 0 my callback
 1 __CFSocketPerformV0
 
 9 initWithHTML:dataUsingEncoding:documentAttributes:
 10 my function 1
 11 my function 2
 12 my callback
 13 __CFSocketPerformV0
 ---
 23 NSApplicationMain
 24 main
 25 Start
 
 and my callback never was designed to be called a second time before the 
 first call was finished. Dispatching a block to handle my function 1 fixed 
 the issue.
 However, information about initWithHTML:dataUsingEncoding:documentAttributes: 
 running an event loop could be worth mentioning in the docs…
 
 Jean
 
 On 8 mai 2013, at 00:52, Ken Thomases wrote:
 
 On May 7, 2013, at 5:37 PM, Jean Suisse wrote:
 
 By any chance, could a call to [[NSAttributedString alloc] 
 initWithHTML:dataUsingEncoding:documentAttributes:] lead to the event loop 
 being run before the call returns?
 
 Yes, it can.  Under the hood, NSAttributedString is using WebKit for HTML 
 rendering.  In part that means that, when invoked from a background thread, 
 it has to shunt the work to the main thread.  But it also means the main 
 thread may have to run the run loop during the call.  It's a nuisance, but 
 it's necessary since HTML can have references to external resources that 
 need to be loaded.
 
 Consider the other method, -[NSAttributedString 
 initWithHTML:options:documentAttributes:] and its options dictionary, which 
 can have keys like NSTimeoutDocumentOption and 
 NSWebResourceLoadDelegateDocumentOption.  Those imply a pretty involved 
 process under the hood.  I'm fairly certain that this method is used for the 
 implementation of the method you're using.
 
 You may be able to use those options to minimize the use of the run loop, 
 but probably not eliminate it.
 
 Regards,
 Ken
 
 
 ---
 Jean Suisse
 Institut de Chimie Moléculaire de l’Université de Bourgogne
 (ICMUB) — UMR 6302
 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Getting a splash screen to show

2013-05-15 Thread Jean Suisse
In one application I have to display a splash screen while a poorly written 
framework (DAQmxBase from National Instruments) takes 6 to 11 seconds to 
initialize itself on the main thread.
To do so, I display my splash screen as a non modal, top-level, centered window 
(use NSWindow's setLevel:NSFloatingWindowLevel to make it top-level).

Do you require your splash screen or the registration window to be modal? 

Jean



On 15 mai 2013, at 17:26, Steve Mills smi...@makemusic.com wrote:

 Please don't waste my time arguing that splash screens are bad. It's all been 
 hashed out before.
 
 How am I supposed to force the splash screen to be visible? It's created and 
 shown in applicationWillFinishLaunching. The app is document based. Other 
 modal dialogs *could* appear and go away before the splash screen appears, so 
 order is important. If a modal dlog *does* appear beforehand (e.g. 
 registration), then the splash screen will display. If not, something is 
 preventing the splash screen from showing. This got me thinking it was event 
 manager related, so I added this after showing the splash screen:
 
 [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask 
 untilDate:nil inMode:NSDefaultRunLoopMode dequeue:NO];
 
 That fixed it. Well, it fixed it until I tried launching the app and letting 
 Cocoa restore documents that were open when I quit. Again, no splash screen. 
 Why is this so hard to do?
 
 --
 Steve Mills
 office: 952-818-3871
 home: 952-401-6255
 cell: 612-803-6157

---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Getting a splash screen to show

2013-05-15 Thread Jean Suisse
On 15 mai 2013, at 17:59, Steve Mills wrote:

 On May 15, 2013, at 10:40:38, Jean Suisse wrote:
 
 In one application I have to display a splash screen while a poorly written 
 framework (DAQmxBase from National Instruments) takes 6 to 11 seconds to 
 initialize itself on the main thread.
 To do so, I display my splash screen as a non modal, top-level, centered 
 window (use NSWindow's setLevel:NSFloatingWindowLevel to make it top-level).
 
 Do you require your splash screen or the registration window to be modal?
 
 Only the registration dialog is modal. The splash is not modal because it 
 uses no interaction. It just shows up, some messages get set (in debug builds 
 only), and it goes away when we're all done getting set up. Here's the code 
 that runs after the nib has been loaded. I'm not sure if everything is needed 
 - I didn't write this code:
 
 [splashWindow setLevel:NSFloatingWindowLevel];

That I use.

 [splashWindow setBackgroundColor:[NSColor clearColor]];
 [splashWindow setOpaque:NO];
 [splashWindow setHasShadow:NO];
 [splashWindow invalidateShadow];
 [splashWindow flushWindow];
 [splashWindow display];
 [splashWindow makeKeyAndOrderFront:nil];

That I don't call. I just use  NSWindowController's initWithWindowNibName:

 SetPortWindowPort((WindowRef)[splashWindow windowRef]);
 [[NSApplication sharedApplication] nextEventMatchingMask:NSAnyEventMask 
 untilDate:nil inMode:NSDefaultRunLoopMode dequeue:NO];

That looks weird.

 The strange part is that it does NOT show if Cocoa is going to restore 
 documents. Why would that matter?

I don't know. Something else is going on. Do you require the registration 
dialog to be modal? Looks like making the dialog non modal or showing it up 
later would solve the issue.

Jean



---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?

2013-05-07 Thread Jean Suisse
Dear all,

I am wondering: 
By any chance, could a call to [[NSAttributedString alloc] 
initWithHTML:dataUsingEncoding:documentAttributes:] lead to the event loop 
being run before the call returns?

Jean
---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?

2013-05-07 Thread Jean Suisse
Thank you for this quick response.
I suspected so. Unfortunately,
I just spent five hours straight tracking a random bug – not even remotely 
related to strings – that seemed to occur when a single thread successively 
triggered two events handled by a callback tied to an input source on the event 
loop (took me some time to get that). Of course the callback isn't thread safe… 
and never was designed to be since tied to the runloop. Until now...

Jean

On 8 mai 2013, at 00:40, Mike Abdullah wrote:

 
 On 7 May 2013, at 23:37, Jean Suisse wrote:
 
 Dear all,
 
 I am wondering: 
 By any chance, could a call to [[NSAttributedString alloc] 
 initWithHTML:dataUsingEncoding:documentAttributes:] lead to the event loop 
 being run before the call returns?
 
 I believe so, yes. It's currently implemented using WebKit, which would 
 generally require spinning the runloop while any asynchronous work is 
 performed.
 


---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Does initWithHTML:dataUsingEncoding:documentAttributes: run an event loop?

2013-05-07 Thread Jean Suisse
Thanks for this suggestion. Actually, once identified, I fixed the bug fairly 
quickly by postponing the task (dispatched a block on the main thread for that).
The bug was caused by two successive events arriving in a short timeframe so 
that the stack looked like that:

0 my callback
1 __CFSocketPerformV0

9 initWithHTML:dataUsingEncoding:documentAttributes:
10 my function 1
11 my function 2
12 my callback
13 __CFSocketPerformV0
---
23 NSApplicationMain
24 main
25 Start

and my callback never was designed to be called a second time before the first 
call was finished. Dispatching a block to handle my function 1 fixed the issue.
However, information about initWithHTML:dataUsingEncoding:documentAttributes: 
running an event loop could be worth mentioning in the docs…

Jean


On 8 mai 2013, at 00:52, Ken Thomases wrote:

 On May 7, 2013, at 5:37 PM, Jean Suisse wrote:
 
 By any chance, could a call to [[NSAttributedString alloc] 
 initWithHTML:dataUsingEncoding:documentAttributes:] lead to the event loop 
 being run before the call returns?
 
 Yes, it can.  Under the hood, NSAttributedString is using WebKit for HTML 
 rendering.  In part that means that, when invoked from a background thread, 
 it has to shunt the work to the main thread.  But it also means the main 
 thread may have to run the run loop during the call.  It's a nuisance, but 
 it's necessary since HTML can have references to external resources that need 
 to be loaded.
 
 Consider the other method, -[NSAttributedString 
 initWithHTML:options:documentAttributes:] and its options dictionary, which 
 can have keys like NSTimeoutDocumentOption and 
 NSWebResourceLoadDelegateDocumentOption.  Those imply a pretty involved 
 process under the hood.  I'm fairly certain that this method is used for the 
 implementation of the method you're using.
 
 You may be able to use those options to minimize the use of the run loop, but 
 probably not eliminate it.
 
 Regards,
 Ken
 

---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Global (all-user) preferences for an application

2013-03-21 Thread Jean Suisse

 Isn't resorting to a SMJobBless helper tool endowed with XPC capabilities 
 just for storing a few must-be-global preference a little overkill?
 
 No, it's not overkill.  If it seems like overkill to you, you should 
 re-evaluate your need to set a few must-be-global preferences.  Writing to 
 /Library/anything *is* a *big* deal.

The project is a scientific data acquisition application that aims at being 
plug  play for a wide range of devices. It is based on the idea of letting 
the scientist grab some hardware, build an experiment workbench and interfacing 
everything with the app so that it just works.

Because the app is so versatile there is more configuration to be done and 
parameters to be entered about the hardware than in a traditional application 
where everything pertaining tho the communication interface, ports, 
communication protocol, etc. is built-in. 

We are talking about 5-15 properties per device. I expect users to configure 
around 4 to 6 devices. That's not a lot of configuration to store. But that's a 
lot if you have to enter it for EVERY user on the computer.
How can I avoid global preferences that apply to all users?






___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Global (all-user) preferences for an application

2013-03-21 Thread Jean Suisse
 On Mar 16, 2013, at 6:14 AM, Jean Suisse jean.li...@gmail.com wrote:
 To be user-friendly my app would need to use per-user preferences and global 
 preferences (i.e. that applies to all users). The former I can manage. The 
 later… well, short of coding a helper tool just for dealing with preferences 
 storage, I have no idea on how to proceed.
 
 Isn't this what /Users/Shared is for?


Good call. If I can't find a better solution, more appropriate, I may just 
use that. Thx.
Jean


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Global (all-user) preferences for an application

2013-03-21 Thread Jean Suisse
 No, it's not overkill.  If it seems like overkill to you, you should 
 re-evaluate your need to set a few must-be-global preferences.  Writing to 
 /Library/anything *is* a *big* deal.
 
 Sure seems to me like signed package com.foo.bar should be able to write into 
 /Library/Application Support/com.foo.bar/anything without so much 
 difficulty...

Or at least, the OS could offer applications the possibility to store global 
preferences easily. Can't it be done in a safe way?
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Global (all-user) preferences for an application

2013-03-18 Thread Jean Suisse
 Normally for shared preference or data you would write to a shared file in 
 /Library/Application Support/companyname/filename, but you have to take 
 special care if you're sandboxing your app.

Indeed. It would seem this requires to be root.

 Never write into your application bundle.  It will fail in many cases, most 
 notably: read-only file systems and App Sandbox.

So, what should I do?

 You best bet is likely to turn to Core Foundation, which has built-in support 
 for not only multi-user but also multi-computer: 
 https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFPreferences/CFPreferences.html#//apple_ref/doc/uid/1129-SW1
 You will likely need to programmatically synchronize the CF prefs with the 
 user prefs if you want to use them with NSUserDefaults.


 That is correct, and also you'll need to do this in a privileged helper tool. 
  If you are fortunate enough to be requiring Mac OS X 10.7 or later, read 
 Nathan de Vries' article on the topic…
 http://atnan.com/blog/2012/02/29/modern-privileged-helper-tools-using-smjobbless-plus-xpc/

Thanks for the links. Luckly enough, my app is 10.7+
Isn't resorting to a SMJobBless helper tool endowed with XPC capabilities just 
for storing a few must-be-global preference a little overkill?

Jean
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Global (all-user) preferences for an application

2013-03-16 Thread Jean Suisse
Dear All,

To be user-friendly my app would need to use per-user preferences and global 
preferences (i.e. that applies to all users). The former I can manage. The 
later… well, short of coding a helper tool just for dealing with preferences 
storage, I have no idea on how to proceed. I would rather avoid that since it 
would be a huge step back compared to the developer-frendliness of 
NSUserDefaults.

According to you, what would be the best course of action ? Should I write into 
my application's bundle ?

Jean
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Fast user switching notifications

2013-03-16 Thread Jean Suisse
Thank you very much for your reply. It was really helpful.

Jean


 There is an other way to track the current user: using the 
 SystemConfiguration framework notification:
 
 http://developer.apple.com/library/mac/#qa/qa1133/_index.html
 
 -- Jean-Daniel
 
 
 
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Fast user switching notifications

2013-03-11 Thread Jean Suisse
Dear All,

There may be several approaches to solve the issue I am about to describe, 
either on the userland side or on the kernel side... or in-between, using a 
daemon.

Current situation
A bsd kernel extension communicates with a regular userland application (called 
theApp). The kext gathers statistics, sends data to the user, takes orders from 
the user, etc.. There are two-way communications initiated by both sides using 
control sockets – There may be no market for such app, it is more of 
investigation tool, but that's irrelevant.

Goal
I would need to handle fast user switching, so that data sent by the kext are 
directed towards the user that can actually handle them. This user is the one 
owning the graphic interface (is there a technical word to say that?).

Issue
When switching from user(A) to user(B) (using fast user switching for 
instance), user(A) no longer owns the graphic interface and theApp(A) is no 
longer able to interact with the user and give the required feedback to the 
kext. User(B) starts theApp(B) and interacts normally with the kext. Then, when 
switching from B to A, the same issue occurs in reverse.

Solution
One approach would be to have theApp(A) launched by user(A) to be notified when 
user(A) looses access to the graphic interface.
When switching back to user(A) theApp(A) and theApp(B) would also get notified.

I read this document 
(https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPMultipleUsers/Concepts/UserSwitchNotifications.html),
 but it seems that there is some race condition occurring, maybe as a result of 
interacting with the kernel (the kext must perform a few tasks before allowing 
theApp(A) to disconnect and theApp(B) to connect).

Are there any other alternatives, from the userland side ?

Jean
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Is it possible to detect a virtual machine

2013-03-02 Thread Jean Suisse
I don't have the answer to your question, but here is a thought:
Virtual machines, such as VMWare, present some generic hardware to the OS they 
run. Could you detect the available hardware, check the vendor, and then decide 
wether or not you are running in a virtual environment ?

Jean

---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


On 2 mars 2013, at 17:17, Kjell Nilsson kj...@oops.se wrote:

 Hi 
 
 I am wondering if it is possible to detect if my Cocoa Application is running 
 in a virtual machine like VMWare, VirtualBox or Parallells Desktop from 
 inside my app.
 
 Kind regards
 --kerusan
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Is it possible to detect a virtual machine

2013-03-02 Thread Jean Suisse
There is an article on code project that may be useful to you. Maybe you can 
adapt the code to suit your needs ?
http://www.codeproject.com/Articles/9823/Detect-if-your-program-is-running-inside-a-Virtual

---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


On 2 mars 2013, at 17:58, Jean Suisse wrote:

 I don't have the answer to your question, but here is a thought:
 Virtual machines, such as VMWare, present some generic hardware to the OS 
 they run. Could you detect the available hardware, check the vendor, and then 
 decide wether or not you are running in a virtual environment ?
 
 Jean
 
 ---
 Jean Suisse
 Institut de Chimie Moléculaire de l’Université de Bourgogne
 (ICMUB) — UMR 6302
 
 
 On 2 mars 2013, at 17:17, Kjell Nilsson wrote:
 
 Hi 
 
 I am wondering if it is possible to detect if my Cocoa Application is 
 running in a virtual machine like VMWare, VirtualBox or Parallells Desktop 
 from inside my app.
 
 Kind regards
 --kerusan
 
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Tracking object references

2013-02-22 Thread Jean Suisse
I am not taking any sides here, but rather just interested in the topic at hand 
: Tracking object references.

I had met an issue once that I never solved, which did require me to track down 
retain / release calls. What I did was to find in my code every explicit or 
implicit (@property accessors) calls to retain or release for the leaked 
instance and insert there a log statement with the value of self and a message 
telling me if retain or release was called. Then a few lines of php code 
(regular expressions weren't available in cocoa at that time) were able to 
remove all the balanced retain/release. That should have revealed which 
instance was responsible for the trouble.
This didn't help me much because the source of the leak wasn't in my code 
(turns out the leaked objects were actually copies made by NSTableView), but 
maybe it can help you.

Jean

On 22 févr. 2013, at 21:11, Greg Parker  wrote:

 On Feb 22, 2013, at 7:42 AM, Matt Neuburg m...@tidbits.com wrote:
 Some specific object did send retain. It is that specific object's 
 responsibility eventually to send release. That's how Cocoa memory 
 management works. Instruments *can* know, and *should* tell me, what 
 specific object that is. I wouldn't be here (i.e. using this aspect of 
 Instruments) if this were not the very problem I'm having, i.e. some 
 specific object is not fulfilling its responsibilities and I need to work 
 out who it is. The fact that Instruments doesn't tell me this is not just 
 some mild forgivable accident. It is Teh Suck. m.
 
 Assume for the sake of argument that your attribution model above works. One 
 problem is that the retaining object can hand off its responsibility to some 
 other object, with no way for Instruments to be able to detect the change. 
 For example, consider code that reads a value out of one strong variable, 
 sets that variable to nil, and writes the value to a second strong variable. 
 No retain or release calls are necessary, which means there's no way for 
 Instruments to know that the release responsibility changed.
 
 Another problem is that who called retain? is not always possible to 
 answer. For example, the call to retain could be an optimized tail-call. In 
 that case, the stack trace inside -retain includes no information about the 
 caller of -retain. If you assigned blame to the caller of retain, you might 
 be mis-attributing the release responsibility. Even worse, Instruments has no 
 way to know whether that has happened.
 
 In order to solve problems like these you would need some sort of debug 
 compilation that defeats enough optimizations and preserves enough 
 information for Instruments to see what's going on, and you'd need to compile 
 everything (including OS libraries) this way.
 
 
 -- 
 Greg Parker gpar...@apple.com Runtime Wrangler
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: OS X Collection Views videos?

2013-02-15 Thread Jean Suisse
Well, there are session 205  219 of WWDC2012, but I think both are exclusively 
about IOS6. Might be worth fast forwarding through them, thought.
Jean


On 15 févr. 2013, at 22:46, Rick Mann rm...@latencyzero.com wrote:

 Are there any WWDC videos covering Cocoa Collection Views (not iOS Collection 
 Views)? I just looked through the titles online, but it's hard to discern, 
 and doesn't look like there are any expressly dedicated to the topic.
 
 
 -- 
 Rick
 
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Best guess at expressing a string as a variable

2013-01-23 Thread Jean Suisse
On 23 janv. 2013, at 02:18, jonat...@mugginsoft.com jonat...@mugginsoft.com 
wrote:

 
 My current thinking is, regardless of the language, is to exclude all 
 characters that are not members of NSCharacterSet + (id)letterCharacterSet.
 
 Is  + (id)letterCharacterSet the best choice here?
 
 I don't know. Does it include characters in すごくやる気がある ?
 That is the question. I don't know what range of character ranges + 
 letterCharacterSet includes.
 A better question might be what is the intended use of + letterCharacterSet. 
 Is it locale dependent?
 
That's a fair question. As Jens Alfke pointed out yesterday, the doc states:

Return value: A character set containing the characters in the categories 
Letters and Marks.
Discussion : Informally, this set is the set of all characters used as letters 
of alphabets and ideographs.
So, it should not depend on the locale. It is however a huge set ! And I guess 
that you may not want most of it (all chinese ideograms for instance)

 
 Hmm. Maybe not. I want to keep the generated variable name legible.

 I think I will have to introduce an intermediate NSTextView that filters and 
 displays the natural language input.
 The user can then modify the variable name if necessary before it gets 
 utilised further.

Maybe you could drop the extra textfields and the processing by requesting the 
variable name to use an english alphanumeric character set ?
Otherwise, how would you deal with this input for a variable name: 名前 ? [ If I 
am a japanese user, I would expect your software to call the variable namae ].
IMHO the whole unicode character set is too large. Most language won't accept 
the largest part of the set.

Jean







---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302












___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Printing a view + landscape printing

2013-01-22 Thread Jean Suisse
Thank you very much for your reply.
I can now print the right view. This view (Parent View) has only two large 
custom subviews in which I display graphics.

Currently, when I print Parent View, it is vertically spanned over two pages 
(which are printed) and horizontally spanned over two pages (which are not 
printed).
I tried to determine the size of the printable area of one page and to print a 
rectangle to materialize it, but I couldn't get it right. Here is the code:




NSPrintInfo* printInfo = [[NSPrintOperation currentOperation] 
printInfo];

NSSize paperSize = [printInfo paperSize];
NSSize printAreaSize = NSMakeSize(0.0, 0.0);

printAreaSize.height = paperSize.height - [printInfo topMargin]  - 
[printInfo bottomMargin];
printAreaSize.width  = paperSize.width  - [printInfo leftMargin] - 
[printInfo rightMargin];

// I tried with and without the code below. If I divide by (scale*2.0) 
then the rectangle fits the paper but is displayed across two pages
float scale = [[[printInfo dictionary] 
objectForKey:NSPrintScalingFactor] floatValue];
paperSize.width  = paperSize.width  / (scale);
paperSize.height = paperSize.height / (scale);

[NSBezierPath strokeRect:NSMakeRect(0, 0, paperSize.width, 
paperSize.height)];

Currently, the size I get for the with paper size is way too large, even when 
divided by scale. This code is executed in parent view.


On 21 janv. 2013, at 18:36, Keary Suska cocoa-...@esoteritech.com wrote:

 On Jan 21, 2013, at 8:17 AM, Jean Suisse wrote:
 
 I have a non-document based application to which I would like to add 
 printing support.
 The main window (the one in the .xib created by default by Xcode) contains a 
 split view.
 
 Currently, when printing, I get only the left pane of the split view (at 
 best) or the control that has the focus (a textfield for instance) at worse.
 
 This likely has to do with which view is the first responder, and so is 
 receiving a -print: action that has a nil target. Although that is how the 
 menu is wired by default, I rarely find it useful. I generally use a custom 
 method (one not implemented by any NSResponder class), so you can capture the 
 print request.
 
 What would be the minimum change to perform in order to get the view in the 
 right side of the split view to print itself in landscape (I would like to 
 offer landscape by default to the user) ? I am happy with the rest of the 
 print flow the way it is.
 
 IIRC, unless otherwise specified, all built-in printing methods will use 
 +[NSPrintInfo sharedPrintInfo] to determine page settings. You can customize 
 your own NSPrintInfo and call +setSharedPrintInfo:. Or you can create your 
 own printing session and pass the print info to it.
 
 P.S.: I saw the Laying Out Page Content section in Printing Programming 
 Guide, but I don't get how it is decided that the content of the view 
 exceeds the size of a single page. I would prefer my view to be told to fit 
 the selected page size (It is possible in my particular situation. I am 
 printing graphics that can be resized to any size, to any ratio).
 
 AFAIK, fit-to-page is not a Cocoa printing system feature. You will have to 
 do that yourself. In theory, the easiest way would be to determine the 
 scaling factor needed and set that in the NSPrintInfo. NSPrintInfo will tell 
 you the paper size and margins, from which you can determine the printable 
 area, then dividing that by the view frame or bounds.
 
 HTH,
 
 Keary Suska
 Esoteritech, Inc.
 Demystifying technology for your home or business
 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Printing a view + landscape printing

2013-01-22 Thread Jean Suisse
On 22 janv. 2013, at 10:29, Graham Cox wrote:

 On 22/01/2013, at 7:50 PM, Jean Suisse wrote:
 
 Thank you very much for your reply.
 I can now print the right view. This view (Parent View) has only two large 
 custom subviews in which I display graphics.
 
 AFAIK, fit-to-page is not a Cocoa printing system feature.
 
 It is.

Indeed it is. 
Thank you so much for this valuable piece of information.
Here's the code that made it work:

NSPrintInfo* sharedPrintInfo = [NSPrintInfo sharedPrintInfo];
[sharedPrintInfo setHorizontalPagination:NSFitPagination];
[sharedPrintInfo setVerticalPagination:NSFitPagination];
[sharedPrintInfo setOrientation:NSLandscapeOrientation];

Now, the result fits one page, in landscape mode. However, the aspect/ratio of 
the view remains the same as displayed on screen.
How can I change the size (bounds) of the view and its subview but for printing 
only ? I could stretch the result, but the text on the graphics would appear 
stretched. ..
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to avoid warning?

2013-01-22 Thread Jean Suisse

 myObj = [[myClass alloc] performSelector(@selector(initWithManager:) 
 withObject:self];
 
 Would this work?
 


You could do :

id myObj =[myClass alloc];
myObj = [myObj performSelector(@selector(initWithManager:) withObject:myObj];
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to avoid warning?

2013-01-22 Thread Jean Suisse

On 22 janv. 2013, at 18:34, Jean Suisse jean.li...@gmail.com wrote:

 
 myObj = [[myClass alloc] performSelector(@selector(initWithManager:) 
 withObject:self];
 
 Would this work?
 
 
 
 You could do :
 
 id myObj =[myClass alloc];
 myObj = [myObj performSelector(@selector(initWithManager:) 
 withObject:myObj];


[Sorry, I did hit send by mistake]

This (above) implies that the manager is self. Not that myObj is used as self 
when calling init.

Or you could declare a protocol myProtocol that defines initWithManager: and 
have the following declaration for myObj:
id myProtocol myObj = …
This would avoid the use of @selector.
You could also test if myObj responds to the selector selector just after 
calling alloc.

Jean

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Best guess at expressing a string as a variable

2013-01-22 Thread Jean Suisse
On 23 janv. 2013, at 00:28, jonat...@mugginsoft.com jonat...@mugginsoft.com 
wrote:


 I have a generic descriptive title of a parameter and want to express it as a 
 variable name within a script.
 
 So if my title is No more awesome today, please! I will likely render this 
 as no-more-awesome-today-please ( I can define the separator style).
 
 I am targeting about 20 or so scripting languages so the range of what each 
 will deem is a valid variable name is rather wide.
 However I would like to deliver a reasonable default rendering.
 
 Dealing with English seems not too troublesome but titles composed in other 
 languages might be a different matter.

Do you want to deal with other languages ? For instance Japanese, Chinese, 
Korean, Arabic, etc. ?
 
 My current thinking is, regardless of the language, is to exclude all 
 characters that are not members of NSCharacterSet + (id)letterCharacterSet.
 
 Is  + (id)letterCharacterSet the best choice here?

I don't know. Does it include characters in すごくやる気がある ?
I can only guess what your goal is. But can't you associate some unique 
variable name to strings you can't translate (for instance the hex 
representation of the bytes in the UTF8 string) ?

Jean





---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Printing a view + landscape printing

2013-01-21 Thread Jean Suisse
Dear All,

I have a non-document based application to which I would like to add printing 
support.
The main window (the one in the .xib created by default by Xcode) contains a 
split view.

Currently, when printing, I get only the left pane of the split view (at best) 
or the control that has the focus (a textfield for instance) at worse.
What would be the minimum change to perform in order to get the view in the 
right side of the split view to print itself in landscape (I would like to 
offer landscape by default to the user) ? I am happy with the rest of the print 
flow the way it is.
Any pointers ?

Thanks,
Jean

P.S.: I saw the Laying Out Page Content section in Printing Programming Guide, 
but I don't get how it is decided that the content of the view exceeds the size 
of a single page. I would prefer my view to be told to fit the selected page 
size (It is possible in my particular situation. I am printing graphics that 
can be resized to any size, to any ratio).

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Printing a view + landscape printing

2013-01-21 Thread Jean Suisse
Answering a part of my question: 

The menu item for printing needs to be re-wired to target the app delegate 
rather than the first responder.
Now, I need to fix the page orientation and determine the size in points for 
the rendering. Any ideas ?



On 21 janv. 2013, at 16:17, Jean Suisse jean.li...@gmail.com wrote:

 Dear All,
 
 I have a non-document based application to which I would like to add printing 
 support.
 The main window (the one in the .xib created by default by Xcode) contains a 
 split view.
 
 Currently, when printing, I get only the left pane of the split view (at 
 best) or the control that has the focus (a textfield for instance) at worse.
 What would be the minimum change to perform in order to get the view in the 
 right side of the split view to print itself in landscape (I would like to 
 offer landscape by default to the user) ? I am happy with the rest of the 
 print flow the way it is.
 Any pointers ?
 
 Thanks,
 Jean
 
 P.S.: I saw the Laying Out Page Content section in Printing Programming 
 Guide, but I don't get how it is decided that the content of the view exceeds 
 the size of a single page. I would prefer my view to be told to fit the 
 selected page size (It is possible in my particular situation. I am printing 
 graphics that can be resized to any size, to any ratio).
 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Floating-point differences between ARM processors

2013-01-07 Thread Jean Suisse

On 8 janv. 2013, at 00:24, Rick Mann wrote:

 
 On Jan 7, 2013, at 11:22 , Greg Parker wrote:
 
 Note also that physics simulations will always need to be careful with the 
 error inherent to finite precision floating-point arithmetic. IEEE 
 specification of exact results for every operation wouldn't solve that.

This is a key point that shouldn't be forgotten.

 We don't care so much about correct results as we do repeatable results. When 
 you write a multiplayer Game Center game, you have to pass around initial 
 conditions and expect the simulation to run deterministically across 
 platforms.


That wasn't clear (at least for me) in your original message. It is also a key 
point. In that case, you indeed don't need accuracy. Why not go for one of 
Vincent Habchi's solutions then ? That could give you more control over the 
results.

Jean


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Custom initWithFrame?

2013-01-03 Thread Jean Suisse
On 4 janv. 2013, at 02:28, Eric Dolecki wrote:
 I am creating a UIView-based control that I would also like to pass in 
 parameters at the time of creation. Is this doable? I don't want to keep 
 calling methods on my object if I can pass all with initwithframe somehow.
 
 Thanks,
 Eric

Eric, maybe you could use :

- (id)initWithFrame:(NSRect)frame andOtherObject:(someClass*)myOtherObject
{
self = [super initWithFrame:frame];
if (self)
{   
[self setOtherObject:myOtherObject];
}   

return self;
}

Best regards,
Jean






---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302





___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: blocks and id

2012-12-12 Thread Jean Suisse
On 12 déc. 2012, at 13:02, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 Why does your code care if some unknown object is a block? This is a strong 
 sign of a bad design.


As far as I am concerned, I can think of at least two or three legitimate 
reasons to care wether an unidentified object is a block or not.
But you seem pretty certain. So you must have had more informations than the 
rest of us 
– sorry, just thinking out loud.

To actually answer the question, I fear that not much can be done.
Personally, I would go for Andreas' current solution and if the app is 
commercial, I would make sure to test  fix it before each public MAC OS 
release, so that users can upgrade the app before upgrading the system (and 
also check the OS version at each launch to detect if they didn't upgrade).

Otherwise, maybe this could work depending on the situation:
-(whatever)processSomething:(id)something 
andKeepInMindThatsABlock:(BOOL)isBlock;

Jean







___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to implement readonly property

2012-12-08 Thread Jean Suisse
Speaking of Double-Checked Locking, there is this interesting article from 
Scott Meyers and Andrei Alexandrescu, written in 2004, which states: 
This article explains why Singleton isn’t thread safe, how DCLP attempts to 
address that problem, why DCLP may fail on both uni- and multiprocessor 
ar-chitectures, and why you can’t (portably) do anything about it. Along the 
way, it clarifies the relationships among statement ordering in source code, 
sequence points, compiler and hardware optimizations, and the actual order of 
statement execution. Finally, it concludes with some suggestions regarding how 
to add thread-safety to Singleton (and similar constructs) such that the 
resulting code is both reliable and efficient.

DCLP = Double-Checked Locking Pattern
Link: http://erdani.com/publications/DDJ_Jul_Aug_2004_revised.pdf

Jean






---
Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 413
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX












___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Associate icon with file ext. / quick look

2012-10-22 Thread Jean Suisse
Thank you very much for this very clear explanation.
I will look for the APIS to perform #1 and #2.

Best regards,
Jean

On 18 oct. 2012, at 20:29, Seth Willits wrote:

 On Oct 18, 2012, at 4:04 AM, Jean Suisse wrote:
 
 Thank you for your reply. I am not familiar with the topic, but if I 
 understand you correctly, what you say implies that :
 
 1. The icon for the file type must be the same than the icon for the app.
 2. If my app generates three files of different types for each record (e.g.: 
 a setup file containing parameters, a raw acquired data file, a signature 
 file), I can't have three different icons, one for each file
 
 No, not at all.
 
 
 A dozen different applications may be able to open and edit a certain file 
 type, but only *one* application on the system is designated as the default 
 handler for that file type. (It owns the file type in my prior lingo.) This 
 is the application that will launch and open the file if you double-click it 
 in Finder.
 
 *That* application is the one responsible for supplying the icon for the file 
 type, not the application which created the file. In other words Acrobat and 
 Preview can both open and save pdf files, but Preview is the default handler 
 for pdf files on my system, so the system will show pdf files using 
 Previews's pdf file icon, even if I create a pdf file inside of Acrobat. If I 
 set Acrobat as the default handler, all pdf files would display using 
 Acrobat's pdf icon.
 
 However, there are exceptions to this.
   
   1) You (or an application) can set a file to open with an application 
 other than the default handler for its file type, so it would not use the 
 default handling application's icon for that file type.
 
   2) You (or an application) can set a custom file icon on a file, even 
 if it isn't the default handling application. So while Preview may be the 
 default handler for pdfs on my system, Acrobat could set a custom icon on the 
 file. When I double-click on it, it may still open in Preview, though unless 
 Acrobat did #1 and overrides the default to claim ownership for that 
 *specific* file.
 
 
 
 So what I am saying is if your Creator application is creating .jean 
 files, but the Viewer application is the one set to be the default handler 
 for .jean files when they're double-clicked in Finder, then Finder will 
 display .jean files using the icon for the .jean file type that Viewer has in 
 its bundle. Creator's icon for .jean files will not be used. 
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Associate icon with file ext. / quick look

2012-10-22 Thread Jean Suisse
Thank you for your reply. I will try that.
Jean


On 22 oct. 2012, at 18:21, Mike Abdullah wrote:

 
 On 22 Oct 2012, at 16:54, Sean McBride wrote:
 
 On Wed, 17 Oct 2012 13:38:45 +0200, Jean Suisse said:
 
 My scientific cocoa app (10.6-10.8) records acquired data from devices
 and store them in human-readable UTF8 text files that have specific
 extensions (different from .txt). I have two questions related to file
 extensions, default application, icons and preview in quick look to
 submit to your expertise.
 
 The app that collects and stores the data is not the same as the one
 that is used to view the data (third-party text editor).
 I have found how to tell launch services to open the files with the
 third-party text editor, but I can't find how to associate the icon of
 my app with all the files extensions I use. How can I do that using
 cocoa or a shell script ? – this is my first question.
 
 Secondly, how can I tell quick look to preview the-said files just like
 it would any other text file ?
 
 Jean,
 
 From the sounds of it, it might be best if you just use .txt for your 
 human readable text files.  QuickLook will then generate previews, and the 
 user's preferred text editor will open the file when double clicked.
 
 I believe declaring your file format as conforming to public.plain-text will 
 automatically gain that ability too.


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Clear NSPanel View Shadow

2012-10-22 Thread Jean Suisse
Dear List,

I have an old transparent NSPanel, which shape is only defined by the painted 
portion of the views it contains.
The NSPanel has the following attributes set:

ExcludedFromWindowsMenu:NO
BackgroundColor: [NSColor clearColor]
AlphaValue:1.0
HasShadow:YES
useOptimizedDrawing:YES
Opaque:NO

Recently, I felt the need to show/hide one of the view in the panel using 
[theView animator] setAlphaValue: xxx];

The issue:
If the NSPanel opens with theView visible, when hiding it, theView's shadow 
remains.
If the NSPanel opens with theView hidden, when displaying theView, theView 
doesn't get a shadow.

It seems that  the shadow for the panel is only computed when first displayed. 
I tried various options, but I must be missing something.

Best regards
Jean
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Clear NSPanel View Shadow

2012-10-22 Thread Jean Suisse
Thank you very much for your reply.
Indeed, calling invalidateShadow did the trick. Now I need to find a way to be 
notified when [[view animator] dosomething] completes, otherwise the shadow 
takes the shape of the window before the transformation.

Cheers,
Jean


On 22 oct. 2012, at 22:06, Ken Thomases k...@codeweavers.com wrote:

 On Oct 22, 2012, at 2:07 PM, Jean Suisse wrote:
 
 The issue:
 If the NSPanel opens with theView visible, when hiding it, theView's shadow 
 remains.
 If the NSPanel opens with theView hidden, when displaying theView, theView 
 doesn't get a shadow.
 
 It seems that  the shadow for the panel is only computed when first 
 displayed. I tried various options, but I must be missing something.
 
 You're looking for -[NSWindow invalidateShadow].
 
 Cheers,
 Ken
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Clear NSPanel View Shadow

2012-10-22 Thread Jean Suisse


On 22 oct. 2012, at 22:32, Jean Suisse jean.li...@gmail.com wrote:

 Thank you very much for your reply.
 Indeed, calling invalidateShadow did the trick. Now I need to find a way to 
 be notified when [[view animator] dosomething] completes, otherwise the 
 shadow takes the shape of the window before the transformation.

Which I found here: 
http://stackoverflow.com/questions/12240870/cocoa-run-block-after-animation-on-osx

 
 Cheers,
 Jean
 
 
 On 22 oct. 2012, at 22:06, Ken Thomases k...@codeweavers.com wrote:
 
 On Oct 22, 2012, at 2:07 PM, Jean Suisse wrote:
 
 The issue:
 If the NSPanel opens with theView visible, when hiding it, theView's shadow 
 remains.
 If the NSPanel opens with theView hidden, when displaying theView, theView 
 doesn't get a shadow.
 
 It seems that  the shadow for the panel is only computed when first 
 displayed. I tried various options, but I must be missing something.
 
 You're looking for -[NSWindow invalidateShadow].
 
 Cheers,
 Ken
 
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Associate icon with file ext. / quick look

2012-10-17 Thread Jean Suisse
Greetings, fellow developers on the lists,

My scientific cocoa app (10.6-10.8) records acquired data from devices and 
store them in human-readable UTF8 text files that have specific extensions 
(different from .txt). I have two questions related to file extensions, default 
application, icons and preview in quick look to submit to your expertise.

The app that collects and stores the data is not the same as the one that is 
used to view the data (third-party text editor).
I have found how to tell launch services to open the files with the third-party 
text editor, but I can't find how to associate the icon of my app with all the 
files extensions I use. How can I do that using cocoa or a shell script ? – 
this is my first question.

Secondly, how can I tell quick look to preview the-said files just like it 
would any other text file ?

Best regards,
Jean



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Dynamic Method Creation

2012-09-15 Thread Jean Suisse
Hi Steve,

There seem to be a pattern in you methods: they all contain the name of a day 
of the week (monday) and you want them for all days. Then you could use macros.

Example :

#define SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)  
\
- (Shift *) dayName##CreateShift {  
\
return [self createShiftForDayOfWeekNamed:[[self class] 
dayName##Name]];\
}   
\

\
- (void) dayName##ClearShift {  
\
[self clearShiftForWeekdayNamed:[[self class] dayName##Name]];  
\
}   



Then, in your code, you will just need :
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(monday);
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(tuesday);
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(wednesday);

etc.

You will probably want two sets of macro :
DECLARE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)


Cheers,
Jean

On 15 sept. 2012, at 07:49, Steve Steinitz wrote:

 Hi Ken,
 
 Thanks for your quick reply.
 
 On 15 Sep 12, at 3:16pm, Ken Thomases wrote:
 
 No offense, but this seems like a terrible design.  And your KVO hack method 
 screams of papering over a bug.
 
 No offense but none of your criticisms seem to hold water.  I might address 
 them individually after I see if anyone can offer any help with my actual 
 question, rather than cluttering the thread now.
 
 Cheers,
 
 Steve

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Dynamic Method Creation

2012-09-15 Thread Jean Suisse
Yes it is that simple ! 
I have been using it to synthesize a whole set of hardware interaction methods 
following a pattern. The more methods you have, the more time you save.  Also, 
you can modify the whole code just by editing it in one place.
Some (like Matt Gallagher and his SYNTHESIZE_SINGLETON macro) have even been 
using this technique to synthesize whole class and their methods.

There are a few drawbacks thought. It's best to thoroughly test synthesized 
methods. Because they are harder to debug.
Since the code is located in a macro, you don't have syntax coloring, and 
sometimes, autocompletion may not work.

Cheers,
Jean


On 15 sept. 2012, at 11:11, Steve Steinitz wrote:

 Hi Jean,
 
 On 15 Sep 12, at 6:12pm, Jean Suisse wrote:
 
 There seem to be a pattern in you methods: they all contain the name of a 
 day of the week (monday) and you want them for all days.
 
 Yes, that was intentional, just for this purpose :)
 
 Then you could use macros.
 
 Example :
 
 #define SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)   
 \
 - (Shift *) dayName##CreateShift {   return [self 
 createShiftForDayOfWeekNamed:[[self class] dayName##Name]];} 
   
 - (void) dayName##ClearShift {[self clearShiftForWeekdayNamed:[[self class] 
 dayName##Name]];}
 
 Then, in your code, you will just need :
 SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(monday);
 SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(tuesday);
 etc.
 
 Wow! Is it really that simple?  Thank you Jean, you have saved the day.
 
 You will probably want two sets of macro :
 DECLARE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
 SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
 
 Right, one for the .h and one for the .m.  Good point.
 
 Thanks again, Jean.
 
 All the best,
 
 Steve
 


Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: maintaining alpha value for intersecting lines?

2012-09-13 Thread Jean Suisse
It is the expected behavior, since the stacking of two partially transparent 
objects leads to a less transparent set. 
So I don't know what you want is possible.
Are your lines straight ? If so, maybe you could try to draw one of them in two 
segments, to avoid the intersection (beware of the anti-aliasing).

- Jean

On 13 sept. 2012, at 14:40, Koen van der Drift wrote:

 When I draw two lines using NSBezierPaths, both of which have an alpha
 value of let's say 0.5, the alpha value appears to be higher at the
 intersection (the color becomes more opaque). Is there a way to
 maintain the original alpha value for lines that intersect?
 
 - Koen.


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: maintaining alpha value for intersecting lines?

2012-09-13 Thread Jean Suisse
I'm afraid it won't work. 
That's the principle of transparency: you can see what's below, tinted by the 
color of what's on top.
What are you trying to do ? Maybe there's an other way around.

On 13 sept. 2012, at 14:59, Koen van der Drift wrote:

 That would be too bad. But maybe I can use one of the
 NSCompositingOperation constants, I just read about that.
 
 https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html#//apple_ref/c/tdef/NSCompositingOperation
 
 I'll try that later.
 
 - Koen.
 
 On Thu, Sep 13, 2012 at 8:51 AM, Jean Suisse jean.li...@gmail.com wrote:
 It is the expected behavior, since the stacking of two partially transparent 
 objects leads to a less transparent set.
 So I don't know what you want is possible.
 Are your lines straight ? If so, maybe you could try to draw one of them in 
 two segments, to avoid the intersection (beware of the anti-aliasing).
 
 - Jean
 
 On 13 sept. 2012, at 14:40, Koen van der Drift wrote:
 
 When I draw two lines using NSBezierPaths, both of which have an alpha
 value of let's say 0.5, the alpha value appears to be higher at the
 intersection (the color becomes more opaque). Is there a way to
 maintain the original alpha value for lines that intersect?
 
 - Koen.
 

Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: View based outline view and custom NSTableCellViews

2012-09-07 Thread Jean Suisse
Hi,

Thank you for your reply.
Yes, I have been thinking for a long time that I should take a really good look 
to bindings. I should invest some time in it.
Thank you for your help.

Cheers, 
Jean


On 7 sept. 2012, at 11:00, Uli Kusterer wrote:

 Jean,
 
 I think your problem isn't the table, but that you're mixing up bindings and 
 outlets. To connect an outlet, simply Control-Drag and hook it up. Use the 
 little icons at the top of the inspector pane to switch to Connections 
 Inspector, which shows the list of all outlets, actions, bindings etc. and 
 see it worked.
 
 They're all connections, but the stuff in the Bindings Inspector that you are 
 describing is not for IBOutlets. Outlets are specific object properties that 
 point to objects in your XIB. Bindings are relationships that pass values 
 between an object in your XIB and a (pretty much arbitrary) property of the 
 object you bind to.
 
 Now the object you bind to *can* be another object in your XIB, but it can 
 also be the application, or the user defaults singleton, or an object 
 referenced by one of the objects in your XIB (like the current selected 
 object in your table view).
 
 I know this stuff is similar, you'll just have to learn more about these two 
 things to know how to tell them apart.
 
 Cheers,
 -- Uli Kusterer
 The Witnesses of TeachText are everywhere...
 http://www.masters-of-the-void.com
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


View based outline view and custom NSTableCellViews

2012-09-06 Thread Jean Suisse
Hello,

In the content view of the window of a freshly created NIB, I have a view-based 
outline view. The file owner is set to be MyWindowController. The outlineView 
is the standard, preconfigured setup, dragged from IB.
Now, I would like to modify the default views provided in this standard 
setup, to integrate my custom controls. And I am stuck on the part where, at 
runtime, I access those custom controls to make them display the appropriate 
information.

If I add, for instance, an NSTextField label to the dataView, how do I access 
it at runtime to change its value ? I know where I should do that. But I can't 
do it because of the lack of outlet.
Instinctively, I would create a subclass of NSTableCellView (MyTableCellView), 
set the NSTableCellView to be MyTableCellView in IB and connect all the outlets 
to be able to do this at runtime : [MyTableCellView.MyExtraTextField 
setXXXValue: …];

But IB is not letting me do that. What did I miss ? They do that in the example 
provided by apple.

Best regards, 
Jean


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Jean Suisse
Hi,

Fritz Anderson is right. We can only agree. 
And recently, they made following Jens Alfke's advice incredibly easy. 
Just post a block to one of the available dispatch queues (not the one running 
on your main thread thought) and let it run its curse. 

Jean

On 6 sept. 2012, at 16:36, Fritz Anderson wrote:

 From what Google tells me, you got a prompt response from Jens Alfke, a very 
 experienced Cocoa-networking programmer, explaining why what you're doing 
 shouldn't be expected to work. Are you looking for a workaround, or just for 
 somebody who will give you better news? I don't think better news is in the 
 cards.


On 29 août 2012, at 22:58, Jens Alfke wrote:

 If you must use a synchronous API, spawn a new thread to run it on.
 




___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: View based outline view and custom NSTableCellViews

2012-09-06 Thread Jean Suisse
To add a few more informations:

If I manually write the outlet declaration in MyTableCellView.h 
(@property(weak) NSTextField* myTextField); and if I add the @synthesize method 
in the .m file, this time, IB is letting me do the connection.
However, IB is presenting me with a window I am not familiar with [1], 
requesting additional informations, related to bindings. So far, I haven't been 
able to make it work.

Jean

[1] such as Bind (set to DisplayPattern Value1), controller (set to My table 
cell view, the name of the view in IB), the name of the custom class (set to 
MyTableCellView), the keypath (set by default to objectvalue, the key should be 
here), the model object, set to MyTableCellView, an other keypath, set to 
MyTextField.


On 6 sept. 2012, at 20:34, Jean Suisse wrote:

 Thank you for your reply.
 
 Elaborate on not letting me do that.
 
 That is Ctrl + drag from the textfield I added in the TableCellView (declared 
 to ID as MyTableCellView) towards the header file MyTableCellView.h (to 
 declare the property + declare the outlet in one shot).
 Also, if I create them manually, IB is refusing to do the connection.
 
 
 Jean
 
 
 On 6 sept. 2012, at 19:11, Seth Willits wrote:
 
 
 On Sep 6, 2012, at 7:46 AM, Jean Suisse wrote:
 
 Instinctively, I would create a subclass of NSTableCellView 
 (MyTableCellView), set the NSTableCellView to be MyTableCellView in IB and 
 connect all the outlets to be able to do this at runtime : 
 [MyTableCellView.MyExtraTextField setXXXValue: …];
 
 That's exactly what you do. 
 
 
 But IB is not letting me do that. What did I miss ? They do that in the 
 example provided by apple.
 
 
 I suspect you're grabbing the wrong thing in IB, or IB doesn't know about 
 your cell view subclass etc. The usual things. It's like any other custom 
 class stuff in IB, so there aren't any hidden tricks involved.
 
 Elaborate on not letting me do that.
 
 
 --
 Seth Willits
 
 
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSData DataWithContentsOfURL within a protocol handler

2012-09-06 Thread Jean Suisse
Yes, I meant GCD. Sorry I missed the part where you told us about supporting 
10.5 in your original message.


On 6 sept. 2012, at 20:55, Dan S wrote:

 if you meant using the grand central dispatch, i think that only became 
 available in 10.6, I need to support this for 10.5
  
 On Thu, Sep 6, 2012 at 11:25 AM, Dan S danc...@rebelbase.com wrote:
 No, actually I've completely missed that it was answered.  Thank you. 
  
 Unfortunatelly, the requester is expecting a return data, error or a 
 redirect. And until the api can be respeced, the sync response has to stay 
 in.  It isn't that it needs to load from network every request, but some 
 volotile data does have to check the server to pull down the changes before 
 serving the data.
  
 I will try to offload the server access to a different thread (though I still 
 need to block the protocol thread because I still have to return the correct 
 data for the current call).
  
 but now I'm also curiouse of what you mewant by posting a block to another 
 dispatch queue ?
  

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Catching app-wide (system-wide) modifier keypress

2012-08-21 Thread Jean Suisse
Hello,

In short :
Is there a way to be notified of any change in the status of control keys 
(option, control, command, etc.) in a given NSWindowController, when another 
window of the app has the focus ?

Long version (what I am trying to achieve) : 
The app I am currently working on is a multipurpose data acquisition software 
for scientists.
To make it simple, let's say the app has two windows. One main window in which 
tasks are created and configured, one small HUD-window in which the user can 
see all created and scheduled tasks (pending execution).

On the HUD window, tasks can be altered (started, stopped, removed, etc…) by 
means of appropriate buttons and pressing the option key while clicking on one 
of these buttons can modify the action (e.g. pressing option while clicking on 
the cancel will cancel all tasks instead of only the current task).

Currently, I am using 

-(void)flagsChanged:(NSEvent *)theEvent

in the NSWindowController to display the appropriate text/image on the button 
(so that the user knows which action will be executed upon hitting the button).

The issue :
When the main window of the application (or any other window but the HUD panel) 
has the focus, hitting the option key will not change the text on the panel 
button, since the panel will never get the event. However, clicking on one of 
the panel button will activate the panel and execute the right action 
(depending on the status of the option key). In this particular situation, the 
text/image displayed on the button does not match the executed action.

Question:
How can I  catch app-wide flagsChanged events to always have my buttons display 
the appropriate text / image ?


Best regards,
Jean


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Focus issues with NSTableView in NSPanel

2012-08-21 Thread Jean Suisse
Hello,

I have an NSPanel window that contains an NSTableView with the usual setup 
(NSPanel - content view (NSView) - NSScrollView - NSTableView - etc).
When the Panel does not have the focus, clicking on an item of the table view 
will first activate the panel. Then a second click will be required to select 
the item. This two-click selection is inconvenient.

I have tried to answer yes to acceptsFirstMouse in the content view, the scroll 
view, and the table view without success. Anyone knows how to deal with this ?

Best regards,
Jean

Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX

T: +333-8039-9037 
F: +339-7223-9232
E: jean.sui...@u-bourgogne.fr

http://www.icmub.fr/185-JEAN-SUISSE_?id=331





___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Focus issues with NSTableView in NSPanel

2012-08-21 Thread Jean Suisse
Well, apparently Glen Low did post a similar question, back in 2007.
http://lists.apple.com/archives/cocoa-dev/2007/Jun/msg00897.html

Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX

T: +333-8039-9037 
F: +339-7223-9232
E: jean.sui...@u-bourgogne.fr

http://www.icmub.fr/185-JEAN-SUISSE_?id=331





On 21 août 2012, at 14:48, Jean Suisse wrote:

 Hello,
 
 I have an NSPanel window that contains an NSTableView with the usual setup 
 (NSPanel - content view (NSView) - NSScrollView - NSTableView - etc).
 When the Panel does not have the focus, clicking on an item of the table view 
 will first activate the panel. Then a second click will be required to select 
 the item. This two-click selection is inconvenient.
 
 I have tried to answer yes to acceptsFirstMouse in the content view, the 
 scroll view, and the table view without success. Anyone knows how to deal 
 with this ?
 
 Best regards,
 Jean
 
 Jean Suisse
 Institut de Chimie Moléculaire de l’Université de Bourgogne
 (ICMUB) — UMR 6302
 
 U.F.R. Sciences et Techniques, Bâtiment Mirande
 Aile B, bureau 411
 9, avenue Alain Savary — B.P. 47870
 21078 DIJON CEDEX
 
 T: +333-8039-9037 
 F: +339-7223-9232
 E: jean.sui...@u-bourgogne.fr
 
 http://www.icmub.fr/185-JEAN-SUISSE_?id=331
 
 
 
 
 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Focus issues with NSTableView in NSPanel

2012-08-21 Thread Jean Suisse
That's perfect. Thank you very much. I have been dragging this inconvenience in 
my app for a long time now…

Jean


On 21 août 2012, at 17:43, Corbin Dunn wrote:

 Override:
 
 - (BOOL)needsPanelToBecomeKey 
 
 and return NO. If you think about it...that is conceptually what you want. 
 Also, the window could return YES from becomesKeyOnlyIfNeeded, and it should 
 also work.
 
 -corbin
 
 
 
 On Aug 21, 2012, at 5:48 AM, Jean Suisse jean.li...@gmail.com wrote:
 
 Hello,
 
 I have an NSPanel window that contains an NSTableView with the usual setup 
 (NSPanel - content view (NSView) - NSScrollView - NSTableView - etc).
 When the Panel does not have the focus, clicking on an item of the table 
 view will first activate the panel. Then a second click will be required to 
 select the item. This two-click selection is inconvenient.
 
 I have tried to answer yes to acceptsFirstMouse in the content view, the 
 scroll view, and the table view without success. Anyone knows how to deal 
 with this ?
 
 Best regards,
 Jean
 
 Jean Suisse
 Institut de Chimie Moléculaire de l’Université de Bourgogne
 (ICMUB) — UMR 6302
 
 U.F.R. Sciences et Techniques, Bâtiment Mirande
 Aile B, bureau 411
 9, avenue Alain Savary — B.P. 47870
 21078 DIJON CEDEX
 
 T: +333-8039-9037 
 F: +339-7223-9232
 E: jean.sui...@u-bourgogne.fr
 
 http://www.icmub.fr/185-JEAN-SUISSE_?id=331
 
 
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/corbind%40apple.com
 
 This email sent to corb...@apple.com
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Focus issues with NSTableView in NSPanel

2012-08-21 Thread Jean Suisse
Well, then you just need to override:

- (BOOL)needsPanelToBecomeKey 

in the NSTableView (subclass) and return NO. 

More info here :
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsview_Class/Reference/NSView.html

This should do the trick. (It worked for me)

Cheers
Jean


Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX

T: +333-8039-9037 
F: +339-7223-9232
E: jean.sui...@u-bourgogne.fr

http://www.icmub.fr/185-JEAN-SUISSE_?id=331





On 21 août 2012, at 18:02, Kyle Sluder wrote:

 On Aug 21, 2012, at 8:43 AM, Corbin Dunn corb...@apple.com wrote:
 
 Override:
 
 - (BOOL)needsPanelToBecomeKey 
 
 and return NO. If you think about it...that is conceptually what you want. 
 Also, the window could return YES from becomesKeyOnlyIfNeeded, and it should 
 also work.
 
 I don't know what Jean Suisse needs, but we've been trying to achieve a very 
 similar goal: clicking on a table view in a non-key window should cause the 
 selection to change *and* should cause that window to become key (with the 
 table view as first responder).
 
 Yes, we understand this is a departure from standard behavior. But this is 
 the behavior we desire. (The table view lives in an inspector window and 
 shows a fair bit of data, and users expect to be able to navigate it with the 
 keyboard.)
 
 Unfortunately, the only thing we've done that seems to work is to override 
 -acceptsFirstMouse: to call [self.window makeKeyAndOrderFront:] before 
 returning YES. This feels incredibly hacky. Is there no other way?
 
 --Kyle Sluder

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How make iPhone HOT (yes, increase the temperature)??

2012-08-10 Thread Jean Suisse
Hi Rodrigo,

For some reasons [1], getting an iPhone hot is trickier than it looks and 
engineers have worked hard to make this device's operation as energy-efficient 
as possible.

The only way to make an iPhone heat itself, when not connected to a power 
source, is by draining its battery power as fast as you can in the most 
inefficient way possible. The quicker you drain the battery, the less efficient 
you use that energy, the hotter the device gets (users may not thank you for 
that).

And then you hit this little snag where you can't really control efficiency. 
Apple engineers made sure iPhones would dissipate as little heat as possible 
for their operation in order to maximize battery life.
So, you're left with controlling the power: the rate at which you spend (drain) 
the device's battery energy.

As you mentioned before, getting the iPhone hot can be achieved by transmitting 
data over the phone network (3G) or as Alex Zavatone pointed out, you can load 
the cores (code for such task should be available in some open source tools for 
linux, achieving this goal on x86 processors).

But, that's it. You don't have a lot of flexibility and depending on your 
specifications it may not be enough (you can't drain the battery in a snap).

To give you a more accurate idea of what you can get:
An iPhone 4s fully charged stores approximately 19 kJ of power (1.432 Ah; 3.7 
V). Using 60% of this energy (from 80 % charge down to 20 %) you get roughly 
11.5 kJ.
That's the energy required to heat 270 mL of water up by 10 °C (10 °K; 18 °F). 
And that's only if you proceed really quickly and you get 100 % of your energy 
in the form of heat (which you won't). 
Real-world result *will* be worse (The water is not the only thing you heat, 
you also need to heat the phone. And both are passively cooled down by their 
environment, so you have to act fast, which is not possible = power control…). 
It may not even be enough to really heat your hands in cold winter (let me 
know). Moreover nice chemical devices are commercially available that nicely do 
the job without killing your mobile's battery life.

This is just an order of magnitude assessment. An apple engineer would have 
more data to help. Or you can look on the internet. Maybe keywords such as 
Joule power iPhone could do the trick. 
With all the tear-downs going on for each iPhone launch I wouldn't be surprised 
to find some informations on this topic…

Cheers,
Jean

[1]
Usually, heat  is viewed as an energy wasteful side-effect of electronic 
devices operation plaguing the industry.
Heat is especially bad for mobile devices with limited power supply since it 
further the reduces the amount of energy actually available for their operation 
and drains their batteries.



Jean Suisse
Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX

T: +333-8039-9037 
F: +339-7223-9232
E: jean.sui...@u-bourgogne.fr

http://www.icmub.fr/185-JEAN-SUISSE_?id=331





On 8 août 2012, at 21:58, Rodrigo Zanatta Silva wrote:

 Hi. I am thinking to do a funny program that make the iPhone to be HOT. I
 intensionally want the device increase your temperature.
 
 Using the iPhone, I knot it will be hot if I use the 3G Internet.
 Programing, I can try the program continually transfer files.
 
 What other strategy I can use to do this? Any idea?
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Equation style display

2012-07-04 Thread Jean Suisse
Dave, Chris,

Thank you so much for your reply. I did check the library at 
https://github.com/davedelong/DDMathParser/. It incredibly nice. I am grateful 
to Dave for developing  sharing it.
Il will now investigate the parsing + mathML conversion combined with rendering 
possibility.

Thanks all for helping me to go forward with my project.
Jean

On 2 juil. 2012, at 21:01, Chris Hanson wrote:

 Mathematical typesetting is actually incredibly complex, and people like 
 Donald Knuth have dedicated significant portions of their careers to it. 
 There's no simple way to go from a textual representation of a formula to a 
 typeset version, not least of which because there's no universally 
 agreed-upon textual representation or typeset version.
 
 I'd also recommend using a web view to display an equation, along with one of 
 the JavaScript TeX-to-HTML rendering packages. Stack Exchange uses one for 
 their Mathematics QA site that seems to work pretty well. However, note that 
 it's not instant.
 
   -- Chris
 
 On Jul 2, 2012, at 8:55 AM, Jean Suisse jean.li...@gmail.com wrote:
 
 Dear all,
 
 I was wondering if there is a way to get the pretty formatted version of 
 an equation (from an NSString) to display within a view (similar to the way 
 Graph.app displays it).
 The question is open, any means is acceptable (if not too far-fetched). 
 I know I can get a .png version using a call to a php script, but since MAC 
 OS already ships with softwares capable of doing it, maybe there is a more 
 elegant (and simple) way of implementing this feature.
 
 Any idea ?
 
 With my thanks,
 Jean
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/cmh%40me.com
 
 This email sent to c...@me.com

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Equation style display

2012-07-02 Thread Jean Suisse
Dear all,

I was wondering if there is a way to get the pretty formatted version of an 
equation (from an NSString) to display within a view (similar to the way 
Graph.app displays it).
The question is open, any means is acceptable (if not too far-fetched). 
I know I can get a .png version using a call to a php script, but since MAC OS 
already ships with softwares capable of doing it, maybe there is a more elegant 
(and simple) way of implementing this feature.

Any idea ?

With my thanks,
Jean



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Equation style display

2012-07-02 Thread Jean Suisse
Thank you for your reply.
Well, I don't know about the Attributed String. The idea is to get the pretty 
print of thing like 

(9/10) * sin( x/(2*t) )

without having to process the string myself.




On 2 juil. 2012, at 18:15, koko wrote:

 Would not NSAttributedString be of use?
 
 -koko
 
 On Jul 2, 2012, at 9:55 AM, Jean Suisse wrote:
 
 Dear all,
 
 I was wondering if there is a way to get the pretty formatted version of 
 an equation (from an NSString) to display within a view (similar to the way 
 Graph.app displays it).
 The question is open, any means is acceptable (if not too far-fetched). 
 I know I can get a .png version using a call to a php script, but since MAC 
 OS already ships with softwares capable of doing it, maybe there is a more 
 elegant (and simple) way of implementing this feature.
 
 Any idea ?
 
 With my thanks,
 Jean
 
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/koko%40highrolls.net
 
 This email sent to k...@highrolls.net
 
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Equation style display

2012-07-02 Thread Jean Suisse
Thank you for your reply. I will investigate this possibility. 
Does it take much space for the rendering ? I mean, I would like to display it 
inside a panel (something like a sheet, or an inspector).

The pretty print is just a feature that would allow the user to quickly spot 
any mistake in an equation.




On 2 juil. 2012, at 18:23, Jean-Daniel Dupas wrote:

 
 Le 2 juil. 2012 à 17:55, Jean Suisse a écrit :
 
 Dear all,
 
 I was wondering if there is a way to get the pretty formatted version of 
 an equation (from an NSString) to display within a view (similar to the way 
 Graph.app displays it).
 The question is open, any means is acceptable (if not too far-fetched). 
 I know I can get a .png version using a call to a php script, but since MAC 
 OS already ships with softwares capable of doing it, maybe there is a more 
 elegant (and simple) way of implementing this feature.
 
 Any idea ?
 
 
 Using MathML and a WebView ? 
 
 That said, I don't know what version of the WebKit (and so Mac OS) is 
 required to use MathML.
 
 There is some javascript/css library that let you display them properly if 
 MathML is not supported like http://www.mathjax.org
 
 With my thanks,
 Jean
 
 
 -- Jean-Daniel
 
 
 
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Equation style display

2012-07-02 Thread Jean Suisse
Well, it seems that all paths leads towards Webkit and MathML… which 
unfortunately requires some parsing / rewriting, even for simple equations…
Thank you Jens.

Best regards,
Jean


On 2 juil. 2012, at 18:45, Jens Alfke wrote:

 
 On Jul 2, 2012, at 8:55 AM, Jean Suisse wrote:
 
 
 I'm pretty certain there's nothing already installed to do that, unless maybe 
 WebKit has support for MathML?
 
 —Jens

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: DataSource modified while TableView is displaying data

2012-04-27 Thread Jean Suisse
So if I understand you correctly alteration of the dataSource should always be 
performed on the main thread.
[implied: because requests for redraw or similar that do not come from my code 
will always run on the main thread. Is that right ?].

Done. Not easy, but done. (Things were a little more complicated than just 
dispatching a block).

Now, for the sake of knowledge, I would like to consider the case where I can't 
always alter the datasource on the main thread. What then ?
I recall assembly instructions (STI, CLI) to prevent IRQ from occurring inside 
a few line of code. 
Is there some way to prevent thread switching for a short time ? Do you know an 
other way to deal with the present issue (alteration of the dataSource of an 
NSTableView not performed on the main thread) ?

Jean

On 26 avr. 2012, at 21:47, Corbin Dunn wrote:

 
 On Apr 26, 2012, at 3:23 AM, Jean Suisse jean.li...@gmail.com wrote:
 
 Dear Peter,
 
 Thank you for your reply. Here is the requested code (see below). 
 After more investigations, I would like to take back a previous statement, 
 that the tableview was perfectly aware that the number of rows in the DS was 
 changed. This is due to my inexperience in stepping through the code across 
 multiple threads.
 
 Here are the facts :
 
 - Only the controller removes rows from the datasource. Either in response 
 to user actions (canceling tasks) or as a result of a Task completed 
 notification from a running task.
 - Each change in the dataSource is immediately followed by a reloadData 
 message sent to the TableView.
 - Sometimes, randomly, the TableView requests a row index that is out of 
 bounds by one index (e.g. row #5 when the dataSource contains only 5 
 elements).
 
 I am thinking that a redraw occurs in-between the removal of one element of 
 the table and the reloadData message. 
 For now, I did a quick fix for this issue by adding a category with 
 safeObjectAtIndex…. But one way to be certain would be to ensure that the 
 two messages (removal + reloadData) are sent without any thread/process 
 switching occurring…
 
 The code for numberOfRowsInTableView : (experimentList is an instance of 
 NSMutableAray)
 
 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
 {
  return self.experimentList ? [self.experimentList count] : 0;
 }
 
 This is fine as long as your experimentList is only ever modified on the main 
 thread.
 
 It sounds like that isn't the case, which is why you have random problems.
 
 corbin
 
 
 
 Jean
 
 
 On 26 avr. 2012, at 11:45, Peter Hudson wrote:
 
 
 Can you post your code for numberOfRowsInTableView:
 
 Peter
 
 
 ___
 
 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:
 https://lists.apple.com/mailman/options/cocoa-dev/corbind%40apple.com
 
 This email sent to corb...@apple.com
 


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: DataSource modified while TableView is displaying data

2012-04-27 Thread Jean Suisse
Dear Roland,

Well, here is my pattern:

Dispatching the datasource modification / tableview reloadData code on the main 
thread. Waiting for it to be executed. And avoiding deadlocks by querying 
[NSThread isMainThread] and taking the appropriate action. This pattern works 
perfectly in my context, but requires more refinement if several threads have 
access to the controller.

Context: The controller is mostly called from a serial queue, sometimes called 
from the main thread.

Code [controller code]:

if ([NSThread isMainThread]) 
{
MODIFY DATASOURCE
RELOAD DATA
}
else
{
self.continueFlag = NO;
dispatch_async( dispatch_get_main_queue(), 
[[^{
MODIFY DATASOURCE
RELOAD DATA
   self.continueFlag = YES;
 } copy] autorelease]);
 __WAIT_FOR(self.continueFlag, 1000);   
}


REMARKS:
__WAIT_FOR is just a polling macro, wrapped around usleep(); periodically 
testing for a condition to become true before continuing (here: polling time = 
1000 µs).
The copy/autorelease may not be mandatory.

Jean

Institut de Chimie Moléculaire de l’Université de Bourgogne
(ICMUB) — UMR 6302

U.F.R. Sciences et Techniques, Bâtiment Mirande
Aile B, bureau 411
9, avenue Alain Savary — B.P. 47870
21078 DIJON CEDEX

T: +333-8039-9037 
F: +339-7223-9232
E: jean.sui...@u-bourgogne.fr

http://www.icmub.fr/185-JEAN-SUISSE_?id=331





On 27 avr. 2012, at 12:42, Roland King wrote:

 Not really no, not that I can think of, nothing simple at least. 
 
 That's one issue with Cocoa's drawing code being main-thread only and with 
 things like NSTableView being totally tightly bound to their datasource and 
 delegate and liable to call them at any time (drawing, scrolling, just 
 feeling like it), and calling more than one method in a sequence (not 
 synchronized across the entire method call), using them cross-thread is 
 tricky indeed. 
 
 I will be interested to see if there are some simple patterns people have 
 found to work, I haven't. In the one case I did this I batched my updates 
 into sets of adds, deletes and changes and then blocked (or at that time 
 performSelector'ed) them onto the main thread where they were applied to the 
 data model there. I can certainly see cases in which that's hard to do and 
 you want to adjust the data model on your thread and then just say redraw. 
 
 On Apr 27, 2012, at 3:42 PM, Jean Suisse wrote:
 
 So if I understand you correctly alteration of the dataSource should always 
 be performed on the main thread.
 [implied: because requests for redraw or similar that do not come from my 
 code will always run on the main thread. Is that right ?].
 
 Done. Not easy, but done. (Things were a little more complicated than just 
 dispatching a block).
 
 Now, for the sake of knowledge, I would like to consider the case where I 
 can't always alter the datasource on the main thread. What then ?
 I recall assembly instructions (STI, CLI) to prevent IRQ from occurring 
 inside a few line of code. 
 Is there some way to prevent thread switching for a short time ? Do you know 
 an other way to deal with the present issue (alteration of the dataSource of 
 an NSTableView not performed on the main thread) ?
 
 Jean
 
 On 26 avr. 2012, at 21:47, Corbin Dunn wrote:
 
 
 On Apr 26, 2012, at 3:23 AM, Jean Suisse jean.li...@gmail.com wrote:
 
 Dear Peter,
 
 Thank you for your reply. Here is the requested code (see below). 
 After more investigations, I would like to take back a previous statement, 
 that the tableview was perfectly aware that the number of rows in the DS 
 was changed. This is due to my inexperience in stepping through the code 
 across multiple threads.
 
 Here are the facts :
 
 - Only the controller removes rows from the datasource. Either in response 
 to user actions (canceling tasks) or as a result of a Task completed 
 notification from a running task.
 - Each change in the dataSource is immediately followed by a reloadData 
 message sent to the TableView.
 - Sometimes, randomly, the TableView requests a row index that is out of 
 bounds by one index (e.g. row #5 when the dataSource contains only 5 
 elements).
 
 I am thinking that a redraw occurs in-between the removal of one element 
 of the table and the reloadData message. 
 For now, I did a quick fix for this issue by adding a category with 
 safeObjectAtIndex…. But one way to be certain would be to ensure that 
 the two messages (removal + reloadData) are sent without any 
 thread/process switching occurring…
 
 The code for numberOfRowsInTableView : (experimentList is an instance of 
 NSMutableAray)
 
 - (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
 {  
return self.experimentList ? [self.experimentList count] : 0;
 }
 
 This is fine as long as your experimentList is only ever modified on the 
 main thread.
 
 It sounds like that isn't the case, which is why you have random problems.
 
 corbin
 
 On 26 avr. 2012, at 11:45, Peter

Re: DataSource modified while TableView is displaying data

2012-04-26 Thread Jean Suisse
Dear Peter,

Thank you for your reply. Here is the requested code (see below). 
After more investigations, I would like to take back a previous statement, that 
the tableview was perfectly aware that the number of rows in the DS was 
changed. This is due to my inexperience in stepping through the code across 
multiple threads.

Here are the facts :

- Only the controller removes rows from the datasource. Either in response to 
user actions (canceling tasks) or as a result of a Task completed notification 
from a running task.
- Each change in the dataSource is immediately followed by a reloadData message 
sent to the TableView.
- Sometimes, randomly, the TableView requests a row index that is out of bounds 
by one index (e.g. row #5 when the dataSource contains only 5 elements).

I am thinking that a redraw occurs in-between the removal of one element of the 
table and the reloadData message. 
For now, I did a quick fix for this issue by adding a category with 
safeObjectAtIndex…. But one way to be certain would be to ensure that the two 
messages (removal + reloadData) are sent without any thread/process switching 
occurring…

The code for numberOfRowsInTableView : (experimentList is an instance of 
NSMutableAray)

- (NSInteger)numberOfRowsInTableView:(NSTableView*)tableView
{   
return self.experimentList ? [self.experimentList count] : 0;
}

Jean


On 26 avr. 2012, at 11:45, Peter Hudson wrote:

 
 Can you post your code for numberOfRowsInTableView:
 
 Peter


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Concurrency: DataSource modified while TableView is displaying data

2012-04-25 Thread Jean Suisse
Hi All,

I have an NSTableView whose DataSource and delegate is a custom controller 
NSTableViewDataSource, NSTableViewDelegate holding an NSMutableArray 
(containing a list of Task/job objects).
The tableView is used to display Tasks waiting to be executed. When 
activated, the Task is requested to post its blocks on a serial queue by the 
controller.
The last block posted by all tasks will actually notify (objC message) the 
controller that the task has ended. The controller will remove the task from 
the list and request the NSTableView to reload its data. This, I presume, is 
executed from the serial queue.

Sometimes, I get an out of bounds exception from my data source (the 
NSMutableArray owned by the controller).

I am thinking:
The issue is that, sometimes, between the time the NSMutableArray is requested 
to remove an object and the time the tableView is requested to reload its data, 
some external event (rare) may trigger a redraw. The tableView, unaware that 
one element is now missing, requests from the data source an element whose row 
number is equal to the datasource's count (= out of bounds by 1 index).

What's troubling me:
When stepping through the programming with the debugger, I plainly see that the 
tableView has requested the number of elements in the datasource half a dozen 
of times before making the mistake of requesting an out-of-bounds element 
(thus, the tableview should be well aware of the new count).

Currently, every modification of the datasource is immediately followed by a 
reloadData request to the tableView. Is there a way to ensure that these two 
consecutive calls are executed without the processor switching to an other 
thread ?

Cheers,
Jean
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: What makes OS X generate a hang report?

2012-01-12 Thread Jean Suisse
Hi !

Well, I am no expert, so I can't answer your question. 
But I do have a suggestion (fix): have you tried loading your QuickTime movie 
on an other thread, and then attaching it to your main thread ? (you have to 
detach it first).

Jean

On 11 janv. 2012, at 21:56, Mark Woods wrote:

 Does anyone know the criteria OS X uses to determine an application has hung? 
 The reason I ask is that I've seen lots of inconsistencies. For example, OS X 
 will kill a process and show the log if it hangs for 5 seconds, other times 
 less than 1 second (is this even counted as a hang?) and sometimes the app 
 hangs forever and I have to force-quit it myself.
 
 Lion seems to be much more sensitive than previous versions and it will 
 occasionally kill my app when doing simple things like loading a QuickTime 
 movie into a QTMovieView, which has to be done on the main thread. (The hang 
 report reports a hang of less than 1 second.)
 
 Has anyone else seen this? Is this a bug I should report to Apple or am I 
 doing something wrong?
 
 Any light anyone can shed on this would be 
 appreciated.___
 
 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/jean.lists%40gmail.com
 
 This email sent to jean.li...@gmail.com



___

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