Fix krandr crashes and uninitialized variables

Work around kcmshell minimum size problem by using icon mode instead of plain page mode in the kcmshell janus widget
pull/16/head
Timothy Pearson 13 years ago
parent 5f99a27180
commit 5117798410

@ -282,7 +282,9 @@ extern "C" KDE_EXPORT int kdemain(int _argc, char *_argv[])
return 0; return 0;
} }
KDialogBase::DialogType dtype = KDialogBase::Plain; //KDialogBase::DialogType dtype = KDialogBase::Plain; // FIXME
KDialogBase::DialogType dtype = KDialogBase::IconList; // Work around a bug whereby several kcontrol modules (such as displayconfig) use an incorrect size when loaded with kcmshell in the Plain mode
// This bug is possibly related to kcmultidialog.cpp:266 [( new TQHBoxLayout( page ) )->setAutoAdd( true );]
if ( modules.count() < 1 ) if ( modules.count() < 1 )
return 0; return 0;

@ -180,7 +180,7 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
printf("Xcalib pipe error\n\r"); printf("Xcalib pipe error\n\r");
} }
else { else {
fgets(xcalib_result, 2048, pipe_xcalib); if (fgets(xcalib_result, 2048, pipe_xcalib)) {
pclose(pipe_xcalib); pclose(pipe_xcalib);
for (i=1;i<2048;i++) { for (i=1;i<2048;i++) {
if (xcalib_result[i] == 0) { if (xcalib_result[i] == 0) {
@ -192,6 +192,10 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
return xcalib_result; return xcalib_result;
} }
} }
else {
printf("Xcalib pipe error\n\r");
}
}
} }
} }
else { else {
@ -245,7 +249,7 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
printf("Xcalib pipe error\n\r"); printf("Xcalib pipe error\n\r");
} }
else { else {
fgets(xcalib_result, 2048, pipe_xcalib); if (fgets(xcalib_result, 2048, pipe_xcalib)) {
pclose(pipe_xcalib); pclose(pipe_xcalib);
for (i=1;i<2048;i++) { for (i=1;i<2048;i++) {
if (xcalib_result[i] == 0) { if (xcalib_result[i] == 0) {
@ -257,6 +261,10 @@ TQString KRandrSimpleAPI::applyIccFile(TQString screenName, TQString fileName) {
return xcalib_result; return xcalib_result;
} }
} }
else {
printf("Xcalib pipe error\n\r");
}
}
} }
} }
return ""; return "";
@ -396,7 +404,7 @@ TQString KRandrSimpleAPI::applySystemWideIccConfiguration(TQString kde_confdir)
printf("Xcalib pipe error\n\r"); printf("Xcalib pipe error\n\r");
} }
else { else {
fgets(xcalib_result, 2048, pipe_xcalib); if (fgets(xcalib_result, 2048, pipe_xcalib)) {
pclose(pipe_xcalib); pclose(pipe_xcalib);
for (i=1;i<2048;i++) { for (i=1;i<2048;i++) {
if (xcalib_result[i] == 0) { if (xcalib_result[i] == 0) {
@ -408,6 +416,10 @@ TQString KRandrSimpleAPI::applySystemWideIccConfiguration(TQString kde_confdir)
return xcalib_result; return xcalib_result;
} }
} }
else {
printf("Xcalib pipe error\n\r");
}
}
return ""; return "";
} }
@ -1109,6 +1121,8 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
screendata->rotations.append(i18n("Rotate 90 degrees")); screendata->rotations.append(i18n("Rotate 90 degrees"));
screendata->rotations.append(i18n("Rotate 180 degrees")); screendata->rotations.append(i18n("Rotate 180 degrees"));
screendata->rotations.append(i18n("Rotate 270 degrees")); screendata->rotations.append(i18n("Rotate 270 degrees"));
screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0);
if (screendata->supports_transformations) {
screendata->current_orientation_mask = cur_screen->proposedRotation(); screendata->current_orientation_mask = cur_screen->proposedRotation();
switch (screendata->current_orientation_mask & RandRScreen::RotateMask) { switch (screendata->current_orientation_mask & RandRScreen::RotateMask) {
case RandRScreen::Rotate0: case RandRScreen::Rotate0:
@ -1126,11 +1140,17 @@ TQPtrList<SingleScreenData> KRandrSimpleAPI::readCurrentDisplayConfiguration() {
default: default:
// Shouldn't hit this one // Shouldn't hit this one
Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask); Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask);
screendata->current_rotation_index = 0;
break; break;
} }
screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX); screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX);
screendata->has_y_flip = (screendata->current_orientation_mask & RandRScreen::ReflectY); screendata->has_y_flip = (screendata->current_orientation_mask & RandRScreen::ReflectY);
screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0); }
else {
screendata->has_x_flip = false;
screendata->has_y_flip = false;
screendata->current_rotation_index = 0;
}
// Determine if this display is primary and/or extended // Determine if this display is primary and/or extended
RROutput primaryoutput = XRRGetOutputPrimary(tqt_xdisplay(), DefaultRootWindow(tqt_xdisplay())); RROutput primaryoutput = XRRGetOutputPrimary(tqt_xdisplay(), DefaultRootWindow(tqt_xdisplay()));
@ -1279,7 +1299,7 @@ TQString KRandrSimpleAPI::clearIccConfiguration() {
printf("Xcalib pipe error\n\r"); printf("Xcalib pipe error\n\r");
} }
else { else {
fgets(xcalib_result, 2048, pipe_xcalib); if (fgets(xcalib_result, 2048, pipe_xcalib)) {
pclose(pipe_xcalib); pclose(pipe_xcalib);
for (i=1;i<2048;i++) { for (i=1;i<2048;i++) {
if (xcalib_result[i] == 0) { if (xcalib_result[i] == 0) {
@ -1291,6 +1311,10 @@ TQString KRandrSimpleAPI::clearIccConfiguration() {
return xcalib_result; return xcalib_result;
} }
} }
else {
printf("Xcalib pipe error\n\r");
}
}
return ""; return "";
} }

@ -40,6 +40,45 @@
#undef INT32 #undef INT32
#include <X11/extensions/Xrandr.h> #include <X11/extensions/Xrandr.h>
SingleScreenData::SingleScreenData()
{
TQString screenFriendlyName;
generic_screen_detected = false;
screen_connected = false;
current_resolution_index = 0;
current_refresh_rate_index = 0;
current_color_depth_index = 0;
gamma_red = 0.0;
gamma_green = 0.0;
gamma_blue = 0.0;
current_rotation_index = 0;
current_orientation_mask = 0;
has_x_flip = false;
has_y_flip = false;
supports_transformations = false;
is_primary = false;
is_extended = false;
absolute_x_position = 0;
absolute_y_position = 0;
current_x_pixel_count = 0;
current_y_pixel_count = 0;
has_dpms = false;
enable_dpms = false;
dpms_standby_delay = 0;
dpms_suspend_delay = 0;
dpms_off_delay = 0;
}
SingleScreenData::~SingleScreenData()
{
//
}
class RandRScreenPrivate class RandRScreenPrivate
{ {
public: public:

@ -29,7 +29,12 @@
class KTimerDialog; class KTimerDialog;
class RandRScreenPrivate; class RandRScreenPrivate;
struct SingleScreenData { class SingleScreenData {
public:
SingleScreenData();
virtual ~SingleScreenData();
public:
TQString screenFriendlyName; TQString screenFriendlyName;
bool generic_screen_detected; bool generic_screen_detected;
bool screen_connected; bool screen_connected;

Loading…
Cancel
Save