161 Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used." |
161 Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used." |
162 |
162 |
163 self subclassResponsibility |
163 self subclassResponsibility |
164 ! |
164 ! |
165 |
165 |
166 checkForAndExitIfAnotherApplicationInstanceIsRunning |
166 shouldReuseRunningApplication |
167 "if another instance of this application is running, |
167 "answer true, if an already running application instance should be re-used" |
168 send it an openFile command for my file-argument, and exit. |
168 |
169 (i.e. to let the already running application open up another window)." |
169 ^ false |
170 |
|
171 |shouldExit| |
|
172 |
|
173 self isAnotherApplicationInstanceRunning ifTrue:[ |
|
174 shouldExit := self processStartupOfASecondInstance. |
|
175 shouldExit ifTrue:[ |
|
176 self releaseApplicationMutex. |
|
177 Smalltalk isStandAloneApp ifTrue:[ |
|
178 Smalltalk exit. |
|
179 ] |
|
180 ]. |
|
181 ]. |
|
182 ! ! |
170 ! ! |
183 |
171 |
184 !StandaloneStartup class methodsFor:'multiple applications support-helpers'! |
172 !StandaloneStartup class methodsFor:'multiple applications support-helpers'! |
185 |
173 |
186 applicationRegistryEntry |
174 applicationRegistryEntry |
210 softwareEntry := subEntry. |
198 softwareEntry := subEntry. |
211 ]. |
199 ]. |
212 applicationEntry := softwareEntry. |
200 applicationEntry := softwareEntry. |
213 ]. |
201 ]. |
214 ^ applicationEntry |
202 ^ applicationEntry |
|
203 ! |
|
204 |
|
205 checkForAndExitIfAnotherApplicationInstanceIsRunning |
|
206 "if another instance of this application is running, |
|
207 send it an openFile command for my file-argument, and exit. |
|
208 (i.e. to let the already running application open up another window)." |
|
209 |
|
210 |shouldExit| |
|
211 |
|
212 self isAnotherApplicationInstanceRunning ifTrue:[ |
|
213 shouldExit := self processStartupOfASecondInstance. |
|
214 shouldExit ifTrue:[ |
|
215 self releaseApplicationMutex. |
|
216 Smalltalk isStandAloneApp ifTrue:[ |
|
217 Smalltalk exit. |
|
218 ] |
|
219 ]. |
|
220 ]. |
|
221 |
|
222 "Modified: / 03-08-2010 / 17:27:25 / cg" |
215 ! |
223 ! |
216 |
224 |
217 confirmOpenNewApplicationInstance |
225 confirmOpenNewApplicationInstance |
218 |
226 |
219 ^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName) |
227 ^ Dialog confirm: ('Continue opening a new instance of %1 or exit?' bindWith:self applicationName) |
283 If the currentID is unknown, ask if the user wants to open a new instance of the application anyway. |
291 If the currentID is unknown, ask if the user wants to open a new instance of the application anyway. |
284 Return true if the first instance has been notified, and this second instance should exit." |
292 Return true if the first instance has been notified, and this second instance should exit." |
285 |
293 |
286 |currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded| |
294 |currentIDStringFromRegistry currentIDFromRegistry fileArg commands aWindowId setForegroundWindowSucceeded| |
287 |
295 |
288 commands := Smalltalk commandLineArguments. |
296 commands := CommandLineArguments. |
289 |
297 |
290 currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
298 currentIDStringFromRegistry := self getCurrentIDFromRegistry. |
291 |
299 |
292 "If the currentID is not found and there are arguments from the command line, |
300 "If the currentID is not found and there are arguments from the command line, |
293 we should wait in case of starting the first instance of the application |
301 we should wait in case of starting the first instance of the application |
451 ]. |
459 ]. |
452 |
460 |
453 "Modified: / 19-09-2006 / 16:30:58 / cg" |
461 "Modified: / 19-09-2006 / 16:30:58 / cg" |
454 ! |
462 ! |
455 |
463 |
|
464 loadRemainingClassLibraries |
|
465 "To speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present). |
|
466 Now, load all skipped libs (the ones marked with '*') from modules.stx." |
|
467 |
|
468 |modulesFile dllDirectory dlls| |
|
469 |
|
470 OperatingSystem isMSWINDOWSlike ifFalse:[^ self ]. |
|
471 |
|
472 self verboseInfo:'loadRemainingClassLibraries'. |
|
473 modulesFile := self stxModulesFilename. |
|
474 dllDirectory := modulesFile directory. |
|
475 |
|
476 dlls := OrderedCollection new. |
|
477 |
|
478 modulesFile readingLinesDo:[:eachModulesLine| |
|
479 |basename dllFile| |
|
480 |
|
481 basename := eachModulesLine withoutSeparators. |
|
482 |
|
483 (basename notEmpty and:[basename first == $*]) ifTrue:[ |
|
484 basename := (basename copyFrom:2) withoutSeparators, '.dll'. |
|
485 dllFile := dllDirectory construct:basename. |
|
486 |
|
487 dllFile exists ifTrue:[ |
|
488 "/ self verboseInfo:('loading: ', basename). |
|
489 Smalltalk showSplashMessage:('loading ', basename). |
|
490 dlls add:dllFile. |
|
491 ] ifFalse:[ |
|
492 self verboseInfo:( '**** cannot resolve: ', basename). |
|
493 ]. |
|
494 ]. |
|
495 ]. |
|
496 |
|
497 dlls notEmpty ifTrue:[ |
|
498 ObjectFileLoader loadObjectFiles:dlls. |
|
499 Display notNil ifTrue:[ |
|
500 "New view classes may have been loaded - have to update their styles" |
|
501 self verboseInfo:'update style caches of loaded dlls'. |
|
502 SimpleView readStyleSheetAndUpdateAllStyleCaches. |
|
503 ]. |
|
504 ]. |
|
505 ! |
|
506 |
456 setupSmalltalkFromArguments:argv |
507 setupSmalltalkFromArguments:argv |
457 "handle common command line arguments: |
508 "handle common command line arguments: |
458 --help ............... print usage and exit |
509 --help ............... print usage and exit |
459 --verbose (-V) ....... be verbose during startup |
510 --verbose (-V) ....... be verbose during startup |
460 --debug .............. enable debugger & inspector |
511 --debug .............. enable debugger & inspector |
591 "Created: / 19-09-2006 / 16:40:47 / cg" |
642 "Created: / 19-09-2006 / 16:40:47 / cg" |
592 "Modified: / 31-10-2007 / 16:18:40 / cg" |
643 "Modified: / 31-10-2007 / 16:18:40 / cg" |
593 ! |
644 ! |
594 |
645 |
595 start |
646 start |
596 CommandLineArguments := Smalltalk commandLineArguments. |
647 GenericException handle:[:ex | |
597 |
648 self verboseInfo:('Error during startup:'). |
598 self verboseInfo:('starting...'). |
649 self verboseInfo:(ex description). |
599 self verboseInfo:('args: ', CommandLineArguments asStringCollection asString). |
650 Verbose == true ifTrue:[ex suspendedContext fullPrintAllLevels:10]. |
600 |
651 ex reject. |
601 Smalltalk isStandAloneApp ifTrue:[ |
652 ] do:[ |
602 self loadPatches. |
653 |idx| |
603 self verboseInfo:('setup Smalltalk'). |
654 self verboseInfo:('starting...'). |
604 ]. |
655 CommandLineArguments := (self additionalArgumentsFromRegistry) |
605 self setupSmalltalkFromArguments:CommandLineArguments. |
656 , Smalltalk commandLineArguments. |
606 self main |
657 |
607 |
658 self verboseInfo:('args: ', CommandLineArguments asStringCollection asString). |
608 "Modified: / 31-10-2007 / 16:03:44 / cg" |
659 |
|
660 "--noRemote - do not reuse an existing application instance, |
|
661 but run in a separate process" |
|
662 idx := CommandLineArguments indexOfAny:#('--noRemote'). |
|
663 idx == 0 ifTrue:[ |
|
664 self shouldReuseRunningApplication ifTrue:[ |
|
665 "Multiple Application support: |
|
666 if another expecco is running, ask it to open another window for me. |
|
667 If that is the case, the following function will not return, but instead exit." |
|
668 self checkForAndExitIfAnotherApplicationInstanceIsRunning. |
|
669 ]. |
|
670 ] ifFalse:[ |
|
671 CommandLineArguments removeAtIndex:idx. |
|
672 Verbose := true. |
|
673 ]. |
|
674 |
|
675 "/ Arrive here, if no other application is running. |
|
676 "/ to speedup startup, we did not load all dll's (only a subset of non-GUI dll's is present). |
|
677 "/ now, load all skipped libs from modules.stx. |
|
678 self loadRemainingClassLibraries. |
|
679 |
|
680 Smalltalk isStandAloneApp ifTrue:[ |
|
681 self loadPatches. |
|
682 self verboseInfo:('setup Smalltalk'). |
|
683 ]. |
|
684 self setupSmalltalkFromArguments:CommandLineArguments. |
|
685 self main |
|
686 ]. |
|
687 |
|
688 "Modified: / 04-08-2010 / 12:30:05 / cg" |
609 ! |
689 ! |
610 |
690 |
611 startStartBlockProcess |
691 startStartBlockProcess |
612 Smalltalk startStartBlockProcess |
692 Smalltalk startStartBlockProcess |
|
693 ! |
|
694 |
|
695 stxModulesFilename |
|
696 "answer the Filename of modules.stx" |
|
697 |
|
698 |file| |
|
699 |
|
700 file := 'modules.stx' asFilename. |
|
701 file exists ifTrue:[^ file]. |
|
702 |
|
703 file := OperatingSystem pathOfSTXExecutable asFilename directory construct:'modules.stx'. |
|
704 file exists ifTrue:[^ file]. |
|
705 |
|
706 self error:'cannot find: modules.stx'. |
613 ! |
707 ! |
614 |
708 |
615 usage |
709 usage |
616 Stderr nextPutLine:'usage:'. |
710 Stderr nextPutLine:'usage:'. |
617 Stderr nextPutLine:' ',self applicationName,' [options...]'. |
711 Stderr nextPutLine:' ',self applicationName,' [options...]'. |
618 Stderr nextPutLine:' options:'. |
712 Stderr nextPutLine:' options:'. |
619 Stderr nextPutLine:' --help .................. output this message'. |
713 Stderr nextPutLine:' --help .................. output this message'. |
620 Stderr nextPutLine:' --verbose ............... verbose startup'. |
714 Stderr nextPutLine:' --verbose ............... verbose startup'. |
621 Stderr nextPutLine:' --noBanner .............. no splash screen'. |
715 Stderr nextPutLine:' --noBanner .............. no splash screen'. |
|
716 self shouldReuseRunningApplication ifTrue:[ |
|
717 Stderr nextPutLine:' --noRemote .............. start as an own application process and do not reuse a running instance'. |
|
718 ]. |
622 self allowScriptingOption ifTrue:[ |
719 self allowScriptingOption ifTrue:[ |
623 Stderr nextPutLine:' --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'. |
720 Stderr nextPutLine:' --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'. |
624 ]. |
721 ]. |
625 self allowDebugOption ifTrue:[ |
722 self allowDebugOption ifTrue:[ |
626 Stderr nextPutLine:' --debug ................. enable Debugger'. |
723 Stderr nextPutLine:' --debug ................. enable Debugger'. |