Bug 283748 - Umbrello be run headless to export diagrams
Summary: Umbrello be run headless to export diagrams
Status: RESOLVED WORKSFORME
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
: 130601 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-11 01:37 UTC by Kip
Modified: 2013-09-04 05:44 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kip 2011-10-11 01:37:57 UTC
Version:           unspecified (using KDE 4.5.5) 
OS:                Linux

Umbrello cannot be run on a headless machine to export diagrams because it appears that it needs the X server, even in the absence of the GUI. I've observed this happening when shelling into another machine and running the following command remotely.

Reproducible: Didn't try

Steps to Reproduce:
$ umbrello --export svg Project.xmi

Actual Results:  
umbrello: cannot connect to X server

Expected Results:  
Expected to export diagrams.

Using Umbrello UML Modeller: 2.4.5-r1254891.
Comment 1 Ralf Habacker 2012-03-13 21:14:14 UTC
(In reply to comment #0)
> Version:           unspecified (using KDE 4.5.5) 
> OS:                Linux
> 
> Umbrello cannot be run on a headless machine to export diagrams because it
> appears that it needs the X server, even in the absence of the GUI. I've
> observed this happening when shelling into another machine and running the
> following command remotely.
> 
> Reproducible: Didn't try
> 
> Steps to Reproduce:
> $ umbrello --export svg Project.xmi
> 
> Actual Results:  
> umbrello: cannot connect to X server
> 
At a first look there as some obvious reasons for this:
1. in main.cpp KApplication is created always with Gui enabled - this is easy to fix
2. UMLApp uses several objects like the QPrinter object, which creates a QWidget object. It looks they depend on an X-Server. The question is if it is possible to avoid such object creations or if not if it is possible to use some memory based gui output device to avoid the x-server dependency.
Comment 2 Ralf Habacker 2012-03-13 21:23:12 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > Version:           unspecified (using KDE 4.5.5) 
> > OS:                Linux
> > 
> > Umbrello cannot be run on a headless machine to export diagrams because it
> > appears that it needs the X server, even in the absence of the GUI. I've
> > observed this happening when shelling into another machine and running the
> > following command remotely.
> > 
> > Reproducible: Didn't try
> > 
> > Steps to Reproduce:
> > $ umbrello --export svg Project.xmi
> > 
> > Actual Results:  
> > umbrello: cannot connect to X server
> > 
> At a first look there as some obvious reasons for this:
> 1. in main.cpp KApplication is created always with Gui enabled - this is
> easy to fix
> 2. UMLApp uses several objects like the QPrinter object, which creates a
> QWidget object. It looks they depend on an X-Server. The question is if it
> is possible to avoid such object creations or if not if it is possible to
> use some memory based gui output device to avoid the x-server dependency.

At a second look: UMLApp depends on KXmlGuiWindow, which initialisation raises an error  'QWidget: Cannot create a QWidget when no GUI is being used'  in the constructor

UMLApp::UMLApp(QWidget* parent)
->  : KXmlGuiWindow(parent),




 which initialisation 
 : KXmlGuiWindow(parent),
Comment 3 Kip 2012-03-14 00:08:58 UTC
It looks like it is probably possible to run it headless, but it would mean re-factoring potentially some code - which could be difficult.
Comment 4 Ralf Habacker 2012-03-14 03:00:11 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > Version:           unspecified (using KDE 4.5.5) 
> > > OS:                Linux
> > > 
> > > Umbrello cannot be run on a headless machine to export diagrams because it
> > > appears that it needs the X server, even in the absence of the GUI. I've
> > > observed this happening when shelling into another machine and running the
> > > following command remotely.
> > > 
> > > Reproducible: Didn't try
> > > 
> > > Steps to Reproduce:
> > > $ umbrello --export svg Project.xmi
> > > 
> > > Actual Results:  
> > > umbrello: cannot connect to X server
> > > 
> > At a first look there as some obvious reasons for this:
> > 1. in main.cpp KApplication is created always with Gui enabled - this is
> > easy to fix
> > 2. UMLApp uses several objects like the QPrinter object, which creates a
> > QWidget object. It looks they depend on an X-Server. The question is if it
> > is possible to avoid such object creations or if not if it is possible to
> > use some memory based gui output device to avoid the x-server dependency.
> 
> At a second look: UMLApp depends on KXmlGuiWindow, which initialisation
> raises an error  'QWidget: Cannot create a QWidget when no GUI is being
> used'  in the constructor

The message comes from 

void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
{
    Q_Q(QWidget);
    if (QApplication::type() == QApplication::Tty)
        qFatal("QWidget: Cannot create a QWidget when no GUI is being used");

which means using KApplication/QApplication without GUI enabled will not work. 

> if it is possible to use some memory based gui output device to avoid the x-server dependency.
The answer to this is Xvfb  - http://en.wikipedia.org/wiki/Xvfb

Xvfb :1 >/dev/null 2>&1 &
DISPLAY=:1 umbrello --export-formats
bmp
bw
dot
eps
epsf
epsi
ico
jp2
jpeg
jpg
pcx
pic
png
ppm
rgb
rgba
sgi
svg
tga
tif
tiff
xbm
xpm
xv
Comment 5 Ralf Habacker 2012-03-14 03:10:23 UTC
(In reply to comment #4)
> DISPLAY=:1 umbrello --export-formats
There is one problem with --export-formats: it prints out to stderr, which makes it impossible to separate export formats from the debug output.
Comment 6 Ralf Habacker 2012-03-14 03:16:34 UTC
SVN commit 1285525 by habacker:

Use stdout as output channel for --export-formats.

Without it is not possible to separate requested informations from debug output.


 M  +1 -1      main.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1285525
Comment 7 Ralf Habacker 2012-03-14 03:16:35 UTC
SVN commit 1285526 by habacker:

We do not need the gui for --export-format command line option.


 M  +1 -1      main.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1285526
Comment 8 Kip 2012-03-14 22:20:02 UTC
Hey Ralf. I just updated to svn head (2.4.5-r1285581), rebuilt, and installed.  This is what I observed:

$ umbrello --export-formats
umbrello: cannot connect to X server

$ umbrello --export svg Project.xmi 
umbrello: cannot connect to X server
Comment 9 Ralf Habacker 2012-11-22 20:15:04 UTC
Yes, as already mentioned in this thread: umbrello on linux/unix is not able to run without a display. You can use xvfb, which is part of xorg-x11-server or Xvnc  to prodive a virtual display without any real output.
Comment 10 Ralf Habacker 2012-11-22 20:20:30 UTC
It would be good to add an additional faq entry on http://uml.sourceforge.net/faq.php. Is anyone there, who can do it ?
Comment 11 Kip 2012-11-23 01:45:32 UTC
Hey Ralph. I guess we have two options. One is to explore what would be required to get Umbrello to run headless on its own. The second is to use through xvfb. I don't know anything about xvfb, but otherwise I would modify the FAQ myself to cover that.
Comment 12 Oliver Kellogg 2012-11-24 07:20:27 UTC
*** Bug 130601 has been marked as a duplicate of this bug. ***
Comment 13 Ralf Habacker 2013-09-03 21:47:49 UTC
umbrello faq entry has been updated http://userbase.kde.org/Umbrello/FAQ#Can_I_use_Umbrello_command_line_features_without_an_X_server_.3F
Comment 14 Kip 2013-09-03 22:30:54 UTC
Thanks a lot Ralph. Always a pleasure to work with you.