~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic-proposed

« back to all changes in this revision

Viewing changes to pgadmin/dlg/dlgClasses.cpp

  • Committer: Package Import Robot
  • Author(s): Christoph Berg
  • Date: 2013-09-10 16:16:38 UTC
  • mfrom: (1.3.4)
  • Revision ID: package-import@ubuntu.com-20130910161638-wwup1q553ylww7dr
Tags: 1.18.0-1
* New upstream release.
* Don't install /usr/bin/png2c anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
//
3
3
// pgAdmin III - PostgreSQL Tools
4
4
//
5
 
// Copyright (C) 2002 - 2012, The pgAdmin Development Team
 
5
// Copyright (C) 2002 - 2013, The pgAdmin Development Team
6
6
// This software is released under the PostgreSQL Licence
7
7
//
8
8
// dlgClasses.cpp - Some dialogue base classes
94
94
                right -= size.GetWidth() + ConvertDialogToPixels(wxSize(3, 0)).x;
95
95
                btnOK->Move(right, pos.y);
96
96
        }
97
 
        if (btnApply)
98
 
        {
99
 
                size = btnApply->GetSize();
100
 
                right -= size.GetWidth() - ConvertDialogToPixels(wxSize(3, 0)).x;
101
 
                btnApply->Move(right, pos.y);
102
 
        }
103
97
 
104
98
// On OS X, reverse the buttons for UI consistency
105
99
#ifdef __WXMAC__
112
106
                btnOK->Move(pos.x, pos.y);
113
107
        }
114
108
 
115
 
        if (btnApply)
116
 
        {
117
 
                pos2 = btnApply->GetPosition();
118
 
                btnApply->Move(pos.x, pos.y);
119
 
        }
120
 
 
121
109
        btnCancel->Move(pos2.x, pos2.y);
122
110
#endif
123
111
 
440
428
        thread = 0;
441
429
        object = _object;
442
430
        txtMessages = 0;
 
431
        bIsAborted = false;
 
432
        bIsExecutionStarted = false;
 
433
        bIsExecutionCompleted = false;
443
434
 
444
435
        pgDatabase *db = object->GetDatabase();
445
436
        wxString applicationname = appearanceFactory->GetLongAppName() + _(" - Execution Tool");
455
446
void ExecutionDialog::OnClose(wxCloseEvent &event)
456
447
{
457
448
        Abort();
 
449
        // If execution is started and not yet complete it means thread is still
 
450
        // running, so we should not delete the connection object and destroy the dialog.
 
451
        if(bIsExecutionStarted && !bIsExecutionCompleted)
 
452
                return;
 
453
 
458
454
        delete conn;
459
455
        if (IsModal())
460
456
                EndModal(-1);
471
467
                Abort();
472
468
                btnCancel->Enable();
473
469
                btnOK->Enable();
474
 
                wxButton *btn = btnApply;
475
 
                if (btn)
476
 
                        btn->Enable();
477
470
        }
478
471
        else
479
472
        {
488
481
 
489
482
void ExecutionDialog::Abort()
490
483
{
491
 
        if (thread)
 
484
        // If bIsAborted is true it means abort is still in progress
 
485
        if (thread && !bIsAborted)
492
486
        {
 
487
                bIsAborted = true;
493
488
                if (thread->IsRunning())
494
 
                        thread->Delete();
 
489
                {
 
490
                        thread->CancelExecution();
 
491
                        thread->Wait();
 
492
                }
 
493
 
495
494
                delete thread;
496
495
                thread = 0;
497
496
        }
511
510
                        return;
512
511
 
513
512
                btnOK->Disable();
 
513
                // Reset the variables
 
514
                bIsAborted = false;
 
515
                bIsExecutionStarted = false;
 
516
                bIsExecutionCompleted = false;
514
517
 
515
518
                thread = new pgQueryThread(conn, sql);
516
519
                if (thread->Create() != wxTHREAD_NO_ERROR)
521
524
 
522
525
                wxLongLong startTime = wxGetLocalTimeMillis();
523
526
                thread->Run();
 
527
                // When execution is started then set the variable
 
528
                bIsExecutionStarted = true;
524
529
                wxNotebook *nb = CTRL_NOTEBOOK("nbNotebook");
525
530
                if (nb)
526
531
                        nb->SetSelection(nb->GetPageCount() - 1);
573
578
                        txtMessages->AppendText(_("\nCancelled.\n"));
574
579
 
575
580
                btnOK->Enable();
576
 
                wxButton *btn = btnApply;
577
 
                if (btn)
578
 
                        btn->Enable();
 
581
                bIsExecutionCompleted = true;
579
582
        }
580
583
        else
581
584
        {