Re: enhancement: warnings instead of fatal error for duplicate calls to gimp_env_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/28/2010 02:43 PM, lloyd konneker wrote:
::snip? SNIP!::
> Here is proposed addition for plug-ins/gimpmodule.c in pygimp_main()
> that I have lightly tested.  Note it raises a warning (Python prints
> warning on stderr once, on the second call), not an exception. Note it
> compiles with a C90 warning about mixing declarations and code.

Just move the variable declaration to the top of the function.  We 
should strive to make the codebase compile with as few meaningful 
warnings as possible.

Also, is that proper code style?

--xsdg

>
>      if (query == Py_None) {
>          PyErr_SetString(pygimp_error, "a query procedure must be
> provided");
>          return NULL;
>      }
>
>      /* lkk 2010 begin enhancement*/
>      static int was_called_previously = 0;
>
>      if (was_called_previously) {
>        PyErr_WarnEx(PyExc_RuntimeWarning, "main() should only be called
> once", 1);
>        Py_INCREF(Py_None);
>        return Py_None;
>      }
>      else {
>        /* OK to set this here since following code either succeeds in
> initializing plugin, or fails hard. */
>        was_called_previously = 1;
>      }
>      /* lkk 2010 end enhancement*/
_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux