]> git.sesse.net Git - nageru/blobdiff - nageru/theme.cpp
On errors, abort() instead of exit(1); exit() in a multithreaded program just gives...
[nageru] / nageru / theme.cpp
index ead38fa819e877fceee43ec32cf4aa52a183dc92..ed99e5f346e9c8eb54b1c9670f4709f0c0dbe093 100644 (file)
@@ -455,7 +455,7 @@ int HTMLInput_new(lua_State* L)
 #else
        fprintf(stderr, "This version of Nageru has been compiled without CEF support.\n");
        fprintf(stderr, "HTMLInput is not available.\n");
-       exit(1);
+       abort();
 #endif
 }
 
@@ -1079,7 +1079,7 @@ int call_num_channels(lua_State *L)
 
        if (lua_pcall(L, 0, 1, 0) != 0) {
                fprintf(stderr, "error running function `num_channels': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        int num_channels = luaL_checknumber(L, 1);
@@ -1142,7 +1142,7 @@ Theme::Theme(const string &filename, const vector<string> &search_dirs, Resource
                for (const string &error : errors) {
                        fprintf(stderr, "%s\n", error.c_str());
                }
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 
@@ -1183,7 +1183,7 @@ Theme::Theme(const string &filename, const vector<string> &search_dirs, Resource
        luaL_unref(L, LUA_REGISTRYINDEX, theme_code_ref);
        if (lua_pcall(L, 0, 0, 0)) {
                fprintf(stderr, "Error when running %s: %s\n", path.c_str(), lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 
@@ -1251,19 +1251,19 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
 
        if (lua_pcall(L, 5, 2, 0) != 0) {
                fprintf(stderr, "error running function `get_chain': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        EffectChain *effect_chain = (EffectChain *)luaL_testudata(L, -2, "EffectChain");
        if (effect_chain == nullptr) {
                fprintf(stderr, "get_chain() for chain number %d did not return an EffectChain\n",
                        num);
-               exit(1);
+               abort();
        }
        chain.chain = effect_chain;
        if (!lua_isfunction(L, -1)) {
                fprintf(stderr, "Argument #-1 should be a function\n");
-               exit(1);
+               abort();
        }
        lua_pushvalue(L, -1);
        shared_ptr<LuaRefWithDeleter> funcref(new LuaRefWithDeleter(&m, L, luaL_ref(L, LUA_REGISTRYINDEX)));
@@ -1280,7 +1280,7 @@ Theme::Chain Theme::get_chain(unsigned num, float t, unsigned width, unsigned he
                lua_rawgeti(L, LUA_REGISTRYINDEX, funcref->get());
                if (lua_pcall(L, 0, 0, 0) != 0) {
                        fprintf(stderr, "error running chain setup callback: %s\n", lua_tostring(L, -1));
-                       exit(1);
+                       abort();
        }
                assert(lua_gettop(L) == 0);
 
@@ -1321,12 +1321,12 @@ string Theme::get_channel_name(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `channel_name': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        const char *ret = lua_tostring(L, -1);
        if (ret == nullptr) {
                fprintf(stderr, "function `channel_name' returned nil for channel %d\n", channel);
-               exit(1);
+               abort();
        }
 
        string retstr = ret;
@@ -1342,7 +1342,7 @@ int Theme::get_channel_signal(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `channel_signal': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        int ret = luaL_checknumber(L, 1);
@@ -1358,13 +1358,13 @@ std::string Theme::get_channel_color(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `channel_color': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        const char *ret = lua_tostring(L, -1);
        if (ret == nullptr) {
                fprintf(stderr, "function `channel_color' returned nil for channel %d\n", channel);
-               exit(1);
+               abort();
        }
 
        string retstr = ret;
@@ -1380,7 +1380,7 @@ bool Theme::get_supports_set_wb(unsigned channel)
        lua_pushnumber(L, channel);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `supports_set_wb': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        bool ret = checkbool(L, -1);
@@ -1399,7 +1399,7 @@ void Theme::set_wb(unsigned channel, double r, double g, double b)
        lua_pushnumber(L, b);
        if (lua_pcall(L, 4, 0, 0) != 0) {
                fprintf(stderr, "error running function `set_wb': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        assert(lua_gettop(L) == 0);
@@ -1412,7 +1412,7 @@ vector<string> Theme::get_transition_names(float t)
        lua_pushnumber(L, t);
        if (lua_pcall(L, 1, 1, 0) != 0) {
                fprintf(stderr, "error running function `get_transitions': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 
        vector<string> ret;
@@ -1477,7 +1477,7 @@ void Theme::transition_clicked(int transition_num, float t)
 
        if (lua_pcall(L, 2, 0, 0) != 0) {
                fprintf(stderr, "error running function `transition_clicked': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 }
@@ -1490,7 +1490,7 @@ void Theme::channel_clicked(int preview_num)
 
        if (lua_pcall(L, 1, 0, 0) != 0) {
                fprintf(stderr, "error running function `channel_clicked': %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
        assert(lua_gettop(L) == 0);
 }
@@ -1530,6 +1530,6 @@ void Theme::theme_menu_entry_clicked(int lua_ref)
        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_ref);
        if (lua_pcall(L, 0, 0, 0) != 0) {
                fprintf(stderr, "error running menu callback: %s\n", lua_tostring(L, -1));
-               exit(1);
+               abort();
        }
 }