This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Segmentation fault when running NETRootInfo info(QX11Info::display(), 0)

Tags: None
(comma "," separated)
vatbier
Registered Member
Posts
16
Karma
0
I'm trying to make a program that toggles showdesktop.
I made this from the source code of plasma_applet_showdesktop.so:
NETRootInfo info(QX11Info::display(), 0);
info.setShowingDesktop(true);

But the NetRootInfo constructor gives a segmentation fault.
Can anyone tell me why?

I'm using Mandriva 2009, KDE 4.1.2.

See below for code.

vatbier

myshowdesktop.cpp :
Code: Select all
// myShowDesktop.cpp,
#include
#include
#include
#include
using namespace std;

int main()
{
    NETRootInfo info(QX11Info::display(), 0);
   // HERE OCCURS THE SEGMENTATION FAULT
   
    info.setShowingDesktop(true);
}



CMakeLists.txt :
Code: Select all
project(mijnshowdesktop)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
include(MacroOptionalAddSubdirectory)

add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})

include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${KDE4_INCLUDES} )
set(mySources myshowdesktop.cpp)
kde4_add_executable(mijnshowdesktop ${mySources})
target_link_libraries(mijnshowdesktop ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )



vatbier, proud to be a member of KDE forums since 2008-Oct.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS
vatbier wrote:I'm trying to make a program that toggles showdesktop.
I made this from the source code of plasma_applet_showdesktop.so:
NETRootInfo info(QX11Info::display(), 0);
info.setShowingDesktop(true);

But the NetRootInfo constructor gives a segmentation fault.
Can anyone tell me why?


Check if it already segaults at QX11Info::display()
That class/method looks like it might need a QApplication instance

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
vatbier
Registered Member
Posts
16
Karma
0
No segfault occurs when I do this:
Code: Select all
int main()
{   
   Display* dp=QX11Info::display();
   std::cout
...
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    NETRootInfo info(QX11Info::display(), 0);
    info.setShowingDesktop(true);


And it runs now without segfault and it minimizes all windows now!!

Thank you very much!
I know very little yet about Qt programming

vatbier

Last edited by vatbier on Fri Oct 31, 2008 11:42 pm, edited 1 time in total.


vatbier, proud to be a member of KDE forums since 2008-Oct.
User avatar
jrick
Registered Member
Posts
131
Karma
1
OS
Are you planning to make this into a plasmoid so there can be Show Desktop button and a keyboard shortcut to go along with it?


Type Colemak!

Proud, Conservative Republican

"Gentlemen! You can't fight in here! This is the war room!"
--President Merkin Muffley, Dr. Strangelove
vatbier
Registered Member
Posts
16
Karma
0
I want to have a ShowDesktop icon in the quicklauncher plasmoid that I have placed next to the icon of K menu.
The ShowDesktop widget that now sits next to the quicklauncher takes too much place (I like small icons like those of quicklaunch in Windows XP and Vista).
Dragging the ShowDesktop widget to the quicklauncher doesn't work as the quicklauncher widget can't work with "services", it expects a .desktop file with an exec command.
In KDE 3.5.9 I had made my own .desktop file with a dcop command.
Now in KDE 4.1.2 I want to do the same with a c++ program (there isn't yet a full dbus interface for plasma)


vatbier, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell