This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch eo-api-finalize
in repository ego.

View the commit online.

commit b94d383de78559ac3d55b5cfdd397401265bbd1b
Author: Cedric Bail <[email protected]>
AuthorDate: Thu Nov 26 02:01:53 2026 -0600

    efl: Init reports that EFL could not start
    
    Init ignored what elm_init returned, so a program went on to make
    windows on an EFL that had not started and failed somewhere else, with
    nothing saying why. Init and Run now return an error: elm_init
    returning no init count, or Ecore refusing the pipe the loop is woken
    through. A failed Init leaves the queue unmade and the thread unpinned,
    so Wait and Shutdown return at once.
    
    The examples, the test harness and ego-docgen stop on it, as they would
    on any other setup failure. The failure itself is not tested: nothing
    short of a broken EFL provokes it.
    
    efl/ui/README.md is regenerated for its snippet, and with it gains the
    classes added since it was last generated.
    
    Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
 README.md                    |   6 +-
 cmd/ego-docgen/main.go       |   4 +-
 efl/efl.go                   |  45 ++++++++++----
 efl/efl_test.go              |  29 +++++++--
 efl/ui/README.md             | 138 ++++++++++++++++++++++++++++++++++++++++++-
 efl/ui/doc.go                |   4 +-
 efl/ui/win_quit_test.go      |   5 +-
 examples/combobox/main.go    |   4 +-
 examples/form/main.go        |   4 +-
 examples/hello_world/main.go |   4 +-
 examples/weather/main.go     |   5 +-
 tests/harness/harness.go     |   9 ++-
 12 files changed, 232 insertions(+), 25 deletions(-)

