@@ -86,11 +86,11 @@ SVEvent* SVEvent::copy() {
86
86
// / It is run from a different thread and synchronizes via SVSync.
87
87
void * ScrollView::MessageReceiver (void * a) {
88
88
int counter_event_id = 0 ; // ongoing counter
89
- char * message = NULL ;
89
+ char * message = nullptr ;
90
90
// Wait until a new message appears in the input stream_.
91
91
do {
92
92
message = ScrollView::GetStream ()->Receive ();
93
- } while (message == NULL );
93
+ } while (message == nullptr );
94
94
95
95
// This is the main loop which iterates until the server is dead (strlen = -1).
96
96
// It basically parses for 3 different messagetypes and then distributes the
@@ -112,7 +112,7 @@ void* ScrollView::MessageReceiver(void* a) {
112
112
svmap_mu->Lock ();
113
113
cur->window = svmap[window_id];
114
114
115
- if (cur->window != NULL ) {
115
+ if (cur->window != nullptr ) {
116
116
cur->parameter = new char [strlen (p) + 1 ];
117
117
strcpy (cur->parameter , p);
118
118
if (strlen (p) > 0 ) { // remove the last \n
@@ -167,7 +167,7 @@ void* ScrollView::MessageReceiver(void* a) {
167
167
waiting_for_events_mu->Unlock ();
168
168
// Signal the corresponding semaphore twice (for both copies).
169
169
ScrollView* sv = svmap[window_id];
170
- if (sv != NULL ) {
170
+ if (sv != nullptr ) {
171
171
sv->Signal ();
172
172
sv->Signal ();
173
173
}
@@ -179,9 +179,9 @@ void* ScrollView::MessageReceiver(void* a) {
179
179
// Wait until a new message appears in the input stream_.
180
180
do {
181
181
message = ScrollView::GetStream ()->Receive ();
182
- } while (message == NULL );
182
+ } while (message == nullptr );
183
183
}
184
- return 0 ;
184
+ return nullptr ;
185
185
}
186
186
187
187
// Table to implement the color index values in the old system.
@@ -242,7 +242,7 @@ int table_colors[ScrollView::GREEN_YELLOW+1][4]= {
242
242
* Scrollview implementation.
243
243
*******************************************************************************/
244
244
245
- SVNetwork* ScrollView::stream_ = NULL ;
245
+ SVNetwork* ScrollView::stream_ = nullptr ;
246
246
int ScrollView::nr_created_windows_ = 0 ;
247
247
int ScrollView::image_index_ = 0 ;
248
248
@@ -274,19 +274,19 @@ void ScrollView::Initialize(const char* name, int x_pos, int y_pos, int x_size,
274
274
bool y_axis_reversed, const char * server_name) {
275
275
// If this is the first ScrollView Window which gets created, there is no
276
276
// network connection yet and we have to set it up in a different thread.
277
- if (stream_ == NULL ) {
277
+ if (stream_ == nullptr ) {
278
278
nr_created_windows_ = 0 ;
279
279
stream_ = new SVNetwork (server_name, kSvPort );
280
280
waiting_for_events_mu = new SVMutex ();
281
281
svmap_mu = new SVMutex ();
282
282
SendRawMessage (
283
283
" svmain = luajava.bindClass('com.google.scrollview.ScrollView')\n " );
284
- SVSync::StartThread (MessageReceiver, NULL );
284
+ SVSync::StartThread (MessageReceiver, nullptr );
285
285
}
286
286
287
287
// Set up the variables on the clientside.
288
288
nr_created_windows_++;
289
- event_handler_ = NULL ;
289
+ event_handler_ = nullptr ;
290
290
event_handler_ended_ = false ;
291
291
y_axis_is_reversed_ = y_axis_reversed;
292
292
y_size_ = y_canvas_size;
@@ -301,7 +301,7 @@ void ScrollView::Initialize(const char* name, int x_pos, int y_pos, int x_size,
301
301
svmap_mu->Unlock ();
302
302
303
303
for (int i = 0 ; i < SVET_COUNT; i++) {
304
- event_table_[i] = NULL ;
304
+ event_table_[i] = nullptr ;
305
305
}
306
306
307
307
mutex_ = new SVMutex ();
@@ -327,53 +327,53 @@ void* ScrollView::StartEventHandler(void* a) {
327
327
do {
328
328
stream_->Flush ();
329
329
sv->semaphore_ ->Wait ();
330
- new_event = NULL ;
330
+ new_event = nullptr ;
331
331
int serial = -1 ;
332
332
int k = -1 ;
333
333
sv->mutex_ ->Lock ();
334
334
// Check every table entry if he is is valid and not already processed.
335
335
336
336
for (int i = 0 ; i < SVET_COUNT; i++) {
337
- if (sv->event_table_ [i] != NULL &&
337
+ if (sv->event_table_ [i] != nullptr &&
338
338
(serial < 0 || sv->event_table_ [i]->counter < serial)) {
339
339
new_event = sv->event_table_ [i];
340
340
serial = sv->event_table_ [i]->counter ;
341
341
k = i;
342
342
}
343
343
}
344
344
// If we didn't find anything we had an old alarm and just sleep again.
345
- if (new_event != NULL ) {
346
- sv->event_table_ [k] = NULL ;
345
+ if (new_event != nullptr ) {
346
+ sv->event_table_ [k] = nullptr ;
347
347
sv->mutex_ ->Unlock ();
348
- if (sv->event_handler_ != NULL ) { sv->event_handler_ ->Notify (new_event); }
348
+ if (sv->event_handler_ != nullptr ) { sv->event_handler_ ->Notify (new_event); }
349
349
if (new_event->type == SVET_DESTROY) {
350
350
// Signal the destructor that it is safe to terminate.
351
351
sv->event_handler_ended_ = true ;
352
- sv = NULL ;
352
+ sv = nullptr ;
353
353
}
354
354
delete new_event; // Delete the pointer after it has been processed.
355
355
} else { sv->mutex_ ->Unlock (); }
356
356
// The thread should run as long as its associated window is alive.
357
- } while (sv != NULL );
358
- return 0 ;
357
+ } while (sv != nullptr );
358
+ return nullptr ;
359
359
}
360
360
#endif // GRAPHICS_DISABLED
361
361
362
362
ScrollView::~ScrollView () {
363
363
#ifndef GRAPHICS_DISABLED
364
364
svmap_mu->Lock ();
365
- if (svmap[window_id_] != NULL ) {
365
+ if (svmap[window_id_] != nullptr ) {
366
366
svmap_mu->Unlock ();
367
367
// So the event handling thread can quit.
368
368
SendMsg (" destroy()" );
369
369
370
370
SVEvent* sve = AwaitEvent (SVET_DESTROY);
371
371
delete sve;
372
372
svmap_mu->Lock ();
373
- svmap[window_id_] = NULL ;
373
+ svmap[window_id_] = nullptr ;
374
374
svmap_mu->Unlock ();
375
375
// The event handler thread for this window *must* receive the
376
- // destroy event and set its pointer to this to NULL before we allow
376
+ // destroy event and set its pointer to this to nullptr before we allow
377
377
// the destructor to exit.
378
378
while (!event_handler_ended_)
379
379
Update ();
@@ -431,9 +431,9 @@ void ScrollView::SetEvent(SVEvent* svevent) {
431
431
// Place both events into the queue.
432
432
mutex_->Lock ();
433
433
// Delete the old objects..
434
- if (event_table_[specific->type ] != NULL ) {
434
+ if (event_table_[specific->type ] != nullptr ) {
435
435
delete event_table_[specific->type ]; }
436
- if (event_table_[SVET_ANY] != NULL ) {
436
+ if (event_table_[SVET_ANY] != nullptr ) {
437
437
delete event_table_[SVET_ANY]; }
438
438
// ...and put the new ones in the table.
439
439
event_table_[specific->type ] = specific;
@@ -668,7 +668,7 @@ void ScrollView::Image(const char* image, int x_pos, int y_pos) {
668
668
// Add new checkboxmenuentry to menubar.
669
669
void ScrollView::MenuItem (const char * parent, const char * name,
670
670
int cmdEvent, bool flag) {
671
- if (parent == NULL ) { parent = " " ; }
671
+ if (parent == nullptr ) { parent = " " ; }
672
672
if (flag) { SendMsg (" addMenuBarItem('%s','%s',%d,true)" ,
673
673
parent, name, cmdEvent);
674
674
} else { SendMsg (" addMenuBarItem('%s','%s',%d,false)" ,
@@ -677,26 +677,26 @@ void ScrollView::MenuItem(const char* parent, const char* name,
677
677
678
678
// Add new menuentry to menubar.
679
679
void ScrollView::MenuItem (const char * parent, const char * name, int cmdEvent) {
680
- if (parent == NULL ) { parent = " " ; }
680
+ if (parent == nullptr ) { parent = " " ; }
681
681
SendMsg (" addMenuBarItem('%s','%s',%d)" , parent, name, cmdEvent);
682
682
}
683
683
684
684
// Add new submenu to menubar.
685
685
void ScrollView::MenuItem (const char * parent, const char * name) {
686
- if (parent == NULL ) { parent = " " ; }
686
+ if (parent == nullptr ) { parent = " " ; }
687
687
SendMsg (" addMenuBarItem('%s','%s')" , parent, name);
688
688
}
689
689
690
690
// Add new submenu to popupmenu.
691
691
void ScrollView::PopupItem (const char * parent, const char * name) {
692
- if (parent == NULL ) { parent = " " ; }
692
+ if (parent == nullptr ) { parent = " " ; }
693
693
SendMsg (" addPopupMenuItem('%s','%s')" , parent, name);
694
694
}
695
695
696
696
// Add new submenuentry to popupmenu.
697
697
void ScrollView::PopupItem (const char * parent, const char * name,
698
698
int cmdEvent, const char * value, const char * desc) {
699
- if (parent == NULL ) { parent = " " ; }
699
+ if (parent == nullptr ) { parent = " " ; }
700
700
char * esc = AddEscapeChars (value);
701
701
char * esc2 = AddEscapeChars (desc);
702
702
SendMsg (" addPopupMenuItem('%s','%s',%d,'%s','%s')" , parent, name,
@@ -715,7 +715,7 @@ void ScrollView::Update() {
715
715
svmap_mu->Lock ();
716
716
for (std::map<int , ScrollView*>::iterator iter = svmap.begin ();
717
717
iter != svmap.end (); ++iter) {
718
- if (iter->second != NULL )
718
+ if (iter->second != nullptr )
719
719
iter->second ->UpdateWindow ();
720
720
}
721
721
svmap_mu->Unlock ();
@@ -817,7 +817,7 @@ char* ScrollView::AddEscapeChars(const char* input) {
817
817
const char * lastptr = input;
818
818
char * message = new char [kMaxMsgSize ];
819
819
int pos = 0 ;
820
- while (nextptr != NULL ) {
820
+ while (nextptr != nullptr ) {
821
821
strncpy (message+pos, lastptr, nextptr-lastptr);
822
822
pos += nextptr - lastptr;
823
823
message[pos] = ' \\ ' ;
0 commit comments