Author Topic: Why does it require the Print Spooler service for simple copy/paste operation?  (Read 22744 times)

0 Members and 1 Guest are viewing this topic.

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Thank you.  I'm glad there is a reasonable explanation.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11713
  • Country: my
  • reassessing directives...
other programs can use this trick as well you can select a schematic in altium hit copy and simpy paste it in word.
i dont think word retrieves pasted data from print spooler...
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6289
  • Country: 00
other programs can use this trick as well you can select a schematic in altium hit copy and simpy paste it in word.
i dont think word retrieves pasted data from print spooler...

That sounds like a windows 3.1 workaround.  :)
 

Offline elgonzo

  • Supporter
  • ****
  • Posts: 688
  • Country: 00
The whole thing sounds like old code base and/or spaghetti code.

Remember, the canvas has to draw the schematic symbols when you load a project or add a new component.
Hence, there are already drawing routines that draw components and whatnot based on an  in-memory data model. For copy&paste, the straight-forward way would be copying of the selected objects/parameter sets and use the already existing drawing routines for rendering. The copied objects/parameter sets would eventually need to be added to the in-memory data model anyway (paste operation). There is no functionality that would benefit from using the spooler.

If it is true what free_electron said about Altium, then this is an unnecessarily complex and contrived way of doing things, because it still needs the 'normal' drawing routines, it still needs to copy&paste the selected objects/parameter sets in the data model, and yet it chooses not to use the existing drawing routines when rendering the respective components on the canvas while doing a copy&paste operation but rather introduces yet another method of how to draw components on the canvas. This looks like code smell or a hack...

However, i agree with that disabling the service in an attempt to improve performance is unnecessary micro optimization theatre...
« Last Edit: February 08, 2015, 04:00:07 am by elgonzo »
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
It sounds like a good way to copy and paste resolution independent graphic information to me.
 

Offline elgonzo

  • Supporter
  • ****
  • Posts: 688
  • Country: 00
It sounds like a good way to copy and paste resolution independent graphic information to me.

To make it abundantly clear: In a sane code base, there is no need to copy&paste graphics information. But copy&paste requires updating of the internal memory model. Rendering of the updated internal memory model is the job of the (already existing) drawing routines. And drawing routines are resolution independent anyways (well, they should be; anything else would be really stupid.) Why would anyone opt to avoid the drawing routines? To improve performance by a few microseconds perhaps? If there would be a real performance gain for copy&paste actions by copying+pasting graphical information instead of using the drawing routines of the application, then the drawing routines are utter crap...

Anyway, it is just a speculation that Altium uses the printer spooler for copy&paste of graphics information. I don't really know Altium, it could very well be that there is another meaningful, somewhat exotic reason of why Altium uses the spooler for copy&paste...
« Last Edit: February 09, 2015, 01:38:36 am by elgonzo »
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11713
  • Country: my
  • reassessing directives...
need to copy paste graphic (bitmap) from to clipboard? use CF_BITMAP or CF_DIB. need resolution independent just as in vector graphics? the host application must provide the rendering mechanism... use OLE service, provide the OLE module please...
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline baljemmett

  • Supporter
  • ****
  • Posts: 665
  • Country: gb
need to copy paste graphic (bitmap) from to clipboard? use CF_BITMAP or CF_DIB. need resolution independent just as in vector graphics? the host application must provide the rendering mechanism... use OLE service, provide the OLE module please...

… or just provide a metafile with CF_ENHMETAFILE, which is basically what free_electron is describing.  Mind you, I've not done enough poking around in that area to know how it relates to the print spooler, except that the print spooler itself has the ability to create and replay metafiles internally if configured to use EMF-format spool files.  Personally I'd have expected an app to be able to use CreateEnhMetaFile without involving the spooler service, though, so who knows what's really going on?
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
To make it abundantly clear: In a sane code base, there is no need to [blah blah blah...]

How many fully sane codebases have you come across, realistically?  I've been programming for nearly 2 decades, and I can count on a hand with no fingers exactly how many I've come across.
 

