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 12 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,16 +180,20 @@ 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) {
xcalib_result[i-1]=0; xcalib_result[i-1]=0;
i=2048; i=2048;
}
}
if (strlen(xcalib_result) > 2) {
return xcalib_result;
} }
} }
if (strlen(xcalib_result) > 2) { else {
return xcalib_result; printf("Xcalib pipe error\n\r");
} }
} }
} }
@ -245,16 +249,20 @@ 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) {
xcalib_result[i-1]=0; xcalib_result[i-1]=0;
i=2048; i=2048;
}
}
if (strlen(xcalib_result) > 2) {
return xcalib_result;
} }
} }
if (strlen(xcalib_result) > 2) { else {
return xcalib_result; printf("Xcalib pipe error\n\r");
} }
} }
} }
@ -396,16 +404,20 @@ 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) {
xcalib_result[i-1]=0; xcalib_result[i-1]=0;
i=2048; i=2048;
}
}
if (strlen(xcalib_result) > 2) {
return xcalib_result;
} }
} }
if (strlen(xcalib_result) > 2) { else {
return xcalib_result; printf("Xcalib pipe error\n\r");
} }
} }
return ""; return "";
@ -1109,28 +1121,36 @@ 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->current_orientation_mask = cur_screen->proposedRotation();
switch (screendata->current_orientation_mask & RandRScreen::RotateMask) {
case RandRScreen::Rotate0:
screendata->current_rotation_index = 0;
break;
case RandRScreen::Rotate90:
screendata->current_rotation_index = 1;
break;
case RandRScreen::Rotate180:
screendata->current_rotation_index = 2;
break;
case RandRScreen::Rotate270:
screendata->current_rotation_index = 3;
break;
default:
// Shouldn't hit this one
Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask);
break;
}
screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX);
screendata->has_y_flip = (screendata->current_orientation_mask & RandRScreen::ReflectY);
screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0); screendata->supports_transformations = (cur_screen->rotations() != RandRScreen::Rotate0);
if (screendata->supports_transformations) {
screendata->current_orientation_mask = cur_screen->proposedRotation();
switch (screendata->current_orientation_mask & RandRScreen::RotateMask) {
case RandRScreen::Rotate0:
screendata->current_rotation_index = 0;
break;
case RandRScreen::Rotate90:
screendata->current_rotation_index = 1;
break;
case RandRScreen::Rotate180:
screendata->current_rotation_index = 2;
break;
case RandRScreen::Rotate270:
screendata->current_rotation_index = 3;
break;
default:
// Shouldn't hit this one
Q_ASSERT(screendata->current_orientation_mask & RandRScreen::RotateMask);
screendata->current_rotation_index = 0;
break;
}
screendata->has_x_flip = (screendata->current_orientation_mask & RandRScreen::ReflectX);
screendata->has_y_flip = (screendata->current_orientation_mask & RandRScreen::ReflectY);
}
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,16 +1299,20 @@ 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) {
xcalib_result[i-1]=0; xcalib_result[i-1]=0;
i=2048; i=2048;
}
}
if (strlen(xcalib_result) > 2) {
return xcalib_result;
} }
} }
if (strlen(xcalib_result) > 2) { else {
return xcalib_result; 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,42 +29,47 @@
class KTimerDialog; class KTimerDialog;
class RandRScreenPrivate; class RandRScreenPrivate;
struct SingleScreenData { class SingleScreenData {
TQString screenFriendlyName; public:
bool generic_screen_detected; SingleScreenData();
bool screen_connected; virtual ~SingleScreenData();
TQStringList resolutions; public:
TQStringList refresh_rates; TQString screenFriendlyName;
TQStringList color_depths; bool generic_screen_detected;
TQStringList rotations; bool screen_connected;
int current_resolution_index; TQStringList resolutions;
int current_refresh_rate_index; TQStringList refresh_rates;
int current_color_depth_index; TQStringList color_depths;
TQStringList rotations;
float gamma_red;
float gamma_green; int current_resolution_index;
float gamma_blue; int current_refresh_rate_index;
int current_color_depth_index;
int current_rotation_index;
int current_orientation_mask; float gamma_red;
bool has_x_flip; float gamma_green;
bool has_y_flip; float gamma_blue;
bool supports_transformations;
int current_rotation_index;
bool is_primary; int current_orientation_mask;
bool is_extended; bool has_x_flip;
int absolute_x_position; bool has_y_flip;
int absolute_y_position; bool supports_transformations;
int current_x_pixel_count;
int current_y_pixel_count; bool is_primary;
bool is_extended;
bool has_dpms; int absolute_x_position;
bool enable_dpms; int absolute_y_position;
unsigned int dpms_standby_delay; int current_x_pixel_count;
unsigned int dpms_suspend_delay; int current_y_pixel_count;
unsigned int dpms_off_delay;
bool has_dpms;
bool enable_dpms;
unsigned int dpms_standby_delay;
unsigned int dpms_suspend_delay;
unsigned int dpms_off_delay;
}; };
class RandRScreen : public TQObject class RandRScreen : public TQObject

Loading…
Cancel
Save