diff --git a/README.md b/README.md
index 7afa5e05..9f6bf81c 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,8 @@ behave like Go.
 package main
 
 import (
+	"log"
+
 	"git.enlightenment.org/cedric/ego/efl"
 	"git.enlightenment.org/cedric/ego/efl/ui"
 	"git.enlightenment.org/cedric/ego/efl/ui/button"
@@ -16,7 +18,9 @@ import (
 )
 
 func main() {
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatal(err)
+	}
 
 	mainWindow := efl.Must(ui.NewWin(nil, win.WithWinName("hello"), win.WithText("Hello")))
 	mainWindow.QuitOnClose() // closing the window ends the program
diff --git a/cmd/ego-docgen/main.go b/cmd/ego-docgen/main.go
index c0a89b33..18e7a52d 100644
--- a/cmd/ego-docgen/main.go
+++ b/cmd/ego-docgen/main.go
@@ -304,7 +304,9 @@ func main() {
 	// Initialise the full EFL stack in buffer mode so we can render
 	// widgets without a display server.
 	os.Setenv("ELM_ENGINE", "buffer")
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatalf("ego-docgen: %v", err)
+	}
 
 	// Use the Enlightenment-X icon theme which ships PNG icons that render
 	// without SVG loader support.
diff --git a/efl/efl.go b/efl/efl.go
index 8d255b2b..9d53c213 100644
--- a/efl/efl.go
+++ b/efl/efl.go
@@ -74,6 +74,9 @@ var (
 	initOnce sync.Once
 	shutOnce sync.Once
 
+	// initErr is what Init returned the first time, written inside initOnce.
+	initErr error
+
 	// queue holds functions to be executed on the EFL thread. A full queue
 	// makes PostContext and Sync wait, off the loop thread.
 	queue chan task
@@ -133,12 +136,17 @@ func InLoop() bool {
 // queued tasks are processed once Wait enters the main loop.
 //
 // Init, Wait, and Run must all be called from the same goroutine (typically
-// the main goroutine). Calling Init more than once is a no-op.
-func Init() {
+// the main goroutine). Init does its work once: every later call returns what
+// the first one did.
+//
+// Init returns an error when EFL could not start: elm_init reports failure by
+// returning no init count, and the dispatch pipe may be refused. EFL is then
+// left as it was before Init, the goroutine is no longer pinned to its thread,
+// and Wait and Shutdown return at once while PostContext and Sync panic, as
+// before Init. Nothing else of EFL may be used, InLoop included: Eina goes
+// on taking the thread that tried for the loop's.
+func Init() error {
 	initOnce.Do(func() {
-		queue = make(chan task, 256)
-		stopped = make(chan struct{})
-
 		// Pin this goroutine permanently to its OS thread. EFL requires that
 		// all calls originate from the thread that called elm_init.
 		runtime.LockOSThread()
@@ -148,7 +156,11 @@ func Init() {
 		// doing so would leave the refcount unbalanced and cause elm_shutdown
 		// to spin the main loop indefinitely waiting for evas objects.
 		argc, argv := cArgv(os.Args)
-		C.elm_init(argc, argv)
+		if C.elm_init(argc, argv) < 1 {
+			runtime.UnlockOSThread()
+			initErr = errors.New("efl: elm_init failed")
+			return
+		}
 		C._ego_signals_onstack()
 
 		// Create the pipe. The callback drains the queue on every wakeup.
@@ -157,8 +169,17 @@ func Init() {
 			(C.Ecore_Pipe_Cb)(unsafe.Pointer(C.pipeCallback)),
 			nil,
 		)
+		if pipe == nil {
+			C.elm_shutdown()
+			runtime.UnlockOSThread()
+			initErr = errors.New("efl: ecore_pipe_add failed")
+			return
+		}
+		queue = make(chan task, 256)
+		stopped = make(chan struct{})
 		inited.Store(true)
 	})
+	return initErr
 }
 
 // Shutdown requests the EFL main loop to quit. The shutdown task sets the closed
@@ -195,7 +216,7 @@ func Shutdown() {
 // After ecore_main_loop_begin returns, Wait tears down the dispatch pipe and
 // releases the OS thread lock. Calling Wait before Init returns immediately.
 func Wait() {
-	if stopped == nil {
+	if !inited.Load() {
 		return
 	}
 	// Enter the main loop on the EFL thread. This blocks until Shutdown
@@ -232,11 +253,15 @@ func Wait() {
 
 // Run initialises EFL, calls setup on the EFL thread, enters the main loop, and
 // blocks until the main loop exits (i.e. until Shutdown is called). It combines
-// Init + setup + Wait into a single convenience call.
-func Run(setup func()) {
-	Init()
+// Init + setup + Wait into a single convenience call. When Init fails, Run
+// returns its error and does not call setup.
+func Run(setup func()) error {
+	if err := Init(); err != nil {
+		return err
+	}
 	setup()
 	Wait()
+	return nil
 }
 
 // PostContext has fn run on the EFL thread, later, and returns without
diff --git a/efl/efl_test.go b/efl/efl_test.go
index 52e344ce..a5058a60 100644
--- a/efl/efl_test.go
+++ b/efl/efl_test.go
@@ -30,7 +30,10 @@ func TestMain(m *testing.M) {
 	if os.Getenv("EGO_TEST_VALUE_POOLS") != "" {
 		// Run by TestValuePoolsAreEmptyAtShutdown in a process of its own,
 		// so that what Eina says at shutdown is about these values alone.
-		efl.Init()
+		if err := efl.Init(); err != nil {
+			fmt.Fprintln(os.Stderr, err)
+			os.Exit(1)
+		}
 		go func() {
 			exerciseCompoundValues()
 			efl.Shutdown()
@@ -41,7 +44,10 @@ func TestMain(m *testing.M) {
 	if os.Getenv("EGO_TEST_LOOP_QUIT") != "" {
 		// Run by TestLoopQuitByEFL: the loop is ended by EFL itself, as
 		// exit_on_close does, rather than by Shutdown.
-		efl.Init()
+		if err := efl.Init(); err != nil {
+			fmt.Fprintln(os.Stderr, err)
+			os.Exit(1)
+		}
 		go efl.Sync(func() {
 			l, _ := eo.AsLoop(efl.MainLoop())
 			v, _ := efl.NewValue(0)
@@ -56,14 +62,20 @@ func TestMain(m *testing.M) {
 	if os.Getenv("EGO_TEST_SYNC_GOEXIT") != "" {
 		// Run by TestSyncGoexit: Goexit on the loop thread ends the loop for
 		// good, so it gets a process of its own.
-		efl.Init()
+		if err := efl.Init(); err != nil {
+			fmt.Fprintln(os.Stderr, err)
+			os.Exit(1)
+		}
 		go efl.Sync(runtime.Goexit)
 		efl.Wait()
 		os.Exit(0)
 	}
 	// The windows some tests make have no display to open on.
 	os.Setenv("ELM_ENGINE", "buffer")
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		fmt.Fprintln(os.Stderr, err)
+		os.Exit(1)
+	}
 	var code int
 	go func() {
 		code = m.Run()
@@ -81,6 +93,15 @@ func TestInitShutdown(t *testing.T) {
 	efl.Sync(func() {})
 }
 
+// TestInitReportsNoErrorTwice verifies that Init succeeded in TestMain and
+// that a later call returns what the first one did. The failure path needs EFL
+// itself to refuse to start, which a test cannot provoke.
+func TestInitReportsNoErrorTwice(t *testing.T) {
+	if err := efl.Init(); err != nil {
+		t.Errorf("second Init: %v", err)
+	}
+}
+
 // TestPostSync verifies that a function posted with Sync is executed on the EFL
 // thread and that Sync blocks until the function completes.
 func TestPostSync(t *testing.T) {
diff --git a/efl/ui/README.md b/efl/ui/README.md
index e3ff564b..f824bde4 100644
--- a/efl/ui/README.md
+++ b/efl/ui/README.md
@@ -6,7 +6,9 @@ model.
 
 A program makes a window, fills it, shows it and enters the loop:
 
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatal(err)
+	}
 	mainWindow := efl.Must(ui.NewWin(nil, win.WithWinName("hello"), win.WithText("Hello")))
 	mainWindow.QuitOnClose()
 	greet := efl.Must(ui.NewButton(mainWindow, button.WithText("Hello")))
@@ -100,6 +102,12 @@ A variant of @Efl.Ui.Popup which uses a layout containing a content object and a
 
 ---
 
+## AverageModel
+
+An @Efl.Ui.Size_Model that estimates the total from the children it knows.
+
+---
+
 ## Bg
 
 The bg (background) widget is used for setting (solid) background decorations for a window (unless it has transparency enabled) or for any container object. It works just like an image, but has some properties useful for backgrounds, such as setting it to tiled, centered, scaled or stretched.
@@ -126,6 +134,12 @@ efl.Sync(func() {
 
 ---
 
+## Border
+
+A container that places widgets along its four edges and around a center.
+
+---
+
 ## Box
 
 A container that arranges children widgets in a vertical or horizontal fashion.
@@ -273,6 +287,12 @@ A dropdown for choosing one item out of a list, optionally editable.
 
 ---
 
+## ComboboxView
+
+A dropdown for choosing one row out of an @Efl.Model, optionally editable.
+
+---
+
 ## Datepicker
 
 A widget for picking a date.
@@ -286,6 +306,12 @@ A widget for picking a date.
 
 ---
 
+## ExactModel
+
+An @Efl.Ui.Size_Model that only ever reports sizes it has been told.
+
+---
+
 ## Fileselector
 
 A way of choosing a file.
@@ -390,6 +416,12 @@ Special @Efl.Ui.Item that acts as group header.
 
 ---
 
+## HomogeneousModel
+
+An @Efl.Ui.Size_Model where every child is the size of the first one.
+
+---
+
 ## Image
 
 Efl UI image class
@@ -923,6 +955,12 @@ A spotlight with predefined @Efl.Ui.Spotlight.Container.spotlight_manager
 
 ---
 
+## StateModel
+
+An @Efl.Boolean_Model carrying the states a view puts an item in.
+
+---
+
 ## TabBar
 
 A selectable box of items.
@@ -1088,3 +1126,101 @@ An inlined window.
 
 An off-screen window to be displayed in a remote process.
 
+## Sub-packages
+
+- [efl/ui/alertpopup](alertpopup/README.md) — 
+- [efl/ui/averagemodel](averagemodel/README.md) — 
+- [efl/ui/bg](bg/README.md) — 
+- [efl/ui/border](border/README.md) — 
+- [efl/ui/box](box/README.md) — 
+- [efl/ui/boxflow](boxflow/README.md) — 
+- [efl/ui/boxstack](boxstack/README.md) — 
+- [efl/ui/button](button/README.md) — 
+- [efl/ui/cachingfactory](cachingfactory/README.md) — 
+- [efl/ui/calendar](calendar/README.md) — 
+- [efl/ui/check](check/README.md) — 
+- [efl/ui/clock](clock/README.md) — 
+- [efl/ui/collection](collection/README.md) — 
+- [efl/ui/collectionview](collectionview/README.md) — 
+- [efl/ui/colorpicker](colorpicker/README.md) — 
+- [efl/ui/colorpickerswatch](colorpickerswatch/README.md) — 
+- [efl/ui/combobox](combobox/README.md) — 
+- [efl/ui/comboboxview](comboboxview/README.md) — 
+- [efl/ui/datepicker](datepicker/README.md) — 
+- [efl/ui/exactmodel](exactmodel/README.md) — 
+- [efl/ui/fileselector](fileselector/README.md) — 
+- [efl/ui/flip](flip/README.md) — 
+- [efl/ui/focusmanagercalc](focusmanagercalc/README.md) — 
+- [efl/ui/focusmanagerrootfocus](focusmanagerrootfocus/README.md) — 
+- [efl/ui/frame](frame/README.md) — 
+- [efl/ui/grid](grid/README.md) — 
+- [efl/ui/griddefaultitem](griddefaultitem/README.md) — 
+- [efl/ui/gridview](gridview/README.md) — 
+- [efl/ui/groupitem](groupitem/README.md) — 
+- [efl/ui/homogeneousmodel](homogeneousmodel/README.md) — 
+- [efl/ui/image](image/README.md) — 
+- [efl/ui/imagefactory](imagefactory/README.md) — 
+- [efl/ui/imagezoomable](imagezoomable/README.md) — 
+- [efl/ui/index](index/README.md) — 
+- [efl/ui/indexitem](indexitem/README.md) — 
+- [efl/ui/label](label/README.md) — 
+- [efl/ui/layout](layout/README.md) — 
+- [efl/ui/layoutfactory](layoutfactory/README.md) — 
+- [efl/ui/list](list/README.md) — 
+- [efl/ui/listdefaultitem](listdefaultitem/README.md) — 
+- [efl/ui/listplaceholderitem](listplaceholderitem/README.md) — 
+- [efl/ui/listview](listview/README.md) — 
+- [efl/ui/menu](menu/README.md) — 
+- [efl/ui/menuitem](menuitem/README.md) — 
+- [efl/ui/navigationbar](navigationbar/README.md) — 
+- [efl/ui/navigationlayout](navigationlayout/README.md) — 
+- [efl/ui/pager](pager/README.md) — 
+- [efl/ui/pan](pan/README.md) — 
+- [efl/ui/panel](panel/README.md) — 
+- [efl/ui/panes](panes/README.md) — 
+- [efl/ui/pathbar](pathbar/README.md) — 
+- [efl/ui/popup](popup/README.md) — 
+- [efl/ui/positionmanagergrid](positionmanagergrid/README.md) — 
+- [efl/ui/positionmanagerlist](positionmanagerlist/README.md) — 
+- [efl/ui/progressbar](progressbar/README.md) — 
+- [efl/ui/radio](radio/README.md) — 
+- [efl/ui/radiobox](radiobox/README.md) — 
+- [efl/ui/radiogroupimpl](radiogroupimpl/README.md) — 
+- [efl/ui/relativecontainer](relativecontainer/README.md) — 
+- [efl/ui/scroller](scroller/README.md) — 
+- [efl/ui/scrollmanager](scrollmanager/README.md) — 
+- [efl/ui/selectmodel](selectmodel/README.md) — 
+- [efl/ui/separator](separator/README.md) — 
+- [efl/ui/slider](slider/README.md) — 
+- [efl/ui/sliderinterval](sliderinterval/README.md) — 
+- [efl/ui/spin](spin/README.md) — 
+- [efl/ui/spinbutton](spinbutton/README.md) — 
+- [efl/ui/spotlightanimationmanager](spotlightanimationmanager/README.md) — 
+- [efl/ui/spotlightcontainer](spotlightcontainer/README.md) — 
+- [efl/ui/spotlightfademanager](spotlightfademanager/README.md) — 
+- [efl/ui/spotlighticonindicator](spotlighticonindicator/README.md) — 
+- [efl/ui/spotlightscrollmanager](spotlightscrollmanager/README.md) — 
+- [efl/ui/stack](stack/README.md) — 
+- [efl/ui/statemodel](statemodel/README.md) — 
+- [efl/ui/tabbar](tabbar/README.md) — 
+- [efl/ui/tabbardefaultitem](tabbardefaultitem/README.md) — 
+- [efl/ui/table](table/README.md) — 
+- [efl/ui/tablestatic](tablestatic/README.md) — 
+- [efl/ui/tabpage](tabpage/README.md) — 
+- [efl/ui/tabpager](tabpager/README.md) — 
+- [efl/ui/tags](tags/README.md) — 
+- [efl/ui/textbox](textbox/README.md) — 
+- [efl/ui/textfactoryemoticons](textfactoryemoticons/README.md) — 
+- [efl/ui/textfactoryfallback](textfactoryfallback/README.md) — 
+- [efl/ui/textfactoryimages](textfactoryimages/README.md) — 
+- [efl/ui/textpath](textpath/README.md) — 
+- [efl/ui/theme](theme/README.md) — 
+- [efl/ui/timepicker](timepicker/README.md) — 
+- [efl/ui/vganimation](vganimation/README.md) — 
+- [efl/ui/video](video/README.md) — 
+- [efl/ui/viewmodel](viewmodel/README.md) — 
+- [efl/ui/widgetfactory](widgetfactory/README.md) — 
+- [efl/ui/win](win/README.md) — 
+- [efl/ui/wininlined](wininlined/README.md) — 
+- [efl/ui/winsocket](winsocket/README.md) — 
+
diff --git a/efl/ui/doc.go b/efl/ui/doc.go
index b0c8468b..1452a8e5 100644
--- a/efl/ui/doc.go
+++ b/efl/ui/doc.go
@@ -4,7 +4,9 @@
 //
 // A program makes a window, fills it, shows it and enters the loop:
 //
-//	efl.Init()
+//	if err := efl.Init(); err != nil {
+//		log.Fatal(err)
+//	}
 //	mainWindow := efl.Must(ui.NewWin(nil, win.WithWinName("hello"), win.WithText("Hello")))
 //	mainWindow.QuitOnClose()
 //	greet := efl.Must(ui.NewButton(mainWindow, button.WithText("Hello")))
diff --git a/efl/ui/win_quit_test.go b/efl/ui/win_quit_test.go
index 9991e972..bba09a6a 100644
--- a/efl/ui/win_quit_test.go
+++ b/efl/ui/win_quit_test.go
@@ -18,7 +18,10 @@ import (
 // does to it when the user closes it, and reports whether the loop ended.
 func quitOnCloseChild() {
 	os.Setenv("ELM_ENGINE", "buffer")
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		fmt.Println(err)
+		return
+	}
 	w, err := ui.NewWin(nil, win.WithWinName("quit-on-close"))
 	if err != nil {
 		fmt.Println(err)
diff --git a/examples/combobox/main.go b/examples/combobox/main.go
index 193a37f4..8b250d98 100644
--- a/examples/combobox/main.go
+++ b/examples/combobox/main.go
@@ -21,7 +21,9 @@ import (
 )
 
 func main() {
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatal(err)
+	}
 
 	mainWindow := efl.Must(ui.NewWin(nil, win.WithWinName("combobox"), win.WithText("Combobox")))
 	mainWindow.QuitOnClose()
diff --git a/examples/form/main.go b/examples/form/main.go
index a3f9915a..f589f73a 100644
--- a/examples/form/main.go
+++ b/examples/form/main.go
@@ -183,7 +183,9 @@ func newForm(mainWindow *ui.Win) (*form, error) {
 }
 
 func main() {
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatal(err)
+	}
 
 	mainWindow := efl.Must(ui.NewWin(nil, win.WithWinName("form"), win.WithText("A form")))
 	mainWindow.QuitOnClose()
diff --git a/examples/hello_world/main.go b/examples/hello_world/main.go
index 116d288e..507cd44a 100644
--- a/examples/hello_world/main.go
+++ b/examples/hello_world/main.go
@@ -18,7 +18,9 @@ import (
 )
 
 func main() {
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatal(err)
+	}
 
 	// win_name is a constructor property: it is applied while the window is
 	// made, which is why it is an option and has no setter.
diff --git a/examples/weather/main.go b/examples/weather/main.go
index 4833b9da..dce41b82 100644
--- a/examples/weather/main.go
+++ b/examples/weather/main.go
@@ -16,6 +16,7 @@ package main
 import (
 	"context"
 	"flag"
+	"log"
 	"net/http"
 	"time"
 
@@ -28,7 +29,9 @@ func main() {
 	first := flag.String("city", "Paris", "the city to show first")
 	flag.Parse()
 
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		log.Fatal(err)
+	}
 
 	// Every request is derived from ctx, which is cancelled when the window
 	// goes. Ecore owns SIGINT and quits the loop on it, so there is no signal
diff --git a/tests/harness/harness.go b/tests/harness/harness.go
index ff1dfd3d..4d9b733e 100644
--- a/tests/harness/harness.go
+++ b/tests/harness/harness.go
@@ -27,6 +27,7 @@ static void _harness_focus(Eo *obj) {
 import "C"
 
 import (
+	"fmt"
 	"image"
 	"os"
 	"testing"
@@ -45,12 +46,16 @@ import (
 //	func TestMain(m *testing.M) { os.Exit(harness.Run(m, nil)) }
 //
 // If setup is non-nil it is called directly after Init (the calling goroutine
-// is the EFL thread).
+// is the EFL thread). When EFL fails to start, Run says why on standard error,
+// runs no test and returns 1.
 func Run(m *testing.M, setup func()) int {
 	// Force all Elementary windows to use the buffer engine so tests run
 	// headless without requiring a display server.
 	os.Setenv("ELM_ENGINE", "buffer")
-	efl.Init()
+	if err := efl.Init(); err != nil {
+		fmt.Fprintln(os.Stderr, "harness:", err)
+		return 1
+	}
 
 	if setup != nil {
 		setup()

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to