Offline elgonzo

  • Supporter
  • ****
  • Posts: 688
  • Country: 00
To make it abundantly clear: In a sane code base, there is no need to [blah blah blah...]

How many fully sane codebases have you come across, realistically?  I've been programming for nearly 2 decades, and I can count on a hand with no fingers exactly how many I've come across.

I am not sure what you are getting at.
Are you trying to say that seeing enough real-world code containing hacks and such will turn a hack into what you called a "good idea"? Or is your comment rather unrelated to the speculation about why the spooler is being used by AD?
« Last Edit: February 10, 2015, 02:33:29 pm by elgonzo »
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
I'm saying that there are always things in codebases that make zero sense on the surface, giving the appearance of a non-sane codebase, and when those decisions were made, the choice may or may not have been the best option.

I'm saying that sometimes there are good reasons, sometimes not, and I'm saying that I've never seen an in-production codebase that didn't have lots of odd decisions hard-coded in.

I agree that a SANE codebase would do things properly, and I've never come across a sane codebase, by that measure.
 

Offline elgonzo

  • Supporter
  • ****
  • Posts: 688
  • Country: 00
I'm saying that there are always things in codebases that make zero sense on the surface, giving the appearance of a non-sane codebase, and when those decisions were made, the choice may or may not have been the best option.

I'm saying that sometimes there are good reasons, sometimes not, and I'm saying that I've never seen an in-production codebase that didn't have lots of odd decisions hard-coded in.

I agree that a SANE codebase would do things properly, and I've never come across a sane codebase, by that measure.

Okay, that makes sense, and i agree. Had difficulty understanding what you were meaning with "good idea".

Having been an employed software developer myself (industrial design/product design applications), i have seen my share of hacks, and well, also have made a few hacks myself. Especially in larger code bases, touching existing production code bears a significant risk of breaking existing features and/or introducing new bugs. (That's what code branches are for.) Aside from risks regarding code changes, work on improving (existing) code bases allocates developer resources - something companies with limited resources/finances naturally do not want if it does not translate to a tangible benefit for the customer (i.e., sales points such as improved performance or new features). This and other factors (such as deadlines , company vision, brand management, etc...) can make the application of hacks a viable economic decision and for the company worth more than the cost it imposes on code maintenance.

"Good ideas" with regard to programming i rather associate with something like "best practices". On the other hand, hacks are a "necessary evil" because of the way the code base of larger software products evolve over time under economic pressures.
« Last Edit: February 10, 2015, 04:55:11 pm by elgonzo »
 

Offline Rigby

  • Super Contributor
  • ***
  • Posts: 1476
  • Country: us
  • Learning, very new at this. Righteous Asshole, too
Yep, and sometimes it's just easier as a developer to implement a hack knowing it's a hack because you're tired of trying to fix something the "correct" way, or because there is a more interesting problem next in the queue, or there is a significant time pressure to just get it done.

I've not worked with any professional developer who hasn't done so, and I've not worked on a single codebase that was fully implemented "correctly."
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6289
  • Country: 00
Yep, and sometimes it's just easier as a developer to implement a hack knowing it's a hack because you're tired of trying to fix something the "correct" way, or because there is a more interesting problem next in the queue, or there is a significant time pressure to just get it done.

I've not worked with any professional developer who hasn't done so, and I've not worked on a single codebase that was fully implemented "correctly."

I agree, it's a hack, regardless of the "justification".  ;-)

Probably inherited from the Delphi environment or implemented years ago on an older version of Windows.
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 8550
  • Country: us
    • SiliconValleyGarage
To clarify : this not required inside altium. It is done to share data with other programs.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline elgonzo

  • Supporter
  • ****
  • Posts: 688
  • Country: 00
To clarify : this not required inside altium. It is done to share data with other programs.
That's what the clipboard and the EMF format is for. You even said so yourself...  :-//

<Edit: Ha, i said "EMF format". Redundancy ahoy!>
« Last Edit: February 10, 2015, 06:22:43 pm by elgonzo »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf