OK, you folks are good. The object that manages this dialog did go out
of scope and that killed the dialog. So I fixed that. Now the dialog is
non-modal, it can stay up just like I wanted it.

At this point my question has to do with destroying that dialog properly.

My mainwindow object has a SystemlogDialog* syslog. When mainwindow gets
a signal that Help | System log menu item has been clicked, it does:

void MainWindow::viewlog()
{
  if (!syslogdialog) {
    syslogdialog = new SystemlogDialog(0);
    syslogdialog->run();
  }
  else {
    // What to do? Raise the window? Grab focus?
    syslogdialog->run();
  }
}

int SystemlogDialog::run()
{
  gtk_widget_show_all(dialog);
  return 0;
}

Problem is when I open the dialog, close it, and re-open it,
syslogdialog still points to the first object, and a dialog box with
gray background, no contents is shown.

What is the right way to catch a signal, tell the containing class to
delete and null-ify sysdialog, so everything can "start over" the next
time the user wants the dialog?

Thanks so much,

Matt

On 4/21/2016 3:04 PM, Phil Wolff wrote:
> Sounds like your dialog goes out of scope when the "return 0"
> statement executes. Is the pointer to the dialog stored on the stack
> as a local variable, or as a class variable that will be preserved
> until the class is destroyed?
>
> On 2016-04-20 06:50 PM, Matthew A. Postiff wrote:
>> On 4/20/2016 2:07 AM, Marius Gedminas wrote:
>>> On Tue, Apr 19, 2016 at 10:07:50AM -0400, Matt Postiff wrote:
>>>> I have a working dialog that displays a system log file in "real time"
>>>> in my gtk2 Windows/Linux app. It is modal.
>>>>
>>>> What I want to do is make it non-modal so it can float off to the side
>>>> of my app and always be visible while I work in the app.
>>>>
>>>> I have tried to gtk_window_set_modal to FALSE and also set <property
>>>> name="modal">False</property> in the gtkbuilder xml.
>>>>
>>>> A snippet of the code and xml is at http://pastebin.com/mACPZP85
>>>>
>>>> Any ideas what I'm doing wrong? Thank you.
>>> How are you displaying that dialog?  Your code snipped doesn't include
>>> that part.  Make sure you don't use gtk_dialog_run().  Use
>>> gtk_widget_show() or gtk_widget_show_all() (whichever is appropriate)
>>> and return to the main loop.
>>>
>>> Marius Gedminas
>> You are right. I had:
>> return gtk_dialog_run(GTK_DIALOG(dialog));
>>
>> I'm very new at this. I tried replacing that with:
>> gtk_widget_show_all(dialog);
>> return 0; // I don't use the return value anyway
>>
>> and the dialog momentarily appears, then disappears quickly before I can
>> see if the guts of it are all present.
>>
>> _______________________________________________
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
>


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to