[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Wed Jul 28 07:32:27 CEST 2004
CVS commit by staikos:
use a bool, not a mutex, for single-threaded lock on data mode painting
M +23 -25 kst2dplot.cpp 1.184
M +2 -1 kst2dplot.h 1.76
--- kdeextragear-2/kst/kst/kst2dplot.cpp #1.183:1.184
@@ -217,4 +217,5 @@ void Kst2DPlot::commonConstructor(const
bool x_log,
bool y_log) {
+ _highlighting = false;
_zoomPaused = false;
_dirty = true;
@@ -989,6 +990,5 @@ void Kst2DPlot::paint(KstPaintType type,
// we might need to redraw the datamode marker...
//
- if (KstApp::inst()->dataMode()) {
- if (!_highlighting.locked()) {
+ if (KstApp::inst()->dataMode() && !_highlighting) {
_copy_x = _copy_y = KST::NOPOINT;
@@ -998,6 +998,5 @@ void Kst2DPlot::paint(KstPaintType type,
if (view) {
QPoint pos = view->mapFromGlobal(QCursor::pos());
- if (view->findChildFor(pos) == KstViewObjectPtr(this)) {
- if (GetPlotRegion().contains(pos)) {
+ if (view->findChildFor(pos) == KstViewObjectPtr(this) && GetPlotRegion().contains(pos)) {
highlightNearestDataPoint(false, view, pos);
}
@@ -1006,6 +1005,4 @@ void Kst2DPlot::paint(KstPaintType type,
}
}
- }
- }
KstPlotBase::paint(type, p);
@@ -2171,4 +2168,7 @@ void Kst2DPlot::setHasFocus(bool has) {
void Kst2DPlot::highlightNearestDataPoint(bool bRepaint, QWidget *view, const QPoint& pos) {
+ // find mouse location in plot units
+ if (!_highlighting) {
+ _highlighting = true;
QRect pr = GetPlotRegion();
double near_x, near_y;
@@ -2181,6 +2181,4 @@ void Kst2DPlot::highlightNearestDataPoin
getLScale(xmin, ymin, xmax, ymax);
- // find mouse location in plot units
- if (_highlighting.tryLock()) {
xpos = (double)(pos.x() - pr.left())/(double)pr.width() *
(xmax - xmin) + xmin;
@@ -2237,5 +2235,5 @@ void Kst2DPlot::highlightNearestDataPoin
}
- _highlighting.unlock();
+ _highlighting = false;
}
}
--- kdeextragear-2/kst/kst/kst2dplot.h #1.75:1.76
@@ -290,4 +290,6 @@ private:
bool _dirty : 1;
bool _zoomPaused : 1;
+ bool _highlighting : 1; // lock to prevent reentrancy on data mode
+ // (shouldn't this be avoidable?)
int _draggableLabel : 15; // I think this should be enough
@@ -321,5 +323,4 @@ private:
/** The single allowed image for the plot */
KstImagePtr _image;
- QMutex _highlighting;
/** Plot Markers. This needs to remain sorted **/
More information about the Kst
mailing list